From e93b6dca2f593e479499122eedef1e65452aaaac Mon Sep 17 00:00:00 2001 From: Simon Wilkinson Date: Thu, 25 Oct 2012 11:27:33 +0100 Subject: [PATCH] rx: Don't double check conn->call We currently have call = conn->call[channel] if (call) { ... } else { call = conn->call[channel] if (call) { ... } } As we don't drop (or acquire) any locks between the first and the second check of call, there's no way that the result can be different from the first time we checked. So just get rid of the uneccessary code, and reindent the following block to match. Change-Id: If21a1d0af461fe0c0651e713dfb99a7c5f01cba4 Reviewed-on: http://gerrit.openafs.org/8290 Reviewed-by: Jeffrey Altman Tested-by: BuildBot Reviewed-by: Derrick Brashear --- src/rx/rx.c | 64 +++++++++++++++++++++++++---------------------------- 1 file changed, 30 insertions(+), 34 deletions(-) diff --git a/src/rx/rx.c b/src/rx/rx.c index e984eacaa..269d21580 100644 --- a/src/rx/rx.c +++ b/src/rx/rx.c @@ -3411,44 +3411,40 @@ rxi_ReceivePacket(struct rx_packet *np, osi_socket socket, currentCallNumber = conn->callNumber[channel]; MUTEX_EXIT(&conn->conn_call_lock); } else if (type == RX_SERVER_CONNECTION) { /* No call allocated */ - call = conn->call[channel]; - if (call) { - MUTEX_ENTER(&call->lock); - currentCallNumber = conn->callNumber[channel]; - MUTEX_EXIT(&conn->conn_call_lock); - } else { - call = rxi_NewCall(conn, channel); /* returns locked call */ - *call->callNumber = currentCallNumber = np->header.callNumber; - MUTEX_EXIT(&conn->conn_call_lock); + call = rxi_NewCall(conn, channel); /* returns locked call */ + *call->callNumber = currentCallNumber = np->header.callNumber; + MUTEX_EXIT(&conn->conn_call_lock); #ifdef RXDEBUG - if (np->header.callNumber == 0) - dpf(("RecPacket call 0 %d %s: %x.%u.%u.%u.%u.%u.%u flags %d, packet %"AFS_PTR_FMT" len %d\n", - np->header.serial, rx_packetTypes[np->header.type - 1], ntohl(conn->peer->host), ntohs(conn->peer->port), - np->header.serial, np->header.epoch, np->header.cid, np->header.callNumber, np->header.seq, - np->header.flags, np, np->length)); + if (np->header.callNumber == 0) + dpf(("RecPacket call 0 %d %s: %x.%u.%u.%u.%u.%u.%u flags %d, " + "packet %"AFS_PTR_FMT" len %d\n", + np->header.serial, rx_packetTypes[np->header.type - 1], + ntohl(conn->peer->host), ntohs(conn->peer->port), + np->header.serial, np->header.epoch, np->header.cid, + np->header.callNumber, np->header.seq, + np->header.flags, np, np->length)); #endif - call->state = RX_STATE_PRECALL; - clock_GetTime(&call->queueTime); - call->app.bytesSent = 0; - call->app.bytesRcvd = 0; - /* - * If the number of queued calls exceeds the overload - * threshold then abort this call. - */ - if ((rx_BusyThreshold > 0) && - (rx_atomic_read(&rx_nWaiting) > rx_BusyThreshold)) { - struct rx_packet *tp; + call->state = RX_STATE_PRECALL; + clock_GetTime(&call->queueTime); + call->app.bytesSent = 0; + call->app.bytesRcvd = 0; + /* + * If the number of queued calls exceeds the overload + * threshold then abort this call. + */ + if ((rx_BusyThreshold > 0) && + (rx_atomic_read(&rx_nWaiting) > rx_BusyThreshold)) { + struct rx_packet *tp; - rxi_CallError(call, rx_BusyError); - tp = rxi_SendCallAbort(call, np, 1, 0); - MUTEX_EXIT(&call->lock); - putConnection(conn); - if (rx_stats_active) - rx_atomic_inc(&rx_stats.nBusies); - return tp; - } - rxi_KeepAliveOn(call); + rxi_CallError(call, rx_BusyError); + tp = rxi_SendCallAbort(call, np, 1, 0); + MUTEX_EXIT(&call->lock); + putConnection(conn); + if (rx_stats_active) + rx_atomic_inc(&rx_stats.nBusies); + return tp; } + rxi_KeepAliveOn(call); } else { /* RX_CLIENT_CONNECTION and No call allocated */ /* This packet can't be for this call. If the new call address is * 0 then no call is running on this channel. If there is a call -- 2.39.5