Пример #1
0
void *thread_function(void *wf_context) {

  struct timeval start_time, end_time;
  double total_time;
  void *input = ((workflow_context_t *) wf_context)->input;
  workflow_t *wf = ((workflow_context_t *) wf_context)->wf;
  
  void *data = NULL;

  int num_threads = wf->num_threads;

  workflow_producer_function_t producer_function = (workflow_producer_function_t)wf->producer_function;
  workflow_consumer_function_t consumer_function = (workflow_consumer_function_t)wf->consumer_function;

  while (workflow_get_status(wf) == WORKFLOW_STATUS_RUNNING) {
    if (producer_function                        &&
	workflow_get_num_items(wf) < num_threads && 
	(!workflow_is_producer_finished(wf))     &&
	workflow_lock_producer(wf)) {
      
      //	 Extrae_event(6000019, 7); 
      total_time = 0;
      start_timer(start_time);
      data = producer_function(input);
      stop_timer(start_time, end_time, total_time);
      wf->producer_time += (total_time / 1000000.0f);

      //	 Extrae_event(6000019, 0); 
      if (data) {
	workflow_insert_item(data, wf);
      } else {
	workflow_producer_finished(wf);
      }
      workflow_unlock_producer(wf);
      
    } else if (consumer_function                         &&
	       workflow_get_num_completed_items_(wf) > 0 && 
	       workflow_lock_consumer(wf)) {	 
      if ((data = workflow_remove_item(wf))) {
	total_time = 0;
	start_timer(start_time);
	consumer_function(data);
	stop_timer(start_time, end_time, total_time);
	wf->consumer_time += (total_time / 1000000.0f);
      }

      workflow_unlock_consumer(wf);
    } else {
      workflow_schedule(wf);
    }
  }

  
  return NULL;
  //printf("Thread function end\n");
}
Пример #2
0
int perft_test_perft(EPDFile* epdFile)
{
	int i = 0;
	Timer totalTimer, perftTimer;
	printf("Testing %i perfts\n", epdFile->numEPD);

	start_timer(&totalTimer);

	for (i = 0; i < epdFile->numEPD; ++i)
	{
		EPD* epd = &epdFile->epds[i];
		int depth = 1;
		char depthKey[8];
		unsigned int perftExpected = 0, perftActual;

		printf("%i/%i %s\n", i + 1, epdFile->numEPD, epd->description);

		while (1)
		{
			snprintf(depthKey, 8, "D%i", depth);

			if (!epd_has_operation(epd, depthKey))
			{
				break;
			}

			perftExpected = epd_uint_operation(epd, depthKey);

			start_timer(&perftTimer);
			perftActual = perft_perft(&epd->board, depth);
			stop_timer(&perftTimer);

			printf("perft %i: %i [%03fs] (%i) %s\n", depth, perftActual, get_elapsed_time(&perftTimer), perftExpected,
			perftActual == perftExpected ? "PASS" : "FAIL");
			if (perftActual != perftExpected)
			{
				printf("Fail in perft test\n");
				printf("FEN: %s\n", epd->description);
				printf("Level: %i\n", depth);
				printf("Expected: %i\n", perftExpected);
				printf("Found: %i\n", perftActual);
				return 0;
			}

			++depth;
		}

		printf("\n");
	}

	stop_timer(&totalTimer);
	printf("Perft suite finished in %03fs\n", get_elapsed_time(&totalTimer));

	return 1;
}
Пример #3
0
int main(int argc, char *argv[])
{
  double integral;
  start_timer();
  integral = NormalIntegral(-0.1146);
  printf ("%.20lf\nseq:%.3lf ms\n",integral,stop_timer());

  start_timer();
  integral = vNormalIntegral(-0.1146);
  printf ("%.20lf\nvec:%.3lf ms\n",integral,stop_timer());
  return 0;
}
Пример #4
0
int main (int argc, char *argv[])  {
    // Déclare un timer, ainsi que deux recorder qui vont contenir les résultats de l'exécution du programme
    timer *t = timer_alloc();
    recorder *bash_rec = recorder_alloc("shell-bash.csv");
    recorder *prog_rec = recorder_alloc("shell-prog.csv");

    // Nom du programme C et du script à comparer
    char * progr = "./shell-program ";
    char * bash =  "./shell-bash.sh ";

    // Cette variable contient la transformation du nombre d'instruction (i).
    // Puisque cette variable est un int, 7 caractères suffisent à sa représentation.
    char  nbr[7];
    int i;

    // Allocation des emplacements contenant la commande à exécuter
    char*argProgr = (char *) malloc(24*sizeof(char));
    char*argBash = (char *) malloc(24*sizeof(char));

    if(argProgr == NULL || argBash == NULL)
        exit(EXIT_FAILURE);


    for(i=1; i<MAX_SIZE; i+=1) {
        // Convertit "i" en char* et le place dans nbr
        snprintf(nbr, 7, "%d", i);

        // Concatene les deux parties de la commande
        strncpy(argProgr, progr, 24);
        strncpy(argBash, bash, 24);
        strncat(argProgr, nbr, 7);
        strncat(argBash, nbr, 7);

        // Commence le timer et lance la commande, puis écrit le résultat dans le record approprié
        start_timer(t);
        system(argProgr);
        write_record(prog_rec, i, stop_timer(t));

        start_timer(t);
        system(argBash);
        write_record(bash_rec, i, stop_timer(t));
    }

    // Libère la mémoire
    recorder_free(bash_rec);
    recorder_free(prog_rec);
    timer_free(t);

    return EXIT_SUCCESS;
}
Пример #5
0
int main(int argc, char *argv[]) {
	removefile_state_t state = NULL;
	removefile_callback_t callback = NULL;
	pthread_t thread = NULL;
	int err = 0;

	mkdirs();
	start_timer("removefile(NULL)");
	assert(removefile("/tmp/removefile-test", NULL, REMOVEFILE_SECURE_1_PASS | REMOVEFILE_RECURSIVE) == 0);
	stop_timer();


	mkdirs();
	assert((state = removefile_state_alloc()) != NULL);
	assert(pthread_create(&thread, NULL, threadproc, state) == 0);
	start_timer("removefile(state) with cancel");
        assert(removefile_state_set(state, REMOVEFILE_STATE_ERROR_CALLBACK, removefile_error_callback) == 0);
        assert(removefile_state_set(state, REMOVEFILE_STATE_ERROR_CONTEXT, (void*)4567) == 0);
	assert(removefile("/tmp/removefile-test", state, REMOVEFILE_SECURE_1_PASS | REMOVEFILE_RECURSIVE) == -1 && errno == ECANCELED);
	stop_timer();

        start_timer("removefile(NULL)");
        assert(removefile("/tmp/removefile-test", NULL, REMOVEFILE_SECURE_1_PASS | REMOVEFILE_RECURSIVE) == 0);
        stop_timer();

	mkdirs();
	assert(removefile_state_set(state, 1234567, (void*)1234567) == -1 && errno == EINVAL);

	assert(removefile_state_set(state, REMOVEFILE_STATE_CONFIRM_CALLBACK, removefile_confirm_callback) == 0);
	assert(removefile_state_get(state, REMOVEFILE_STATE_CONFIRM_CALLBACK, &callback) == 0);
	assert(callback == removefile_confirm_callback);
	assert(removefile_state_set(state, REMOVEFILE_STATE_CONFIRM_CONTEXT, (void*)1234) == 0);

	assert(removefile_state_set(state, REMOVEFILE_STATE_ERROR_CALLBACK, removefile_error_callback) == 0);
	assert(removefile_state_get(state, REMOVEFILE_STATE_ERROR_CALLBACK, &callback) == 0);
	assert(callback == removefile_error_callback);
	assert(removefile_state_set(state, REMOVEFILE_STATE_ERROR_CONTEXT, (void*)4567) == 0);

	assert(removefile_state_set(state, REMOVEFILE_STATE_STATUS_CALLBACK, removefile_status_callback) == 0);
	assert(removefile_state_get(state, REMOVEFILE_STATE_STATUS_CALLBACK, &callback) == 0);
	assert(callback == removefile_status_callback);
	assert(removefile_state_set(state, REMOVEFILE_STATE_STATUS_CONTEXT, (void*)5678) == 0);

	start_timer("removefile(state)");
	assert(removefile("/tmp/removefile-test", state, REMOVEFILE_SECURE_1_PASS | REMOVEFILE_RECURSIVE) == 0);
	stop_timer();

	return 0;
}
Пример #6
0
int main() {

  test_setup();
  perf_start();

  for (int i = 0; i < NUM_ITER; ++i) {
    test_clear();

    reset_timer();
    start_timer();

    test_run(i);

    stop_timer();

    samples[i] = get_time();
  }

  perf_stop();
  int check = test_check();

  printf("Correct: %d\n", check);
  for (int i = 0; i < NUM_ITER; ++i)
    printf("TS[%d]: %d\n", i, samples[i]);

  perf_print_all();

  return 0;
}
Пример #7
0
/*
 * Handle packets from the receiver
 */
void handle_packet(struct packet* pckt)
{
	switch(pckt->header.type)
	{
		case DAT:
			break;
		case ACK:
			// update statistics
			ACK_packets_received++;
			// mark data packet as acknowledged by stopping its timer
			pthread_mutex_lock(&timers_mutex);
			stop_timer(timer_list, pckt->header.seqno);
			//printf("Timer %d stopped\n", pckt->header.seqno);
			pthread_mutex_unlock(&timers_mutex);
			break;
		case SYN:
			break;
		case RST:
			// update statistics
			RST_packets_received++;
			break;
		case FIN:
			break;
		default:
			break;
	}
}
Пример #8
0
void saal_okay(SIG_ENTITY *sig)
{
    SOCKET *curr;

    trace_msg("SAAL came up");
#ifdef THOMFLEX
    /*
     * Some versions of the Thomson Thomflex 5000 won't do any signaling before
     * they get a RESTART. Whenever SAAL comes up, this may indicate that the
     * switch got booted, so we send that RESTART. We also have to clear all
     * pending connections, which isn't that nice ... Note that the rest of the
     * RESTART state machine is not implemented, so the RESTART ACKNOWLEDGE
     * will yield a warning.
     */
    {
	Q_DSC dsc;
	int size;

	clear_all_calls(sig);
	q_create(&dsc,q_buffer,MAX_Q_MSG);
	q_assign(&dsc,QF_msg_type,QMSG_RESTART);
	q_assign(&dsc,QF_call_ref,0);
	q_assign(&dsc,QF_rst_class,ATM_RST_ALL_VC);
	if ((size = q_close(&dsc)) >= 0) to_signaling(sig,q_buffer,size);
    }
#endif
    if (!t309) return;
    stop_timer(t309);
    t309 = NULL;
    for (curr = sockets; curr; curr = curr->next)
	if (curr->sig == sig && curr->call_state != cs_null)
	    send_status_enq(curr);
}
Пример #9
0
//Display time and recalculate based on Pebble Time
//This is based on the difference of start and current time from the Pebble
PblTm get_display_time() {

    //get the current time
    PblTm currentTime;
    get_time(&currentTime);

    //convert start time and current time to seconds for easier difference calculation
    long startTimeSeconds = PblTm_to_seconds(startTime);
    long currentTimeSeconds = PblTm_to_seconds(currentTime);

    //find difference in seconds
    diffSeconds = currentTimeSeconds - startTimeSeconds;

    //Remember to use decisecond offsest
    if (diffSeconds == 0 && dSecondsOffset > 0)
        totalSeconds++;

    //Add total running time (totalSeconds) to display time
    displaySeconds = totalSeconds + diffSeconds;

    // Stop the count if max reached
    if (displaySeconds >= MAX_SECONDS)
    {
       	stop_timer();
    	PblTm zeroTime = { .tm_sec = 0, .tm_min = 0, .tm_hour = 0};
    	return zeroTime;
    }

    return seconds_to_PblTm(displaySeconds);
}
Пример #10
0
/* Free all resources associated with a reassembly descriptor */
static void
free_reasm(
struct reasm *r
){
	register struct reasm *rp;
	struct reasm *rplast = NULL;
	register struct frag *fp;

	for(rp = Reasmq;rp != NULL;rplast = rp,rp=rp->next)
		if(r == rp)
			break;
	if(rp == NULL)
		return;	/* Not on list */

	stop_timer(&rp->timer);
	/* Remove from list of reassembly descriptors */
	if(rplast != NULL)
		rplast->next = rp->next;
	else
		Reasmq = rp->next;

	/* Free any fragments on list, starting at beginning */
	while((fp = rp->fraglist) != NULL){
		rp->fraglist = fp->next;
		free_p(&fp->buf);
		free(fp);
	}
	free(rp);
}
Пример #11
0
// Button handlers
// Start/stop timer
void toggle_timer_click(ClickRecognizerRef recognizer, Window *window) {
    if(running) {
			stop_timer();
    } else {
			start_timer();
    }
}
Пример #12
0
/* check if sysinfo is complete, change to RACH state */
static int new_sysinfo(void)
{
	struct gsm48_sysinfo *s = &sysinfo;

	/* restart timer */
	start_timer(READ_WAIT);

	/* mandatory */
	if (!s->si1 || !s->si2 || !s->si3 || !s->si4) {
		LOGP(DRR, LOGL_INFO, "not all mandatory SI received\n");
		return 0;
	}

	/* extended band */
	if (s->nb_ext_ind_si2 && !s->si2bis) {
		LOGP(DRR, LOGL_INFO, "extended ba, but si2bis not received\n");
		return 0;
	}

	/* 2ter */
	if (s->si2ter_ind && !s->si2ter) {
		LOGP(DRR, LOGL_INFO, "si2ter_ind, but si2ter not received\n");
		return 0;
	}

	LOGP(DRR, LOGL_INFO, "Sysinfo complete\n");

	stop_timer();

	rach_count = 0;
	start_rach();

	return 0;
}
Пример #13
0
int dotcpwatch (int argc, char** argv, void *p)
{
    if(argc < 2)
    {
        tprintf ("TCP Watch Dog timer %d/%d seconds\n",
        	read_timer (&TcpWatchTimer)/1000,
        		dur_timer(&TcpWatchTimer)/1000);

        return 0;
    }

    stop_timer (&TcpWatchTimer);	/* in case it's already running */

	/* what to call on timeout */
    TcpWatchTimer.func = (void (*)(void*))dowatchtick;

    TcpWatchTimer.arg = NULLCHAR;	/* dummy value */

	/* set timer duration */
    set_timer (&TcpWatchTimer, (uint32)atoi (argv[1])*1000);

    start_timer (&TcpWatchTimer);	/* and fire it up */

    return 0;
}
Пример #14
0
static void start_timer(int sec, int micro)
{
	stop_timer();
	timer.cb = timeout_cb;
	timer.data = ms;
	osmo_timer_schedule(&timer, sec, micro);
}
Пример #15
0
/* note: this function can free the tr_web if its 'closing' flag is set
   and no tasks remain.  callers must not reference their g pointer
   after calling this function */
