FACT++  1.0
TIMR_ENT* dtq_add_entry ( int  queue_id,
int  time,
void(*)()  user_routine,
dim_long  tag 
)

Definition at line 399 of file dtq.c.

References DIM_next_time, DIM_time_left, dll_get_prev(), dll_insert_after(), get_elapsed_time(), get_minimum(), Memory::malloc(), my_alarm(), timer_entry::prev, QUEUE_ENT::queue_head, queue_id, SPECIAL_QUEUE, start_it(), Std_timer_handler(), stop_it(), timer_entry::tag, time, timer_entry::time, timer_entry::time_left, user_routine(), and timer_entry::user_routine.

Referenced by dis_insert_request(), dtq_start_timer(), handle_registration(), insert_service(), main(), modify_service(), open_dns(), recv_dns_dis_rout(), and tcpip_set_test_write().

400 {
401  TIMR_ENT *new_entry, *queue_head, *auxp, *prevp;
402  int next_time, min_time = 100000;
403  int time_left, deltat = 0;
404 
405  DISABLE_AST
406 
407  next_time = time;
408  if(!next_time)
409  next_time = -10;
410  if(Alarm_runs)
411  {
412  time_left = DIM_time_left;
413  if(!time_left)
414  time_left = DIM_next_time;
415  if((time_left > next_time) || (queue_id == SPECIAL_QUEUE))
416  {
417  if(next_time != -10)
418  {
419  min_time = stop_it();
420  if((next_time > min_time) && (min_time != 0))
421  next_time = min_time;
422  }
423  else
424  my_alarm(next_time);
425  }
426  else
427  {
428  deltat = get_elapsed_time();
429  }
430  }
431  new_entry = (TIMR_ENT *)malloc( sizeof(TIMR_ENT) );
432  new_entry->time = time;
433  if( user_routine )
434  new_entry->user_routine = user_routine;
435  else
436  new_entry->user_routine = Std_timer_handler;
437  new_entry->tag = tag;
438  new_entry->time_left = time + deltat;
439 
440  queue_head = timer_queues[queue_id].queue_head;
441  if(!time)
442  {
443  dll_insert_after((DLL *)queue_head->prev, (DLL *)new_entry);
444  }
445  else
446  {
447  if(queue_head)
448  {
449  auxp = queue_head;
450  prevp = auxp;
451  while((auxp = (TIMR_ENT *)dll_get_prev((DLL *)queue_head, (DLL *)auxp)))
452  {
453  if(time >= auxp->time)
454  {
455  break;
456  }
457  prevp = auxp;
458  }
459 /*
460  if(auxp)
461  {
462  if(queue_id != SPECIAL_QUEUE)
463  {
464  if(auxp->time_left > 0)
465  {
466  if(auxp->time == time)
467  new_entry->time_left = auxp->time_left;
468  }
469  }
470  prevp = auxp;
471  }
472 */
473  dll_insert_after((DLL *)prevp, (DLL *)new_entry);
474  }
475  }
476  if(!Alarm_runs)
477  {
478  if((next_time != -10) && (min_time == 100000))
479  {
480  min_time = get_minimum(0);
481  if(next_time > min_time)
482  next_time = min_time;
483  }
484  start_it(next_time);
485  }
486  ENABLE_AST
487  return(new_entry);
488 }
static int stop_it()
Definition: dtq.c:613
static void Std_timer_handler()
Definition: dtq.c:786
DLL * dll_get_prev(DLL *head, DLL *item)
Definition: dll.c:77
dim_long tag
Definition: dim.h:377
void dll_insert_after(DLL *atitem, DLL *item)
Definition: dll.c:36
static int DIM_next_time
Definition: dtq.c:69
void * malloc()
Definition: EventBuilder.cc:99
Definition: dim.h:370
static int get_elapsed_time()
Definition: dtq.c:247
#define SPECIAL_QUEUE
Definition: dtq.c:32
static int Alarm_runs
Definition: dtq.c:60
static QUEUE_ENT timer_queues[MAX_TIMER_QUEUES+2]
Definition: dtq.c:54
TIMR_ENT * queue_head
Definition: dtq.c:49
Definition: dim.h:530
static int start_it(int new_time)
Definition: dtq.c:632
int time_left
Definition: dim.h:375
static int get_minimum(int deltat)
Definition: dtq.c:555
Warning because the service this data corrsponds to might have been last updated longer ago than Local time
Definition: smartfact.txt:92
int time
Definition: dim.h:374
static int my_alarm(int secs)
Definition: dtq.c:261
static int queue_id
Definition: tcpip.c:93
static int DIM_time_left
Definition: dtq.c:70
void(* user_routine)()
Definition: dim.h:376
static void user_routine(void *tagp, void *bufp, int *size)
Definition: diccpp.cxx:11
struct timer_entry * prev
Definition: dim.h:372

+ Here is the call graph for this function:

+ Here is the caller graph for this function: