winsup/cygwin ChangeLog fhandler ...

Christopher Faylor
Sun Dec 18 04:08:00 GMT 2011

On Sat, Dec 17, 2011 at 04:03:26PM -0800, Daniel Colascione wrote:
>On 12/16/11 11:01 PM, cgf wrote:
>> CVSROOT:	/cvs/uberbaum
>> Module name:	winsup
>> Changes by:	cgf[SNIP] 2011-12-17 07:01:21
>> 	(fhandler_base_overlapped::close): Cancel any ongoing I/O before closing.
>+      /* Cancelling seems to be necessary for cases where a reader is
>+	 still executing either in another thread or when a signal handler
>               ^^^^^^^^^        ^^^^^^^^^^^^^^^^^
>+	 performs a close.  */
>+      CancelIo (get_io_handle ());
>Are you sure you want to use CancelIo here? MSDN says this about the function:
>> Cancels all pending input and output (I/O) operations that are
>> issued by the calling thread for the specified file. The function
>         ^^^^^^^^^^^^^^^^^^^^^
>> does not cancel I/O operations that other threads issue for a file handle.
>  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>I think you want to call CancelIoEx here, passing NULL for its second parameter.
> CancelIoEx, however, is only available post-Vista, so I imagine you'd want to
>fall back to CancelIo for XP, accepting that you can't cancel IO from another
>thread, and that the mechanism will work only from a signal delivered to the
>thread doing the IO.

This was really intended to fix a problem with a close in a signal
handler so the thread comment was incorrect.  However, now that you
mention it, the previous code considered a close in another thread as an
EINTR, which is obviously wrong.


More information about the Cygwin-developers mailing list