/[ipchat]/ipchat/src/demux.c
ViewVC logotype

Diff of /ipchat/src/demux.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.13 by matiasaguirre, Mon Mar 21 01:47:53 2005 UTC revision 1.14 by beatk, Mon Mar 21 20:47:21 2005 UTC
# Line 66  struct fd_list_node { Line 66  struct fd_list_node {
66    
67  /* Node in timer queue. */  /* Node in timer queue. */
68  struct timer_pq_node {  struct timer_pq_node {
         timer_id id;  
69          time_t next_alarm;          time_t next_alarm;
70          unsigned long int time_incr;          unsigned long int time_incr;
71          long int time_shift;          long int time_shift;
# Line 314  void Line 313  void
313  dmx_dispatch_timer (timer_id id)  dmx_dispatch_timer (timer_id id)
314  {  {
315          struct timer_pq_node *node;          struct timer_pq_node *node;
         struct timer_pq_node tmp_node;  
316    
317          tmp_node.id = id;          node = pq_get_func (id, &timer_q);
         node = pq_get_func (&tmp_node, &timer_q);  
318    
319          if (node && get_uptime() >= node->next_alarm)          if (node && get_uptime() >= node->next_alarm)
320                  proc_timer (node);                  proc_timer (node);
# Line 361  dmx_remove_output_fd (int fd) Line 358  dmx_remove_output_fd (int fd)
358  void *  void *
359  dmx_remove_timer (timer_id id)  dmx_remove_timer (timer_id id)
360  {  {
         struct timer_pq_node tmp_node;  
361          struct timer_pq_node* node;          struct timer_pq_node* node;
362          void *data = NULL;          void *data = NULL;
363    
364          tmp_node.id = id;          node = (struct timer_pq_node *)pq_del_func (id, &timer_q);
         node = (struct timer_pq_node *)pq_del_func (&tmp_node, &timer_q);  
365          if (node) {          if (node) {
366                  data = node->data;                  data = node->data;
367                  free (node);                  free (node);
# Line 379  dmx_remove_timer (timer_id id) Line 374  dmx_remove_timer (timer_id id)
374  static int  static int
375  timer_eq (void *timer, void *timer2)  timer_eq (void *timer, void *timer2)
376  {  {
377          return timer && timer2 && ((struct timer_pq_node *)timer)->id          /* check if it's the same timer, copies not supported */
378                                    == ((struct timer_pq_node *)timer2)->id;          return timer == timer2;
379  }  }
380    
381  /* Stop reporting signal 'signum'. Restores default action for the signal. */  /* Stop reporting signal 'signum'. Restores default action for the signal. */
# Line 490  timer_pq_add (time_t next_alarm, unsigne Line 485  timer_pq_add (time_t next_alarm, unsigne
485          if (timer_q.size == 0) {          if (timer_q.size == 0) {
486                  /* not yet initialized */                  /* not yet initialized */
487                  if (pq_new (&timer_q, 127, timer_eq) < 0)                  if (pq_new (&timer_q, 127, timer_eq) < 0)
488                          return -1;                          return NULL;
489          }          }
490    
491          new_node = (struct timer_pq_node*)malloc (sizeof(struct timer_pq_node));          new_node = (struct timer_pq_node*)malloc (sizeof(struct timer_pq_node));
         new_node->id = (int)new_node;  
492          new_node->next_alarm = next_alarm;          new_node->next_alarm = next_alarm;
493          new_node->time_incr = time_incr;          new_node->time_incr = time_incr;
494          new_node->time_shift = time_shift;          new_node->time_shift = time_shift;
# Line 503  timer_pq_add (time_t next_alarm, unsigne Line 497  timer_pq_add (time_t next_alarm, unsigne
497    
498          pq_add (next_alarm, new_node, &timer_q);          pq_add (next_alarm, new_node, &timer_q);
499    
500          return new_node->id;          return new_node;
501  }  }
502    
503  /* Remove all nodes from the timer queue. */  /* Remove all nodes from the timer queue. */
# Line 578  proc_timer (struct timer_pq_node *timer) Line 572  proc_timer (struct timer_pq_node *timer)
572                  pq_chpri (timer, timer->next_alarm, &timer_q);                  pq_chpri (timer, timer->next_alarm, &timer_q);
573          }          }
574          else {          else {
575                  dmx_remove_timer (timer->id);                  dmx_remove_timer (timer);
576          }          }
577    
578          callback (data);          callback (data);

Legend:
Removed from v.1.13  
changed lines
  Added in v.1.14

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26