]> git.michaelhowe.org Git - packages/o/openafs.git/commitdiff
rx-init-more-packets-20080529
authorJeffrey Altman <jaltman@secure-endpoints.com>
Thu, 29 May 2008 14:31:41 +0000 (14:31 +0000)
committerJeffrey Altman <jaltman@secure-endpoints.com>
Thu, 29 May 2008 14:31:41 +0000 (14:31 +0000)
LICENSE MIT

It is frequently the case that rx_getAllAddr() is called before
rx_Init() or rx_InitHost().  rx_getAllAddr() obtains the list of
interfaces by using rx_GetIFInfo() which in turn computes and
allocates the number of addition rx packets.  Unfortunately,
rxi_MorePackets() relies on the existence of an initialized mutex
and the mutex is not initialized (on Windows) until the rx_InitHost()
call.  Therefore, we must delay the rxi_MorePackets() call until
after rx_InitHost() if rx_getAllAddr() is called previously.

Failure to do so results in a panic.

src/rx/rx.c
src/rx/rx_user.c

index aa1524a174ad8db8489f79d12a1443611864598b..dc3817fb1901e57ba6ccdc7870eb561401386950 100644 (file)
@@ -358,7 +358,10 @@ rx_SetEpoch(afs_uint32 epoch)
  * by the kernel.  Whether this will ever overlap anything in
  * /etc/services is anybody's guess...  Returns 0 on success, -1 on
  * error. */
-static int rxinit_status = 1;
+#ifndef AFS_NT40_ENV
+static
+#endif
+int rxinit_status = 1;
 #ifdef AFS_PTHREAD_ENV
 /*
  * This mutex protects the following global variables:
index 133283681361a97191e6bbbbecb155e921e47d89..8c3568b5a6974b10d2e42ef27a97c665455a12d0 100644 (file)
@@ -323,15 +323,36 @@ rx_getAllAddr(afs_int32 * buffer, int maxSize)
 #endif
 
 #ifdef AFS_NT40_ENV
+extern int rxinit_status;
+void 
+rxi_InitMorePackets(void) {
+    int npackets, ncbufs;
+
+    ncbufs = (rx_maxJumboRecvSize - RX_FIRSTBUFFERSIZE);
+    if (ncbufs > 0) {
+        ncbufs = ncbufs / RX_CBUFFERSIZE;
+        npackets = rx_initSendWindow - 1;
+        rxi_MorePackets(npackets * (ncbufs + 1));
+    }
+}
 void
 rx_GetIFInfo(void)
 {
     u_int maxsize;
     u_int rxsize;
-    int npackets, ncbufs;
     afs_uint32 i;
 
     LOCK_IF_INIT;
+    if (Inited) {
+        if (Inited < 2 && rxinit_status == 0) {
+            /* We couldn't initialize more packets earlier.
+             * Do it now. */
+            rxi_InitMorePackets();
+            Inited = 2;
+        }
+        UNLOCK_IF_INIT;
+       return;
+    }
     Inited = 1;
     UNLOCK_IF_INIT;
 
@@ -353,12 +374,16 @@ rx_GetIFInfo(void)
 
     }
     UNLOCK_IF;
-    ncbufs = (rx_maxJumboRecvSize - RX_FIRSTBUFFERSIZE);
-    if (ncbufs > 0) {
-        ncbufs = ncbufs / RX_CBUFFERSIZE;
-        npackets = rx_initSendWindow - 1;
-        rxi_MorePackets(npackets * (ncbufs + 1));
-    }
+
+    /*
+     * If rxinit_status is still set, rx_InitHost() has yet to be called
+     * and we therefore do not have any mutex locks initialized.  As a
+     * result we cannot call rxi_MorePackets() without crashing.
+     */
+    if (rxinit_status)
+        return;
+
+    rxi_InitMorePackets();
 }
 #endif