]> git.pond.sub.org Git - empserver/commitdiff
(empth_sleep) [_WIN32]: Ensure the thread does not waking up early.
authorRon Koenderink <rkoenderink@yahoo.ca>
Sat, 20 Oct 2007 11:51:50 +0000 (11:51 +0000)
committerRon Koenderink <rkoenderink@yahoo.ca>
Sat, 20 Oct 2007 11:51:50 +0000 (11:51 +0000)
It has been seen which caused an update to be missed.

src/lib/empthread/ntthread.c

index 4f736949ed3f755b57c89b0d6eddb39036a7a8b0..5c6dbe71484495976523d7409fe05be81fe800bf 100644 (file)
@@ -63,6 +63,7 @@
 #include "misc.h"
 #include "empthread.h"
 #include "prototypes.h"
+#include "server.h"
 
 #define loc_MIN_THREAD_STACK  16384
 
@@ -325,8 +326,6 @@ loc_Exit_Handler(DWORD fdwCtrlType)
 static void
 empth_threadMain(void *pvData)
 {
-    time_t now;
-
     empth_t *pThread = pvData;
 
     /* Out of here... */
@@ -342,9 +341,14 @@ empth_threadMain(void *pvData)
     /* Signal that the thread has started. */
     SetEvent(hThreadStartEvent);
 
-    /* seed the rand() function */
-    time(&now);
-    srand(now ^ (unsigned)pThread);
+    /*
+     * seed the rand() function
+     * In WIN32, each thread has seed
+     */
+    if (rnd_seed.set)
+       srand(rnd_seed.seed);
+    else
+       srand(time(NULL) ^ (unsigned)pThread);
 
     /* Switch to this thread context */
     loc_RunThisThread(NULL);