darwin knet avoid rx socket during shutdown
authorDerrick Brashear <shadow@dementia.org>
Fri, 11 Sep 2009 05:59:08 +0000 (01:59 -0400)
committerDerrick Brashear <shadow|account-1000005@unknown>
Fri, 11 Sep 2009 15:05:28 +0000 (08:05 -0700)
theoretically a user thread can race us during shutdown and end up
panicing us if the soclose happens at the wrong time. if we're shutting down
just return. using afs_shuttingdown would have the side effect that we'd lose
the ability to add any graceful behavior.

Reviewed-on: http://gerrit.openafs.org/443
Reviewed-by: Derrick Brashear <shadow@dementia.org>
Tested-by: Derrick Brashear <shadow@dementia.org>

src/rx/DARWIN/rx_knet.c

index a556e16..6b85ef4 100644 (file)
@@ -45,6 +45,11 @@ osi_NetReceive(osi_socket so, struct sockaddr_in *addr, struct iovec *dvec,
 
     for (i = 0; i < nvecs; i++)
        iov[i] = dvec[i];
+
+    if ((afs_termState == AFSOP_STOP_RXK_LISTENER) ||
+       (afs_termState == AFSOP_STOP_COMPLETE))
+       return -1;
+
     if (haveGlock)
        AFS_GUNLOCK();
 #if defined(KERNEL_FUNNEL)
@@ -151,8 +156,13 @@ osi_NetSend(osi_socket so, struct sockaddr_in *addr, struct iovec *dvec,
 
     addr->sin_len = sizeof(struct sockaddr_in);
 
+    if ((afs_termState == AFSOP_STOP_RXK_LISTENER) ||
+       (afs_termState == AFSOP_STOP_COMPLETE))
+       return -1;
+
     if (haveGlock)
        AFS_GUNLOCK();
+
 #if defined(KERNEL_FUNNEL)
     thread_funnel_switch(KERNEL_FUNNEL, NETWORK_FUNNEL);
 #endif