Windows: Do not leak activeRPC count
authorJeffrey Altman <jaltman@your-file-system.com>
Tue, 3 Sep 2013 12:42:50 +0000 (08:42 -0400)
committerJeffrey Altman <jaltman@your-file-system.com>
Tue, 3 Sep 2013 19:20:38 +0000 (12:20 -0700)
If a callback race has been lost cm_MergeStatus is not executed.
In that case either the activeRPC count should not be incremented
or must be decremented to indicate that the current call has been
completed.

Change-Id: I417f72bbc482f6d207ed0c09770b1d8a53d078ff
Reviewed-on: http://gerrit.openafs.org/10218
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Jeffrey Altman <jaltman@your-file-system.com>

src/WINNT/afsd/cm_callback.c
src/WINNT/afsd/cm_vnodeops.c

index 644f845..3cbbb56 100644 (file)
@@ -1880,8 +1880,11 @@ long cm_GetCallback(cm_scache_t *scp, struct cm_user *userp,
         lock_ObtainWrite(&scp->rw);
         if (code == 0) {
             int lostRace = cm_EndCallbackGrantingCall(scp, &cbr, &callback, &volSync, 0);
-            if (!lostRace)
+           if (lostRace) {
+               InterlockedDecrement(&scp->activeRPCs);
+           } else {
                 code = cm_MergeStatus(NULL, scp, &afsStatus, &volSync, userp, reqp, 0);
+           }
         } else {
             cm_EndCallbackGrantingCall(NULL, &cbr, NULL, NULL, 0);
             InterlockedDecrement(&scp->activeRPCs);
index d204264..5a2bf67 100644 (file)
@@ -2639,9 +2639,10 @@ cm_TryBulkStatRPC(cm_scache_t *dscp, cm_bulkStat_t *bbp, cm_user_t *userp, cm_re
                                                           &bbp->callbacks[j],
                                                           &volSync,
                                                           CM_CALLBACK_MAINTAINCOUNT|CM_CALLBACK_BULKSTAT);
-                    InterlockedIncrement(&scp->activeRPCs);
-                    if (!lostRace)
+                   if (!lostRace) {
+                       InterlockedIncrement(&scp->activeRPCs);
                         code = cm_MergeStatus(dscp, scp, &bbp->stats[j], &volSync, userp, reqp, CM_MERGEFLAG_BULKSTAT);
+                   }
                     lock_ReleaseWrite(&scp->rw);
                 } else {
                     lock_ReleaseRead(&scp->rw);
@@ -3162,10 +3163,11 @@ long cm_Create(cm_scache_t *dscp, clientchar_t *cnamep, long flags, cm_attr_t *a
             if (!cm_HaveCallback(scp)) {
                 lostRace = cm_EndCallbackGrantingCall(scp, &cbReq,
                                                       &newFileCallback, &volSync, 0);
-                InterlockedIncrement(&scp->activeRPCs);
-                if (!lostRace)
+               if (!lostRace) {
+                   InterlockedIncrement(&scp->activeRPCs);
                     code = cm_MergeStatus( dscp, scp, &newFileStatus, &volSync,
                                            userp, reqp, 0);
+               }
                 didEnd = 1;
             }
             lock_ReleaseWrite(&scp->rw);
@@ -3353,10 +3355,11 @@ long cm_MakeDir(cm_scache_t *dscp, clientchar_t *cnamep, long flags, cm_attr_t *
             if (!cm_HaveCallback(scp)) {
                 lostRace = cm_EndCallbackGrantingCall(scp, &cbReq,
                                                       &newDirCallback, &volSync, 0);
-                InterlockedIncrement(&scp->activeRPCs);
-                if (!lostRace)
+               if (!lostRace) {
+                   InterlockedIncrement(&scp->activeRPCs);
                     code = cm_MergeStatus( dscp, scp, &newDirStatus, &volSync,
                                            userp, reqp, 0);
+               }
                 didEnd = 1;
             }
             lock_ReleaseWrite(&scp->rw);