From 11b84698222f6f4a511be157d85fa7039a7e9d33 Mon Sep 17 00:00:00 2001 From: Jeff Riegel Date: Tue, 5 Jun 2001 15:21:45 +0000 Subject: [PATCH] rx-race-condition-cleanup-by-adding-busy-status-20010605 set a busy status on a connection to prevent it from being deleted while in use --- src/rx/rx.c | 10 +++++++--- src/rx/rx.h | 1 + 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/rx/rx.c b/src/rx/rx.c index 43fa1665c..8f96aa00c 100644 --- a/src/rx/rx.c +++ b/src/rx/rx.c @@ -863,7 +863,7 @@ static void rxi_DestroyConnectionNoLock(conn) MUTEX_EXIT(&rx_stats_mutex); } - if (conn->refCount > 0) { + if ((conn->refCount > 0) || (conn->flags & RX_CONN_BUSY)) { /* Busy; wait till the last guy before proceeding */ MUTEX_EXIT(&conn->conn_data_lock); USERPRI; @@ -1763,6 +1763,7 @@ afs_int32 rx_EndCall(call, rc) MUTEX_ENTER(&conn->conn_call_lock); MUTEX_ENTER(&call->lock); MUTEX_ENTER(&conn->conn_data_lock); + conn->flags |= RX_CONN_BUSY; if (conn->flags & RX_CONN_MAKECALL_WAITING) { conn->flags &= (~RX_CONN_MAKECALL_WAITING); MUTEX_EXIT(&conn->conn_data_lock); @@ -1801,8 +1802,10 @@ afs_int32 rx_EndCall(call, rc) CALL_RELE(call, RX_CALL_REFCOUNT_BEGIN); MUTEX_EXIT(&call->lock); - if (conn->type == RX_CLIENT_CONNECTION) + if (conn->type == RX_CLIENT_CONNECTION) { MUTEX_EXIT(&conn->conn_call_lock); + conn->flags &= ~RX_CONN_BUSY; + } AFS_RXGUNLOCK(); USERPRI; /* @@ -6600,7 +6603,8 @@ static int rxi_AddRpcStat( * queue. */ - if ((rpc_stat == NULL) || + if (queue_IsEnd(stats, rpc_stat) || + (rpc_stat == NULL) || (rpc_stat->stats[0].interfaceId != rxInterface) || (rpc_stat->stats[0].remote_is_server != isServer)) { int i; diff --git a/src/rx/rx.h b/src/rx/rx.h index 7820cb068..03be43d02 100644 --- a/src/rx/rx.h +++ b/src/rx/rx.h @@ -481,6 +481,7 @@ struct rx_connection { #define RX_CONN_USING_PACKET_CKSUM 4 /* non-zero header.spare field seen */ #define RX_CONN_KNOW_WINDOW 8 /* window size negotiation works */ #define RX_CONN_RESET 16 /* connection is reset, remove */ +#define RX_CONN_BUSY 32 /* connection is busy; don't delete */ /* Type of connection, client or server */ #define RX_CLIENT_CONNECTION 0 -- 2.39.5