static void
tr_multi_socket_action( tr_web * g, int fd, int mask )
{
    int closed = FALSE;
    CURLMcode rc;

    dbgmsg( "check_run_count: prev_running %d, still_running %d",
            g->prev_running, g->still_running );

    /* invoke libcurl's processing */
    do {
        rc = curl_multi_socket_action( g->multi, fd, mask, &g->still_running );
        dbgmsg( "event_cb(): fd %d, mask %d, still_running is %d",
                fd, mask, g->still_running );
    } while( rc == CURLM_CALL_MULTI_PERFORM );
    if( rc != CURLM_OK )
        tr_err( "%s", curl_multi_strerror( rc ) );

    remove_finished_tasks( g );

    add_tasks_from_queue( g );

    if( !g->still_running ) {
        stop_timer( g );
        if( g->closing ) {
            web_close( g );
            closed = TRUE;
        }
    }

    if( !closed )
        restart_timer( g );
}
Пример #16
0
static void
web_close( tr_web * g )
{
    stop_timer( g );
    curl_multi_cleanup( g->multi );
    tr_free( g );
}
Пример #17
0
void gradient_end_txrx()
{
  stop_timer();
  Qprint();
  gradient_set_state(GRADIENT_IDLE);
  wor_start(IS_SINK_NODE);
}
Пример #18
0
static void
timer_close(struct sol_flow_node *node, void *data)
{
    struct timer_data *mdata = data;

    stop_timer(mdata);
}
void timer_stop(void)
{
    int oldstatus = disable_interrupt_save(IRQ_FIQ_STATUS);
    /* Halt timer if running - stop module clock */
    stop_timer(true);
    restore_interrupt(oldstatus);
}
Пример #20
0
void do_adc(void)
{
	uint8_t	channel = adc_work_channels[adc_current_channel];
	
	if (ADC_USE_INTERRUPT == g_use_interrupt)
		return;
	
	if ((0 == adc[channel].timer_id) ||
		(0 == timer_value(adc[channel].timer_id)))
	{
		adc[channel].new_value += adc_single_value(channel);
		adc[channel].count++;
		if (adc[channel].count > adc[channel].max_count - 1)
		{
			adc[channel].count = 0;
			adc[channel].mean_value = 
				(int16_t)(adc[channel].new_value / adc[channel].max_count);
			adc[channel].new_value = 0;
		}
		
		stop_timer(adc[channel].timer_id);
		adc[channel].timer_id = start_timer(adc[channel].delay);
	}
	
	adc_current_channel++;
	if (-1 == adc_work_channels[adc_current_channel])
		adc_current_channel = 0;
}
Пример #21
0
static int vtimer_cntp_ctl(struct cpu_user_regs *regs, uint32_t *r, int read)
{
    struct vcpu *v = current;

    if ( !ACCESS_ALLOWED(regs, EL0PTEN) )
        return 0;

    if ( read )
    {
        *r = v->arch.phys_timer.ctl;
    }
    else
    {
        uint32_t ctl = *r & ~CNTx_CTL_PENDING;
        if ( ctl & CNTx_CTL_ENABLE )
            ctl |= v->arch.phys_timer.ctl & CNTx_CTL_PENDING;
        v->arch.phys_timer.ctl = ctl;

        if ( v->arch.phys_timer.ctl & CNTx_CTL_ENABLE )
        {
            set_timer(&v->arch.phys_timer.timer,
                      v->arch.phys_timer.cval + v->domain->arch.phys_timer_base.offset);
        }
        else
            stop_timer(&v->arch.phys_timer.timer);
    }
    return 1;
}
bool timer_set(long cycles, bool start)
{
    /* Maximum cycle count expressible in the cycles parameter is 2^31-1
     * and the modulus counter is capable of 2^32-1 and as a result there is
     * no requirement to use a prescaler > 1. This gives a frequency range of
     * ~0.015366822Hz - 66000000Hz. The highest input frequency gives the
     * greatest possible accuracy anyway. */
    int oldstatus = disable_interrupt_save(IRQ_FIQ_STATUS);

    /* Halt timer if running - leave module clock enabled */
    stop_timer(false);

    if (start && pfn_unregister != NULL)
    {
        pfn_unregister();
        pfn_unregister = NULL;
    }

    /* CLKSRC = ipg_clk,
     * EPIT output disconnected,
     * Enabled in wait mode
     * Prescale 1 for 66MHz
     * Reload from modulus register,
     * Count from load value */
    EPITCR2 = EPITCR_CLKSRC_IPG_CLK | EPITCR_WAITEN | EPITCR_IOVW |
              ((1-1) << EPITCR_PRESCALER_POS) | EPITCR_RLD | EPITCR_ENMOD;
    EPITLR2 = cycles;
    /* Event when counter reaches 0 */
    EPITCMPR2 = 0;

    restore_interrupt(oldstatus);
    return true;
}
void wait_for_interrupt()
{
	int pending = 0;
	int reenable = 1;

	printf("Wait for the Timer interrupt to trigger \n");
	printf("$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$\n");

	/* block on the file waiting for an interrupt */

	read(timer_fd, (void *)&pending, sizeof(int));

	printf("\n\[email protected]@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n");
	printf("Interrupting ZYNQ!\n");
	printf("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n");

	/* the interrupt occurred so stop the timer and clear the interrupt and then
	 * wait til those are done before re-enabling the interrupt
	 */
	stop_timer();
	clear_interrupt();

	/* re-enable the interrupt again now that it's been handled */

	write(timer_fd, (void *)&reenable, sizeof(int));

	printf("\n\nExit interrupt \n\n");
}
Пример #24
0
void select_item() {
  uint64_t elapsed = stop_timer(&select_timeout_sec, &select_timeout_msec);
  if (elapsed > SELECT_TIME_THR) {
    MenuIndex idx = menu_layer_get_selected_index(menu_layer);
    menu_select_callback(menu_layer, &idx, NULL);
  }
}
Пример #25
0
/**
 * print_timer() 関数テスト
 *
 * @return なし
 */
