The WIN32 version did not block when the sleep was
already reached by the time empth_sleep() did the
time remaining calculation. The other versions
of empth_sleep() do always yield.
int
empth_sleep(time_t until)
{
- long lSec;
+ long lSec = until - time(0) > 0 ? until - time(0) : 0;
empth_t *pThread = TlsGetValue(dwTLSIndex);
int iReturn = 0;
- while (!iReturn && ((lSec = until - time(0)) > 0)) {
+ do {
loc_BlockThisThread();
loc_debug("going to sleep %ld sec", lSec);
loc_debug("sleep done. Waiting to run.");
loc_RunThisThread(NULL);
- }
+ } while (!iReturn && ((lSec = until - time(0)) > 0));
+
return iReturn;
}