Fix update thread not successfully waking up with LWP
authorRon Koenderink <rkoenderink@yahoo.ca>
Sun, 8 Feb 2009 02:09:30 +0000 (20:09 -0600)
committerRon Koenderink <rkoenderink@yahoo.ca>
Sun, 8 Feb 2009 02:09:30 +0000 (20:09 -0600)
Commit 08b945568 broke empth_sleep() for LWP: it returned zero even
when woken up early.

src/lib/lwp/sel.c

index aa1e66a411d086a51e0e7c18917feab68feb4302..27b3d0c82d293d9caf8541322c99f5272d412387 100644 (file)
@@ -132,9 +132,9 @@ lwpWakeupFd(struct lwpProc *proc)
        return;
 
     lwpStatus(proc, "awakening; was sleeping on fd %d", proc->fd);
-    if (proc->runtime != (time_t)-1) {
+    if (proc->runtime != (time_t)-1 && proc->runtime != 0) {
        /* is in LwpDelayq; leave the job to lwpWakeupSleep() */
-       proc->runtime = 0;
+       proc->runtime = (time_t)-1;
        return;
     }
     FD_CLR(proc->fd, &LwpReadfds);
@@ -161,7 +161,8 @@ lwpWakeupSleep(void)
        while (NULL != (proc = lwpGetFirst(&LwpDelayq))) {
            if (now >= proc->runtime) {
                lwpStatus(proc, "sleep done");
-               proc->runtime = (time_t)-1;
+               if (proc->runtime != 0)
+                   proc->runtime = (time_t)-1;
                if (proc->fd >= 0)
                    lwpWakeupFd(proc);
                else