]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/src/stored/spool.c
Extend idea of Prefer Mounted Volumes to mean a volume about
[bacula/bacula] / bacula / src / stored / spool.c
index abcdb0a7b9270f5a47d427f66b535f13bfd5334f..bf57c08ad623c9ed2dabb9f1d1e0e6a60b0c6b75 100644 (file)
@@ -204,6 +204,10 @@ static bool close_data_spool_file(DCR *dcr)
 
 static const char *spool_name = "*spool*";
 
+/*
+ * NB! This routine locks the device, but if committing will
+ *     not unlock it. If not committing, it will be unlocked.
+ */
 static bool despool_data(DCR *dcr, bool commit)
 {
    DEVICE *rdev;
@@ -215,7 +219,8 @@ static bool despool_data(DCR *dcr, bool commit)
    char ec1[50];
 
    Dmsg0(100, "Despooling data\n");
-   /* Commit means that the job is done, so we commit, otherwise, we
+   /*
+    * Commit means that the job is done, so we commit, otherwise, we
     *  are despooling because of user spool size max or some error  
     *  (e.g. filesystem full).
     */
@@ -229,7 +234,7 @@ static bool despool_data(DCR *dcr, bool commit)
    }
    dcr->despool_wait = true;
    dcr->spooling = false;
-   lock_device(dcr->dev);
+   dcr->dev->r_dlock();
    dcr->despool_wait = false;
    dcr->despooling = true;
    dcr->dev_locked = true;
@@ -248,7 +253,7 @@ static bool despool_data(DCR *dcr, bool commit)
    rdev->max_block_size = dcr->dev->max_block_size;
    rdev->min_block_size = dcr->dev->min_block_size;
    rdev->device = dcr->dev->device;
-   rdcr = new_dcr(NULL, rdev);
+   rdcr = new_dcr(jcr, rdev);
    rdcr->spool_fd = dcr->spool_fd;
    rdcr->jcr = jcr;                   /* set a valid jcr */
    block = dcr->block;                /* save block */
@@ -325,7 +330,7 @@ static bool despool_data(DCR *dcr, bool commit)
    /* If doing a commit, leave the device locked -- unlocked in release_device() */
    if (!commit) {
       dcr->dev_locked = false;
-      unlock_device(dcr->dev);
+      dcr->dev->dunlock();
    }
    return ok;
 }