win: cause uv_read_stop to immediately stop reading the stream

this implements locking around the blocking call to ReadFile to get
around a Windows kernel bug where a blocking ReadFile operation on a
stream can deadlock the thread. this allows uv_read_stop to immediately
cancel a pending IO operation, and allows uv_pipe_getsockname to
"pause" any pending read (from libuv) while it retrieves the
sockname information

if unsupported by the OS (pre-Vista), this reverts to the old
(e.g. deadlock-prone) behavior

ref. issue #1313
On 08/05/2014 02:35 AM, Jameson Nash wrote:
> In src/win/pipe.c:
> 
>>  
>>  /* Cleans up uv_pipe_t (server or connection) and all resources associated */
>>  /* with it. */
>>  void uv_pipe_cleanup(uv_loop_t* loop, uv_pipe_t* handle) {
>>    int i;
>>    HANDLE pipeHandle;
>> +  uv_mutex_t *m;
>> +
>> +  handle->flags &= ~UV_HANDLE_READING;
> 
> no, this makes sure that the |uv_pipe_readfile_pause| call below
> actually stops reading.
> 

Right.


-- 
Saúl Ibarra Corretgé
bettercallsaghul.com