rx-unrefd-peer-may-be-gcd-so-be-safe-20040919
authorDerrick Brashear <shadow@dementia.org>
Mon, 20 Sep 2004 03:07:22 +0000 (03:07 +0000)
committerDerrick Brashear <shadow@dementia.org>
Mon, 20 Sep 2004 03:07:22 +0000 (03:07 +0000)
this means we potentially "lose" some received bytes in the tracking,
but the alternative is to add and then drop a ref (which i suppose would be ok)

src/rx/rx_packet.c

index 298cf20..2185d43 100644 (file)
@@ -865,7 +865,11 @@ rxi_ReadPacket(int socket, register struct rx_packet *p, afs_uint32 * host,
             * never be cleaned up.
             */
            peer = rxi_FindPeer(*host, *port, 0, 0);
-           if (peer) {
+           /* Since this may not be associated with a connection,
+            * it may have no refCount, meaning we could race with
+            * ReapConnections
+            */
+           if (peer && (peer->refCount > 0)) {
                MUTEX_ENTER(&peer->peer_lock);
                hadd32(peer->bytesReceived, p->length);
                MUTEX_EXIT(&peer->peer_lock);