Cygwin: AF_UNIX: make sure connect wait thread is cleanly interruptible

Using TerminateThread potentially leaks resources.  In our case,
the connect wait thread may be forcefully terminated after
having successfully opened a client side pipe handle.  If this
occurs, we have a stale pipe server instance, so the pipe will
never be closed as long as the process lives.

Avoid this by changing the npfs handle to non-blocking, so we can
wait on a termination event object from inside the thread itself
and cleanly exit from the thread instead of terminating.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
This commit is contained in:
Corinna Vinschen
2018-03-07 16:19:32 +01:00
parent 27a63d4ef2
commit cde2648c22
2 changed files with 49 additions and 8 deletions

View File

@ -860,6 +860,7 @@ class fhandler_socket_unix : public fhandler_socket
if the socket is backed by a file in the
file system (actually a reparse point) */
HANDLE connect_wait_thr;
HANDLE cwt_termination_evt;
PVOID cwt_param;
LONG so_error;
sun_name_t *sun_path;