void
test_print_timer(void)
{
    unsigned int t = 0, time = 0; /* タイマ用変数 */
    int fd = -1;                  /* ファイルディスクリプタ */
    int retval = 0;               /* 戻り値 */
    char actual[BUF_SIZE] = {0};  /* 実際の文字列 */
    const char expected[] =       /* 期待する文字列 */
        "time of time: [0-9]+\\.[0-9]+\\[msec\\]";

    start_timer(&t);
    time = stop_timer(&t);
    fd = pipe_fd(STDERR_FILENO);
    if (fd < 0) {
        cut_error("pipe_fd=%d(%d)", fd, errno);
        return;
    }

    print_timer(time);

    retval = read(fd, actual, sizeof(actual));
    if (retval < 0) {
        cut_fail("read=%d(%d)", fd, errno);
        goto error_handler;
    }
    dbglog("actual=%s", actual);

    cut_assert_match(expected, actual,
                     cut_message("expected=%s actual=%s",
                                 expected, actual));

error_handler:
    close_fd(&fd, NULL);
}
Пример #26
0
static void
do_powm ( const char *n_str, const char *e_str, const char *m_str)
{
  gcry_mpi_t e, n, msg, cip;
  gcry_error_t err;
  int i;

  err = gcry_mpi_scan (&n, GCRYMPI_FMT_HEX, n_str, 0, 0);
  if (err) BUG ();
  err = gcry_mpi_scan (&e, GCRYMPI_FMT_HEX, e_str, 0, 0);
  if (err) BUG ();
  err = gcry_mpi_scan (&msg, GCRYMPI_FMT_HEX, m_str, 0, 0);
  if (err) BUG ();

  cip = gcry_mpi_new (0);

  start_timer ();
  for (i=0; i < 1000; i++)
    gcry_mpi_powm (cip, msg, e, n);
  stop_timer ();
  printf (" %s", elapsed_time ()); fflush (stdout);
/*    { */
/*      char *buf; */

/*      if (gcry_mpi_aprint (GCRYMPI_FMT_HEX, (void**)&buf, NULL, cip)) */
/*        BUG (); */
/*      printf ("result: %s\n", buf); */
/*      gcry_free (buf); */
/*    } */
  gcry_mpi_release (cip);
  gcry_mpi_release (msg);
  gcry_mpi_release (n);
  gcry_mpi_release (e);
}
Пример #27
0
void GlobalCleanup()
{
	int t;

	stop_timer();
	for (t=0;t<GLOBAL.objects;t++) objects[t]->session_stop();
	
	while (GLOBAL.objects>0)   free_object(0);
	
	BreakDownCommPort();
	// for (t=0;t<GLOBAL.objects;t++) free_object(0);

    CloseHandle(TTY.ThreadExitEvent);
	for (t=0;t<GLOBAL.midiports;t++)
  	  if (MIDIPORTS[t].midiout) midiOutClose(MIDIPORTS[t].midiout);

	if (CAPTFILE.filehandle!=0) CloseHandle(CAPTFILE.filehandle);

	SDLNet_Quit();
	SDL_Quit();

	DeleteObject(DRAW.brush_blue);
	DeleteObject(DRAW.pen_blue);
	DeleteObject(DRAW.pen_white);
	write_logfile("BrainBay normal shutdown.");

    return;
}
Пример #28
0
void ppp_fsm_recv_conf_req_ack(struct ppp_fsm_t *layer)
{
	switch(layer->fsm_state)
	{
		case FSM_Closed:
			layer->send_term_ack(layer);
			break;
		case FSM_Stopped:
			//if (layer->init_req_cnt) layer->init_req_cnt(layer);
			init_req_counter(layer,layer->max_configure);
			--layer->restart_counter;
			if (layer->send_conf_req) layer->send_conf_req(layer);
		case FSM_Req_Sent:
		case FSM_Ack_Sent:
			if (layer->send_conf_ack) layer->send_conf_ack(layer);
			layer->fsm_state=FSM_Ack_Sent;
			break;
		case FSM_Ack_Rcvd:
			if (layer->send_conf_ack) layer->send_conf_ack(layer);
			stop_timer(layer);
			if (layer->layer_up) layer->layer_up(layer);
			layer->fsm_state=FSM_Opened;
			break;
		case FSM_Opened:
			if (layer->layer_down) layer->layer_down(layer);
			--layer->restart_counter;
			if (layer->send_conf_req) layer->send_conf_req(layer);
			if (layer->send_conf_ack) layer->send_conf_ack(layer);
			layer->fsm_state=FSM_Ack_Sent;
			break;
		default:
			break;
	}
}
Пример #29
0
/*
 * Restart from root all pending referrals which its previous referral has expired.
 * @param expired_referral_cache Referral cache entry that has expired
 */
