/* -*-c-*-
*
- * $Id: sel.c,v 1.5 1999/08/31 17:42:22 mdw Exp $
+ * $Id: sel.c,v 1.8 2000/03/23 20:42:08 mdw Exp $
*
* I/O multiplexing support
*
/*----- Revision history --------------------------------------------------*
*
* $Log: sel.c,v $
+ * Revision 1.8 2000/03/23 20:42:08 mdw
+ * Rearrange timeout handling to avoid list corruptions.
+ *
+ * Revision 1.7 1999/12/11 11:12:17 mdw
+ * Fix comment formatting error.
+ *
+ * Revision 1.6 1999/09/26 14:28:11 mdw
+ * (sel_select): Almost pointless efficiency tweak.
+ *
* Revision 1.5 1999/08/31 17:42:22 mdw
* New function `sel_force' to force a descriptor to be `selected'.
*
}
/* --- @sel_fdmerge@ --- *
- *
+ *
* Arguments: @fd_set *dest@ = destination FD set
* @fd_set *fd@ = pointer to set to merge
* @int maxfd@ = highest numbered descriptor in @fd@ + 1
/* --- Run through the timers --- */
- {
+ if (s->timers && TV_CMP(&s->timers->tv, <=, &a.now)) {
sel_timer *t, *tt;
- for (t = s->timers; t && TV_CMP(&t->tv, <=, &a.now); t = tt) {
+ tt = s->timers;
+ for (t = tt; t && TV_CMP(&t->tv, <=, &a.now); t = t->next)
+ ;
+ if (t) {
+ t->prev->next = 0;
+ t->prev = (sel_timer *)&s->timers;
+ }
+ s->timers = t;
+ for (t = tt; t; t = tt) {
tt = t->next;
- t->next = t->prev = t;
t->func(&a.now, t->p);
}
- s->timers = t;
- if (t)
- t->prev = (sel_timer *)&s->timers;
}
/* --- And finally run through the files --- *
sel_file *f, *ff;
for (f = s->files[i]; f; f = ff) {
ff = f->next;
- if (FD_ISSET(f->fd, a.fd + f->mode))
- f->func(f->fd, f->mode, f->p);
+ if (FD_ISSET(f->fd, a.fd + i))
+ f->func(f->fd, i, f->p);
}
}
}