Fix misuse of CreateThread() in Windows client

We use the C run-time, so we better use its _beginthread(), too.
CreateThread() can lead to deadlocks, at least with some versions of
the C run-time.  Broken in commit f082ef9f, v4.3.11.
This commit is contained in:
Markus Armbruster 2009-04-25 09:59:36 +02:00
parent d0cf7a3119
commit 20eb6afd15

View file

@ -43,6 +43,7 @@
#include <sys/select.h> #include <sys/select.h>
#include <unistd.h> #include <unistd.h>
#else #else
#include <process.h>
#include <io.h> #include <io.h>
#endif #endif
#include "linebuf.h" #include "linebuf.h"
@ -132,8 +133,8 @@ sigaction(int signal, struct sigaction *action, struct sigaction *oaction)
* WIN32 does not support select type function on console input * WIN32 does not support select type function on console input
* so the client uses a separate thread to read input * so the client uses a separate thread to read input
*/ */
static DWORD WINAPI static void
stdin_read_thread(LPVOID lpParam) stdin_read_thread(void *dummy)
{ {
for (;;) { for (;;) {
switch (WaitForSingleObject(bounce_empty, INFINITE)) { switch (WaitForSingleObject(bounce_empty, INFINITE)) {
@ -146,7 +147,7 @@ stdin_read_thread(LPVOID lpParam)
bounce_error = errno; bounce_error = errno;
break; break;
case WAIT_ABANDONED: case WAIT_ABANDONED:
return 0; return;
default: default:
assert(0); assert(0);
} }
@ -163,7 +164,7 @@ sysdep_stdin_init(void)
bounce_empty = CreateEvent(NULL, FALSE, TRUE, NULL); bounce_empty = CreateEvent(NULL, FALSE, TRUE, NULL);
bounce_full = CreateEvent(NULL, TRUE, FALSE, NULL); bounce_full = CreateEvent(NULL, TRUE, FALSE, NULL);
ctrl_c_event = CreateEvent(NULL, FALSE, FALSE, NULL); ctrl_c_event = CreateEvent(NULL, FALSE, FALSE, NULL);
CreateThread(NULL, 0, stdin_read_thread, NULL, 0, NULL); _beginthread(stdin_read_thread, 0, NULL);
} }
/* /*