From 1cda132258b09d009064856dab1c36f3b9f19628 Mon Sep 17 00:00:00 2001 From: Christopher Faylor Date: Mon, 11 Oct 2004 02:21:31 +0000 Subject: * cygtls.h (exitsock): New element. (exitsock_sin): Ditto. * cygtls.cc (_cygtls::init_thread): Initialize exitsock to invalid handle. (_cygtls::call2): Close exitsock if it is valid. * select.cc (struct socketinf): Remove sin element. (start_thread_socket): Initialize one SOCK_DGRAM socket per thread instead of (apparently) expensive opening and closing of socket with each select call. (socket_cleanup): Send a byte to the exitsock socket as a way to potentially signal a waiting-for-socket thread to exit. * tlsoffsets.h: Regenerate. --- winsup/cygwin/cygtls.cc | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'winsup/cygwin/cygtls.cc') diff --git a/winsup/cygwin/cygtls.cc b/winsup/cygwin/cygtls.cc index a409fda04..4dcd5df8f 100644 --- a/winsup/cygwin/cygtls.cc +++ b/winsup/cygwin/cygtls.cc @@ -92,6 +92,10 @@ _cygtls::call2 (DWORD (*func) (void *, void *), void *arg, void *buf) _my_tls.init_thread (buf, func); DWORD res = func (arg, buf); _my_tls.remove (INFINITE); + // FIXME: Need some sort of atthreadexit function to allow things like + // select to control this themselves + if (_my_tls.locals.exitsock != INVALID_SOCKET) + closesocket (_my_tls.locals.exitsock); ExitThread (res); } @@ -114,6 +118,7 @@ _cygtls::init_thread (void *x, DWORD (*func) (void *, void *)) } local_clib._current_locale = "C"; locals.process_logmask = LOG_UPTO (LOG_DEBUG); + locals.exitsock = INVALID_SOCKET; } set_state (false); -- cgit v1.2.3