diff options
author | Christopher Faylor <me@cgf.cx> | 2001-04-14 22:11:03 +0000 |
---|---|---|
committer | Christopher Faylor <me@cgf.cx> | 2001-04-14 22:11:03 +0000 |
commit | 266be1d8c9765d22bff62e79c5d396bc2f54fea4 (patch) | |
tree | 83156f2351cc47a32d1d7fdc950bd9a6ad6d4cdc | |
parent | e6b98fc8d6539f40aa34ce4964ae40305a5a52ca (diff) | |
download | newlib-266be1d8c9765d22bff62e79c5d396bc2f54fea4.zip newlib-266be1d8c9765d22bff62e79c5d396bc2f54fea4.tar.gz newlib-266be1d8c9765d22bff62e79c5d396bc2f54fea4.tar.bz2 |
* 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.
-rw-r--r-- | winsup/cygwin/ChangeLog | 11 | ||||
-rw-r--r-- | winsup/cygwin/net.cc | 7 | ||||
-rw-r--r-- | winsup/cygwin/select.cc | 9 |
3 files changed, 24 insertions, 3 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index 19d1e3a..f7abb53 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,14 @@ +Sat Apr 14 18:04:35 2001 Christopher Faylor <cgf@cygnus.com> + + * net.cc (cygwin_socket): Set SO_LINGER to small value so closed UNIX + domain sockets will not stay around. + +Sat Apr 14 18:01:43 2001 Pierre A. Humblet <Pierre.Humblet@ieee.org> + + * 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. + Sat Apr 14 17:04:00 2001 Robert Collins <rbtcollins@hotmail.com> * thread.h (MTinterface): Add threadcount. diff --git a/winsup/cygwin/net.cc b/winsup/cygwin/net.cc index e089cd6..5365057 100644 --- a/winsup/cygwin/net.cc +++ b/winsup/cygwin/net.cc @@ -363,7 +363,12 @@ cygwin_socket (int af, int type, int protocol) if (af == AF_INET) name = (type == SOCK_STREAM ? "/dev/tcp" : "/dev/udp"); else - name = (type == SOCK_STREAM ? "/dev/streamsocket" : "/dev/dgsocket"); + { + name = (type == SOCK_STREAM ? "/dev/streamsocket" : "/dev/dgsocket"); + /* Set LINGER with 0 timeout for hard close */ + struct linger tmp = {1, 0}; /* On, 0 delay */ + (void) setsockopt (soc, SOL_SOCKET, SO_LINGER, (char *)&tmp, sizeof(tmp)); + } fdsock (fd, name, soc)->set_addr_family (af); res = fd; diff --git a/winsup/cygwin/select.cc b/winsup/cygwin/select.cc index 683b93a..db59e58 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; |