]> git.michaelhowe.org Git - packages/o/openafs.git/commitdiff
DEVEL15-rx-mutex-init-once-20080903
authorJeffrey Altman <jaltman@secure-endpoints.com>
Wed, 3 Sep 2008 19:07:23 +0000 (19:07 +0000)
committerDerrick Brashear <shadow@dementia.org>
Wed, 3 Sep 2008 19:07:23 +0000 (19:07 +0000)
LICENSE IPL10
FIXES 114555

because rx_Finalize doesn't clean up, we end up reiniting mutexes. use
pthread_once when not in the kernel.
(kernel does not now call rx_Finalize, ever)

(cherry picked from commit 7f4e0dfc3ef1464c8d8b422bf00915fa4538090c)

src/rx/rx.c

index 7dbca402716f96286ee7e01ff31875697a4e25ee..36b17061f69541777abcf4c8bc204e7f0f7eddb6 100644 (file)
@@ -172,6 +172,7 @@ extern pthread_cond_t rx_listener_cond;
 static pthread_mutex_t epoch_mutex;
 static pthread_mutex_t rx_init_mutex;
 static pthread_mutex_t rx_debug_mutex;
+static pthread_mutex_t rx_rpc_stats;
 
 static void
 rxi_InitPthread(void)
@@ -217,6 +218,25 @@ rxi_InitPthread(void)
     assert(pthread_key_create(&rx_ts_info_key, NULL) == 0);
  
     rxkad_global_stats_init();
+
+    MUTEX_INIT(&rx_rpc_stats, "rx_rpc_stats", MUTEX_DEFAULT, 0);
+    MUTEX_INIT(&rx_freePktQ_lock, "rx_freePktQ_lock", MUTEX_DEFAULT, 0);
+#ifdef RX_ENABLE_LOCKS
+#ifdef RX_LOCKS_DB
+    rxdb_init();
+#endif /* RX_LOCKS_DB */
+    MUTEX_INIT(&freeSQEList_lock, "freeSQEList lock", MUTEX_DEFAULT, 0);
+    MUTEX_INIT(&rx_freeCallQueue_lock, "rx_freeCallQueue_lock", MUTEX_DEFAULT,
+              0);
+    CV_INIT(&rx_waitingForPackets_cv, "rx_waitingForPackets_cv", CV_DEFAULT,
+           0);
+    MUTEX_INIT(&rx_peerHashTable_lock, "rx_peerHashTable_lock", MUTEX_DEFAULT,
+              0);
+    MUTEX_INIT(&rx_connHashTable_lock, "rx_connHashTable_lock", MUTEX_DEFAULT,
+              0);
+    MUTEX_INIT(&rx_serverPool_lock, "rx_serverPool_lock", MUTEX_DEFAULT, 0);
+    MUTEX_INIT(&rxi_keyCreate_lock, "rxi_keyCreate_lock", MUTEX_DEFAULT, 0);
+#endif /* RX_ENABLE_LOCKS */
 }
 
 pthread_once_t rx_once_init = PTHREAD_ONCE_INIT;
@@ -264,7 +284,7 @@ assert(pthread_once(&rx_once_init, rxi_InitPthread)==0)
  * to manipulate the queue.
  */
 
-#ifdef RX_ENABLE_LOCKS
+#if defined(RX_ENABLE_LOCKS) && defined(KERNEL)
 static afs_kmutex_t rx_rpc_stats;
 void rxi_StartUnlocked();
 #endif
@@ -423,7 +443,7 @@ rx_InitHost(u_int host, u_int port)
        UNLOCK_RX_INIT;
        return RX_ADDRINUSE;
     }
-#ifdef RX_ENABLE_LOCKS
+#if defined(RX_ENABLE_LOCKS) && defined(KERNEL)
 #ifdef RX_LOCKS_DB
     rxdb_init();
 #endif /* RX_LOCKS_DB */
@@ -440,14 +460,11 @@ rx_InitHost(u_int host, u_int port)
     MUTEX_INIT(&rx_connHashTable_lock, "rx_connHashTable_lock", MUTEX_DEFAULT,
               0);
     MUTEX_INIT(&rx_serverPool_lock, "rx_serverPool_lock", MUTEX_DEFAULT, 0);
-#ifndef KERNEL
-    MUTEX_INIT(&rxi_keyCreate_lock, "rxi_keyCreate_lock", MUTEX_DEFAULT, 0);
-#endif /* !KERNEL */
-#if defined(KERNEL) && defined(AFS_HPUX110_ENV)
+#if defined(AFS_HPUX110_ENV)
     if (!uniprocessor)
        rx_sleepLock = alloc_spinlock(LAST_HELD_ORDER - 10, "rx_sleepLock");
-#endif /* KERNEL && AFS_HPUX110_ENV */
-#endif /* RX_ENABLE_LOCKS */
+#endif /* AFS_HPUX110_ENV */
+#endif /* RX_ENABLE_LOCKS && KERNEL */
 
     rxi_nCalls = 0;
     rx_connDeadTime = 12;