diff options
author | Steve Nielsen <spn@enteract.com> | 1998-03-12 05:48:20 -0600 |
---|---|---|
committer | Gurusamy Sarathy <gsar@cpan.org> | 1998-03-12 19:50:20 +0000 |
commit | 401ef382596273d18ae12637e4c3df0e9ffcd72f (patch) | |
tree | 38d120539a20a4c8fb2862a5a9c05efa57b4d509 | |
parent | 6c21342d4ccc04f9aa02e7c99f17f479235eb293 (diff) | |
download | perl-401ef382596273d18ae12637e4c3df0e9ffcd72f.tar.gz |
[win32] set sockets to nonoverlapped mode for every thread
Message-Id: <35081FE4.965A484D@enteract.com>
Subject: [PATCH 5.004_62] win32: set sockopt on a per-thread basis
p4raw-id: //depot/win32/perl@808
-rw-r--r-- | win32/win32.h | 3 | ||||
-rw-r--r-- | win32/win32sck.c | 29 |
2 files changed, 30 insertions, 2 deletions
diff --git a/win32/win32.h b/win32/win32.h index 259ffdc71c..781c720ed0 100644 --- a/win32/win32.h +++ b/win32/win32.h @@ -229,6 +229,9 @@ struct thread_intern { char Wstrerror_buffer[512]; struct servent Wservent; char Wgetlogin_buffer[128]; +# ifdef USE_SOCKETS_AS_HANDLES + int Winit_socktype; +# endif # ifdef HAVE_DES_FCRYPT char Wcrypt_buffer[30]; # endif diff --git a/win32/win32sck.c b/win32/win32sck.c index 14d2e6a45f..b07d1f1918 100644 --- a/win32/win32sck.c +++ b/win32/win32sck.c @@ -32,11 +32,22 @@ # define TO_SOCKET(x) (x) #endif /* USE_SOCKETS_AS_HANDLES */ +#ifdef USE_THREADS #define StartSockets() \ STMT_START { \ if (!wsock_started) \ start_sockets(); \ + set_socktype(); \ + } STMT_END +#else +#define StartSockets() \ + STMT_START { \ + if (!wsock_started) { \ + start_sockets(); \ + set_socktype(); \ + } \ } STMT_END +#endif #define EndSockets() \ STMT_START { \ @@ -60,8 +71,10 @@ static struct servent* win32_savecopyservent(struct servent*d, #ifdef USE_THREADS #ifdef USE_DECLSPEC_THREAD __declspec(thread) struct servent myservent; +__declspec(thread) int init_socktype; #else #define myservent (thr->i.Wservent) +#define init_socktype (thr->i.Winit_socktype) #endif #else static struct servent myservent; @@ -75,7 +88,6 @@ start_sockets(void) unsigned short version; WSADATA retdata; int ret; - int iSockOpt = SO_SYNCHRONOUS_NONALERT; /* * initalize the winsock interface and insure that it is @@ -88,15 +100,28 @@ start_sockets(void) croak("Could not find version 1.1 of winsock dll\n"); /* atexit((void (*)(void)) EndSockets); */ + wsock_started = 1; +} +void +set_socktype(void) +{ #ifdef USE_SOCKETS_AS_HANDLES +#ifdef USE_THREADS + dTHR; + if(!init_socktype) { +#endif + int iSockOpt = SO_SYNCHRONOUS_NONALERT; /* * Enable the use of sockets as filehandles */ setsockopt(INVALID_SOCKET, SOL_SOCKET, SO_OPENTYPE, (char *)&iSockOpt, sizeof(iSockOpt)); +#ifdef USE_THREADS + init_socktype = 1; + } +#endif #endif /* USE_SOCKETS_AS_HANDLES */ - wsock_started = 1; } |