From 1e0e5254cb68748f3e4def2153f2039a6080dd64 Mon Sep 17 00:00:00 2001 From: Jeffrey Altman Date: Mon, 3 Jul 2006 02:16:35 +0000 Subject: [PATCH] STABLE14-windows-library-cleanup-20060702 afs_winsockCleanup (cherry picked from commit 20b4f785b56ff604bab72d3b624aae74a9e5ae5d) --- src/libafsauthent/afsauthent.def | 2 ++ src/rx/rx.c | 4 ++++ src/rx/rx_pthread.c | 7 ++++++- src/shlibafsauthent/afsauthent.def | 2 ++ src/util/afsutil.h | 1 + src/util/winsock_nt.c | 11 +++++++++-- 6 files changed, 24 insertions(+), 3 deletions(-) diff --git a/src/libafsauthent/afsauthent.def b/src/libafsauthent/afsauthent.def index a822985923..e90d63dab2 100644 --- a/src/libafsauthent/afsauthent.def +++ b/src/libafsauthent/afsauthent.def @@ -84,3 +84,5 @@ EXPORTS DISK_function_names @83 DATA VOTE_function_names @84 DATA + rx_Finalize @85 + pr_End @86 diff --git a/src/rx/rx.c b/src/rx/rx.c index a03d38d897..27d9e97c82 100644 --- a/src/rx/rx.c +++ b/src/rx/rx.c @@ -2021,6 +2021,10 @@ rx_Finalize(void) } rxi_flushtrace(); +#ifdef AFS_NT40_ENV + afs_winsockCleanup(); +#endif + rxinit_status = 1; UNLOCK_RX_INIT; } diff --git a/src/rx/rx_pthread.c b/src/rx/rx_pthread.c index d67a691978..4e622d806a 100644 --- a/src/rx/rx_pthread.c +++ b/src/rx/rx_pthread.c @@ -87,7 +87,9 @@ rxi_Delay(int sec) void rxi_InitializeThreadSupport(void) { - listeners_started = 0; + /* listeners_started must only be reset if + * the listener thread terminates */ + /* listeners_started = 0; */ clock_GetTime(&rxi_clockNow); } @@ -322,6 +324,9 @@ rxi_StartListener(void) pthread_attr_t tattr; AFS_SIGSET_DECL; + if (listeners_started) + return; + if (pthread_attr_init(&tattr) != 0) { dpf (("Unable to create Rx event handling thread (pthread_attr_init)\n")); diff --git a/src/shlibafsauthent/afsauthent.def b/src/shlibafsauthent/afsauthent.def index 20fd1192d4..a7199c5019 100644 --- a/src/shlibafsauthent/afsauthent.def +++ b/src/shlibafsauthent/afsauthent.def @@ -84,3 +84,5 @@ EXPORTS DISK_function_names @83 DATA VOTE_function_names @84 DATA + rx_Finalize @85 + pr_End @86 diff --git a/src/util/afsutil.h b/src/util/afsutil.h index d70c6a2d15..60d0cf141d 100644 --- a/src/util/afsutil.h +++ b/src/util/afsutil.h @@ -90,6 +90,7 @@ afs_vsnprintf( /*@out@ */ char *p, size_t avail, const char *fmt, /* Initialize the windows sockets before calling networking routines. */ extern int afs_winsockInit(void); + extern void afs_winsockCleanup(void); struct timezone { int tz_minuteswest; /* of Greenwich */ diff --git a/src/util/winsock_nt.c b/src/util/winsock_nt.c index 5f95efaea8..e2e308b767 100644 --- a/src/util/winsock_nt.c +++ b/src/util/winsock_nt.c @@ -25,11 +25,11 @@ RCSID * * Returns 0 on success, -1 on error. */ +static int once = 1; + int afs_winsockInit(void) { - static int once = 1; - if (once) { int code; WSADATA data; @@ -48,6 +48,13 @@ afs_winsockInit(void) return 0; } +void +afs_winsockCleanup(void) +{ + WSACleanup(); + once = 0; +} + int afs_gettimeofday(struct timeval *tv, struct timezone *tz) {