Fix Windows client's stdin read thread's error handling
stdin_read_thread() zeroed bounce_status on failure, effectifely
treating it like EOF. Fix by setting to -1.
It treated main thread termination like failure, and set bounce_error
to a bogus value. Can't happen, because the program terminates when
the main thread terminates, and the only user of bounce_error is the
main thread anyway. Regardless, handle the case by terminating,
because that's more obviously correct.
Broken in commit f082ef9f
, v4.3.11.
This commit is contained in:
parent
cf4cb6c907
commit
d0cf7a3119
1 changed files with 10 additions and 3 deletions
|
@ -136,12 +136,19 @@ static DWORD WINAPI
|
||||||
stdin_read_thread(LPVOID lpParam)
|
stdin_read_thread(LPVOID lpParam)
|
||||||
{
|
{
|
||||||
for (;;) {
|
for (;;) {
|
||||||
if (WaitForSingleObject(bounce_empty, INFINITE) != WAIT_OBJECT_0) {
|
switch (WaitForSingleObject(bounce_empty, INFINITE)) {
|
||||||
bounce_status = 0;
|
case WAIT_FAILED:
|
||||||
|
bounce_status = -1;
|
||||||
bounce_error = GetLastError();
|
bounce_error = GetLastError();
|
||||||
} else {
|
break;
|
||||||
|
case WAIT_OBJECT_0:
|
||||||
bounce_status = _read(0, bounce_buf, sizeof(bounce_buf));
|
bounce_status = _read(0, bounce_buf, sizeof(bounce_buf));
|
||||||
bounce_error = errno;
|
bounce_error = errno;
|
||||||
|
break;
|
||||||
|
case WAIT_ABANDONED:
|
||||||
|
return 0;
|
||||||
|
default:
|
||||||
|
assert(0);
|
||||||
}
|
}
|
||||||
SetEvent(bounce_full);
|
SetEvent(bounce_full);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue