Discussion:
winsup/cygwin ChangeLog exceptions.cc fhandler ...
Daniel Colascione
2011-12-18 00:03:26 UTC
Permalink
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.
http://sourceware.org/cgi-bin/cvsweb.cgi/winsup/cygwin/fhandler.cc.diff?cvsroot=uberbaum&r1=1.418&r2=1.419
+ /* 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 ());
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.
Christopher Faylor
2011-12-18 04:07:59 UTC
Permalink
Post by Daniel Colascione
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.
http://sourceware.org/cgi-bin/cvsweb.cgi/winsup/cygwin/fhandler.cc.diff?cvsroot=uberbaum&r1=1.418&r2=1.419
+ /* 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 ());
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.

cgf

Loading...