Author: tridge
Date: 2005-02-02 10:24:47 +0000 (Wed, 02 Feb 2005)
New Revision: 5170

WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=5170

Log:
fixed a bug handling events that have already timed out - they were
being treated as events that never time out, so they happened on the
next other event



Modified:
   branches/SAMBA_4_0/source/lib/events.c


Changeset:
Modified: branches/SAMBA_4_0/source/lib/events.c
===================================================================
--- branches/SAMBA_4_0/source/lib/events.c      2005-02-02 09:59:01 UTC (rev 
5169)
+++ branches/SAMBA_4_0/source/lib/events.c      2005-02-02 10:24:47 UTC (rev 
5170)
@@ -223,7 +223,7 @@
        struct loop_event *le;
        struct timed_event *te, *te_next;
        int selrtn;
-       struct timeval tval, t;
+       struct timeval tval, t, *tvalp=NULL;
        uint32_t destruction_count = ev->destruction_count;
 
        t = timeval_current();
@@ -264,13 +264,13 @@
                        talloc_free(te);
                        continue;
                }
-
                tv = timeval_diff(&te->next_event, &t);
-               if (timeval_is_zero(&tval)) {
+               if (tvalp == NULL) {
                        tval = tv;
                } else {
                        tval = timeval_min(&tv, &tval);
                }
+               tvalp = &tval;
        }
 
        /* only do a select() if there're fd_events
@@ -290,11 +290,7 @@
                 * sys_select() with something in the events
                 * structure - for now just use select() 
                 */
-               if (timeval_is_zero(&tval)) {
-                       selrtn = select(ev->maxfd+1, &r_fds, &w_fds, NULL, 
NULL);
-               } else {
-                       selrtn = select(ev->maxfd+1, &r_fds, &w_fds, NULL, 
&tval);
-               }
+               selrtn = select(ev->maxfd+1, &r_fds, &w_fds, NULL, tvalp);
                
                t = timeval_current();
                

Reply via email to