From 266be1d8c9765d22bff62e79c5d396bc2f54fea4 Mon Sep 17 00:00:00 2001 From: Christopher Faylor Date: Sat, 14 Apr 2001 22:11:03 +0000 Subject: * net.cc (cygwin_socket): Set SO_LINGER to small value so closed UNIX domain sockets will not stay around. * select.cc (socket_cleanup): Set SO_LINGER to small value so closed dummy sockets do not stay around. Use correct value for second argument to shutdown. --- winsup/cygwin/select.cc | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'winsup/cygwin/select.cc') diff --git a/winsup/cygwin/select.cc b/winsup/cygwin/select.cc index 683b93a5f..db59e5834 100644 --- a/winsup/cygwin/select.cc +++ b/winsup/cygwin/select.cc @@ -1329,6 +1329,11 @@ socket_cleanup (select_record *, select_stuff *stuff) { select_printf ("connection to si->exitsock %p", si->exitsock); SOCKET s = socket (AF_INET, SOCK_STREAM, 0); + + /* Set LINGER with 0 timeout for hard close */ + struct linger tmp = {1, 0}; /* On, 0 delay */ + (void) setsockopt (s, SOL_SOCKET, SO_LINGER, (char *)&tmp, sizeof(tmp)); + /* Connecting to si->exitsock will cause any executing select to wake up. When this happens then the exitsock condition will cause the thread to terminate. */ @@ -1338,12 +1343,12 @@ socket_cleanup (select_record *, select_stuff *stuff) select_printf ("connect failed"); /* FIXME: now what? */ } - shutdown (s, 2); + shutdown (s, SD_BOTH); closesocket (s); /* Wait for thread to go away */ WaitForSingleObject (si->thread, INFINITE); - shutdown (si->exitsock, 2); + shutdown (si->exitsock, SD_BOTH); closesocket (si->exitsock); CloseHandle (si->thread); stuff->device_specific[FHDEVN(FH_SOCKET)] = NULL; -- cgit v1.2.3