]> git.michaelhowe.org Git - packages/o/openafs.git/commitdiff
rx-pthread-mutex-protects-threadcount-20090128
authorJeffrey Altman <jaltman@your-file-system.com>
Wed, 28 Jan 2009 21:34:33 +0000 (21:34 +0000)
committerDerrick Brashear <shadow|account-1000005@unknown>
Thu, 17 Dec 2009 06:28:35 +0000 (22:28 -0800)
LICENSE BSD

add protection of previously unprotected thread count variables
(cherry picked from commit 226cf894b65c62225785180dfeeed0ec1c1a160b)

Change-Id: Id0e6172ff64175323c7867c0156fabca753d7e97
Reviewed-on: http://gerrit.openafs.org/927
Reviewed-by: Derrick Brashear <shadow@dementia.org>
Tested-by: Derrick Brashear <shadow@dementia.org>
src/rx/rx.c

index 4a9a58cbca3e5ecf17ddcaceb785c2d896ea76e8..3007c8e146a4a6c4fd61e3ac8c818580cbdde9ba 100644 (file)
@@ -1562,27 +1562,32 @@ rx_GetCall(int tno, struct rx_service *cur_service, osi_socket * socketp)
                if (!QuotaOK(service)) {
                    continue;
                }
+               MUTEX_ENTER(&rx_pthread_mutex);
                if (tno == rxi_fcfs_thread_num
                    || !tcall->queue_item_header.next) {
+                   MUTEX_EXIT(&rx_pthread_mutex);
                    /* If we're the fcfs thread , then  we'll just use 
                     * this call. If we haven't been able to find an optimal 
                     * choice, and we're at the end of the list, then use a 
                     * 2d choice if one has been identified.  Otherwise... */
                    call = (choice2 ? choice2 : tcall);
                    service = call->conn->service;
-               } else if (!queue_IsEmpty(&tcall->rq)) {
-                   struct rx_packet *rp;
-                   rp = queue_First(&tcall->rq, rx_packet);
-                   if (rp->header.seq == 1) {
-                       if (!meltdown_1pkt
-                           || (rp->header.flags & RX_LAST_PACKET)) {
-                           call = tcall;
-                       } else if (rxi_2dchoice && !choice2
-                                  && !(tcall->flags & RX_CALL_CLEARED)
-                                  && (tcall->rprev > rxi_HardAckRate)) {
-                           choice2 = tcall;
-                       } else
-                           rxi_md2cnt++;
+               } else {
+                   MUTEX_EXIT(&rx_pthread_mutex);
+                   if (!queue_IsEmpty(&tcall->rq)) {
+                       struct rx_packet *rp;
+                       rp = queue_First(&tcall->rq, rx_packet);
+                       if (rp->header.seq == 1) {
+                           if (!meltdown_1pkt
+                               || (rp->header.flags & RX_LAST_PACKET)) {
+                               call = tcall;
+                           } else if (rxi_2dchoice && !choice2
+                                      && !(tcall->flags & RX_CALL_CLEARED)
+                                      && (tcall->rprev > rxi_HardAckRate)) {
+                               choice2 = tcall;
+                           } else
+                               rxi_md2cnt++;
+                       }
                    }
                }
                if (call) {
@@ -1730,27 +1735,32 @@ rx_GetCall(int tno, struct rx_service *cur_service, osi_socket * socketp)
        for (queue_Scan(&rx_incomingCallQueue, tcall, ncall, rx_call)) {
            service = tcall->conn->service;
            if (QuotaOK(service)) {
+               MUTEX_ENTER(&rx_pthread_mutex);
                if (tno == rxi_fcfs_thread_num
                    || !tcall->queue_item_header.next) {
+                   MUTEX_EXIT(&rx_pthread_mutex);
                    /* If we're the fcfs thread, then  we'll just use 
                     * this call. If we haven't been able to find an optimal 
                     * choice, and we're at the end of the list, then use a 
                     * 2d choice if one has been identified.  Otherwise... */
                    call = (choice2 ? choice2 : tcall);
                    service = call->conn->service;
-               } else if (!queue_IsEmpty(&tcall->rq)) {
-                   struct rx_packet *rp;
-                   rp = queue_First(&tcall->rq, rx_packet);
-                   if (rp->header.seq == 1
-                       && (!meltdown_1pkt
-                           || (rp->header.flags & RX_LAST_PACKET))) {
-                       call = tcall;
-                   } else if (rxi_2dchoice && !choice2
-                              && !(tcall->flags & RX_CALL_CLEARED)
-                              && (tcall->rprev > rxi_HardAckRate)) {
-                       choice2 = tcall;
-                   } else
-                       rxi_md2cnt++;
+               } else {
+                   MUTEX_EXIT(&rx_pthread_mutex);
+                   if (!queue_IsEmpty(&tcall->rq)) {
+                       struct rx_packet *rp;
+                       rp = queue_First(&tcall->rq, rx_packet);
+                       if (rp->header.seq == 1
+                           && (!meltdown_1pkt
+                               || (rp->header.flags & RX_LAST_PACKET))) {
+                           call = tcall;
+                       } else if (rxi_2dchoice && !choice2
+                                  && !(tcall->flags & RX_CALL_CLEARED)
+                                  && (tcall->rprev > rxi_HardAckRate)) {
+                           choice2 = tcall;
+                       } else
+                           rxi_md2cnt++;
+                   }
                }
            }
            if (call)