]> git.michaelhowe.org Git - packages/o/openafs.git/commitdiff
ubik: cleanup DB lock usage in SDISK_SendFile
authorMarc Dionne <marc.c.dionne@gmail.com>
Sat, 29 Jan 2011 17:48:02 +0000 (12:48 -0500)
committerStephan Wiesand <stephan.wiesand@desy.de>
Wed, 3 Apr 2013 17:39:23 +0000 (10:39 -0700)
Some failure paths can return from SDISK_SendFile with the
database lock still held.  Other failure paths will cause
setlabel to be called without holding the lock.

Rework the failure paths so we always release the DB lock before
returning, and always hold it when calling setlabel.

Reviewed-on: http://gerrit.openafs.org/4151
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Derrick Brashear <shadow@dementia.org>
(cherry picked from commit ad63745f357e377c613881fa3470b85d4d36fe36)

Change-Id: I99cb359f108f604be75f19250fb697eb95b81947
Reviewed-on: http://gerrit.openafs.org/9418
Reviewed-by: Derrick Brashear <shadow@your-file-system.com>
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Stephan Wiesand <stephan.wiesand@desy.de>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
src/ubik/remote.c

index 010dfbd23aeb5f9ad84383199e66f7b68ef6c812..75330a670f3eb00c235c9ee114985f36203b3258 100644 (file)
@@ -494,7 +494,10 @@ SDISK_SendFile(struct rx_call *rxcall, afs_int32 file,
 
     /* send the file back to the requester */
 
+    dbase = ubik_dbase;
+
     if ((code = ubik_CheckAuth(rxcall))) {
+       DBHOLD(dbase);
        goto failed;
     }
 
@@ -515,10 +518,10 @@ SDISK_SendFile(struct rx_call *rxcall, afs_int32 file,
     if (offset && offset != otherHost) {
        /* we *know* this is the wrong guy */
        code = USYNC;
+       DBHOLD(dbase);
        goto failed;
     }
 
-    dbase = ubik_dbase;
     DBHOLD(dbase);
 
     /* abort any active trans that may scribble over the database */
@@ -559,7 +562,6 @@ SDISK_SendFile(struct rx_call *rxcall, afs_int32 file,
 #endif
        code = rx_Read(rxcall, tbuffer, tlen);
        if (code != tlen) {
-           DBRELE(dbase);
            ubik_dprint("Rx-read length error=%d\n", code);
            code = BULK_ERROR;
            close(fd);
@@ -572,7 +574,6 @@ SDISK_SendFile(struct rx_call *rxcall, afs_int32 file,
        pass++;
 #endif
        if (code != tlen) {
-           DBRELE(dbase);
            ubik_dprint("write failed error=%d\n", code);
            code = UIOERROR;
            close(fd);
@@ -620,8 +621,8 @@ SDISK_SendFile(struct rx_call *rxcall, afs_int32 file,
 #else
     LWP_NoYieldSignal(&dbase->version);
 #endif
-    DBRELE(dbase);
-  failed:
+
+failed:
     if (code) {
 #ifndef OLD_URECOVERY
        unlink(pbuffer);
@@ -637,6 +638,7 @@ SDISK_SendFile(struct rx_call *rxcall, afs_int32 file,
     } else {
        ubik_print("Ubik: Synchronize database completed\n");
     }
+    DBRELE(dbase);
     return code;
 }