From: Derrick Brashear Date: Mon, 18 Oct 2004 04:09:24 +0000 (+0000) Subject: STABLE12-rx-peer-and-conn-refcounts-now-unsigned-int32-20041015 X-Git-Tag: openafs-stable-1_2_12~32 X-Git-Url: https://git.michaelhowe.org/gitweb/?a=commitdiff_plain;h=9b629dd1564de55d93e24782a46f82da24c5a585;p=packages%2Fo%2Fopenafs.git STABLE12-rx-peer-and-conn-refcounts-now-unsigned-int32-20041015 FIXES 15459 in an extreme case, the peer object refcount could wrap we should probably also log if wrapping is imminent (cherry picked from commit 85835f169cf47207795e00cbc2dae6fd77950f78) --- diff --git a/src/rx/rx.c b/src/rx/rx.c index 93cdb1a56..f0dda8430 100644 --- a/src/rx/rx.c +++ b/src/rx/rx.c @@ -796,15 +796,16 @@ void rxi_CleanupConnection(conn) * idle (refCount == 0) after rx_idlePeerTime (60 seconds) have passed. */ MUTEX_ENTER(&rx_peerHashTable_lock); - if (--conn->peer->refCount <= 0) { - conn->peer->idleWhen = clock_Sec(); - if (conn->peer->refCount < 0) { - conn->peer->refCount = 0; - MUTEX_ENTER(&rx_stats_mutex); - rxi_lowPeerRefCount ++; - MUTEX_EXIT(&rx_stats_mutex); - } + if (conn->peer->refCount < 2) { + conn->peer->idleWhen = clock_Sec(); + if (conn->peer->refCount < 1) { + conn->peer->refCount = 1; + MUTEX_ENTER(&rx_stats_mutex); + rxi_lowPeerRefCount++; + MUTEX_EXIT(&rx_stats_mutex); + } } + conn->peer->refCount--; MUTEX_EXIT(&rx_peerHashTable_lock); MUTEX_ENTER(&rx_stats_mutex); diff --git a/src/rx/rx.h b/src/rx/rx.h index 8cadf0b7c..4c6ff9d5a 100644 --- a/src/rx/rx.h +++ b/src/rx/rx.h @@ -411,7 +411,7 @@ struct rx_peer { /* For garbage collection */ afs_uint32 idleWhen; /* When the refcountwent to zero */ - short refCount; /* Reference count for this structure */ + afs_uint32 refCount; /* Reference count for this structure */ /* Congestion control parameters */ u_char burstSize; /* Reinitialization size for the burst parameter */ @@ -496,7 +496,7 @@ struct rx_connection { /* client-- to retransmit the challenge */ struct rx_service *service; /* used by servers only */ u_short serviceId; /* To stamp on requests (clients only) */ - u_short refCount; /* Reference count */ + afs_uint32 refCount; /* Reference count */ u_char flags; /* Defined below */ u_char type; /* Type of connection, defined below */ u_char secondsUntilPing; /* how often to ping for each active call */ @@ -619,7 +619,7 @@ struct rx_call { struct clock traceStart; /* time the call started running */ u_short MTU; /* size of packets currently sending */ #ifdef RX_ENABLE_LOCKS - short refCount; /* Used to keep calls from disappearring + u_short refCount; /* Used to keep calls from disappearring when we get them from a queue. */ #endif /* RX_ENABLE_LOCKS */ /* Call refcount modifiers */ @@ -633,7 +633,7 @@ struct rx_call { #define RX_CALL_REFCOUNT_ABORT 7 /* delayed abort */ #define RX_CALL_REFCOUNT_MAX 8 /* array size. */ #ifdef RX_REFCOUNT_CHECK - short refCDebug[RX_CALL_REFCOUNT_MAX]; + u_short refCDebug[RX_CALL_REFCOUNT_MAX]; #endif /* RX_REFCOUNT_CHECK */ int iovNBytes; /* byte count for current iovec */ int iovMax; /* number elements in current iovec */ @@ -921,7 +921,7 @@ struct rx_debugPeer { u_short port; u_short ifMTU; afs_uint32 idleWhen; - short refCount; + u_short refCount; u_char burstSize; u_char burst; struct clock burstWait;