void reset_pending_referrals_with_expired_previous_referral(lispd_referral_cache_entry *expired_referral_cache)
{
    lispd_pending_referral_cache_list   *pending_referrals      = pening_referrals_list;
    lispd_pending_referral_cache_entry  *pending_referral_entry = NULL;

    while (pending_referrals != NULL){
        if (pending_referrals->pending_referral_cache_entry->previous_referral == expired_referral_cache){
            pending_referral_entry = pending_referrals->pending_referral_cache_entry;
            pending_referral_entry->previous_referral = get_root_referral_cache(pending_referral_entry->map_cache_entry->mapping->eid_prefix.afi);
            pending_referral_entry->tried_locators = 0;
            pending_referral_entry->request_through_root = TRUE;
            if (pending_referral_entry->nonces != NULL){
                free(pending_referral_entry->nonces);
                pending_referral_entry->nonces = NULL;
            }
            if (pending_referral_entry->ddt_request_retry_timer != NULL){
                stop_timer(pending_referral_entry->ddt_request_retry_timer);
                pending_referral_entry->ddt_request_retry_timer = NULL;
            }
            lispd_log_msg(LISP_LOG_DEBUG_1,"reset_pending_referrals_with_expired_previous_referral: Resetting of pending referral cache "
                    "%s/%d due to expiration of its parent referral node. Restart from root",
                    get_char_from_lisp_addr_t(pending_referral_entry->map_cache_entry->mapping->eid_prefix),
                    pending_referral_entry->map_cache_entry->mapping->eid_prefix_length);
            err = send_ddt_map_request_miss(NULL,(void *)pending_referral_entry);
        }
        pending_referrals = pending_referrals->next;
    }
}
Пример #30
0
void ppp_fsm_recv_term_ack(struct ppp_fsm_t *layer)
{
	stop_timer(layer);
	switch(layer->fsm_state)
	{
		case FSM_Closing:
			layer->fsm_state=FSM_Closed;
			if (layer->layer_finished) layer->layer_finished(layer);
			break;
		case FSM_Stopping:
			layer->fsm_state=FSM_Stopped;
			if (layer->layer_finished) layer->layer_finished(layer);
			break;
		case FSM_Ack_Rcvd:
			layer->fsm_state=FSM_Req_Sent;
			break;
		case FSM_Opened:
			if (layer->layer_down) layer->layer_down(layer);
			--layer->restart_counter;
			if (layer->send_conf_req) layer->send_conf_req(layer);
			layer->fsm_state=FSM_Req_Sent;
			break;
		default:
			break;
	}
}