Skip to content

Commit

Permalink
win pipe: missing conditional check on uv_pipe_zero_readfile_thread_proc
Browse files Browse the repository at this point in the history
fixes a race condition where if uv_read_stop was called shortly after uv_read_start or a successful read and before the uv_pipe_zero_readfile_thread_proc thread started, that thread would call the blocking ReadFile call after the HANDLE_READING flag had already been cleared
  • Loading branch information
vtjnash committed Jul 16, 2015
1 parent abcbb0c commit bd8cf2a
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/win/pipe.c
Original file line number Diff line number Diff line change
Expand Up @@ -1089,6 +1089,7 @@ static DWORD WINAPI uv_pipe_zero_readfile_thread_proc(void* parameter) {
uv_mutex_unlock(m);
}
restart_readfile:
if (handle->flags & UV_HANDLE_READING) {
result = ReadFile(handle->handle,
&uv_zero_,
0,
Expand All @@ -1110,6 +1111,9 @@ static DWORD WINAPI uv_pipe_zero_readfile_thread_proc(void* parameter) {
}
}
}
} else {
result = 1; /* successfully aborted read before it even started */
}
if (hThread) {
assert(hThread == handle->readfile_thread);
/* mutex does not control clearing readfile_thread */
Expand Down

0 comments on commit bd8cf2a

Please sign in to comment.