rx-avoid-leaking-nwaiting-20030605
authorDerrick Brashear <shadow@dementia.org>
Thu, 5 Jun 2003 22:42:07 +0000 (22:42 +0000)
committerDerrick Brashear <shadow@dementia.org>
Thu, 5 Jun 2003 22:42:07 +0000 (22:42 +0000)
thanks to kolya@mit.edu for suggesting moving rather than adding the
decrement and confirming sanity.

basically if a call ended up call->error it was possible to queue_Remove()
it, drop the call, and not rx_nWaiting--; result should be observed as
rxdebug reporting waitprocs when threads were idle.

src/rx/rx.c

index 27f47c5..e2cdc41 100644 (file)
@@ -1466,6 +1466,13 @@ struct rx_call *rx_GetCall(int tno, struct rx_service *cur_service, osi_socket *
            MUTEX_EXIT(&rx_serverPool_lock);
            MUTEX_ENTER(&call->lock);
 
+           if (call->flags & RX_CALL_WAIT_PROC) {
+               call->flags &= ~RX_CALL_WAIT_PROC;
+               MUTEX_ENTER(&rx_stats_mutex);
+               rx_nWaiting--;
+               MUTEX_EXIT(&rx_stats_mutex);
+           }
+
            if (call->state != RX_STATE_PRECALL || call->error) {
                MUTEX_EXIT(&call->lock);
                MUTEX_ENTER(&rx_serverPool_lock);
@@ -1479,10 +1486,6 @@ struct rx_call *rx_GetCall(int tno, struct rx_service *cur_service, osi_socket *
                rxi_SendAck(call, 0, 0, RX_ACK_DELAY, 0);
 
            CLEAR_CALL_QUEUE_LOCK(call);
-           call->flags &= ~RX_CALL_WAIT_PROC;
-           MUTEX_ENTER(&rx_stats_mutex);
-           rx_nWaiting--;
-           MUTEX_EXIT(&rx_stats_mutex);
            break;
        }
        else {