]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/src/stored/acquire.c
kes Move the checking of the database in initializion of the Director
[bacula/bacula] / bacula / src / stored / acquire.c
index 9fa9f79c9589f70aacc3b34fa6f1ca124a9c35eb..c1b791ee3d01e0025a0096d6b545a6a5fec50014 100644 (file)
@@ -1,14 +1,7 @@
-/*
- *  Routines to acquire and release a device for read/write
- *
- *   Kern Sibbald, August MMII
- *
- *   Version $Id$
- */
 /*
    Bacula® - The Network Backup Solution
 
-   Copyright (C) 2002-2006 Free Software Foundation Europe e.V.
+   Copyright (C) 2002-2007 Free Software Foundation Europe e.V.
 
    The main author of Bacula is Kern Sibbald, with contributions from
    many others, a complete list can be found in the file AUTHORS.
    (FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich,
    Switzerland, email:ftf@fsfeurope.org.
 */
+/*
+ *  Routines to acquire and release a device for read/write
+ *
+ *   Kern Sibbald, August MMII
+ *
+ *   Version $Id$
+ */
 
 #include "bacula.h"                   /* pull in global headers */
 #include "stored.h"                   /* pull in Storage Deamon headers */
@@ -281,13 +281,13 @@ default_path:
       dcr->VolumeName, dev->print_name());
 
 get_out:
-   P(dev->mutex);
+   dev->lock();
    if (dcr->reserved_device) {
       dev->reserved_device--;
       Dmsg2(100, "Dec reserve=%d dev=%s\n", dev->reserved_device, dev->print_name());
       dcr->reserved_device = false;
    }
-   V(dev->mutex);
+   dev->unlock();
    dev->unblock();
    Dmsg1(50, "jcr->dcr=%p\n", jcr->dcr);
    return ok;
@@ -406,13 +406,15 @@ DCR *acquire_device_for_append(DCR *dcr)
    if (jcr->NumWriteVolumes == 0) {
       jcr->NumWriteVolumes = 1;
    }
-   P(dev->mutex);
+   dev->VolCatInfo.VolCatJobs++;              /* increment number of jobs on vol */
+   dir_update_volume_info(dcr, false);        /* send Volume info to Director */
+   dev->lock();
    if (dcr->reserved_device) {
       dev->reserved_device--;
       Dmsg2(100, "Dec reserve=%d dev=%s\n", dev->reserved_device, dev->print_name());
       dcr->reserved_device = false;
    }
-   V(dev->mutex);
+   dev->unlock();
    dev->unblock();
    return dcr;
 
@@ -420,13 +422,13 @@ DCR *acquire_device_for_append(DCR *dcr)
  * Error return
  */
 get_out:
-   P(dev->mutex);
+   dev->lock();
    if (dcr->reserved_device) {
       dev->reserved_device--;
       Dmsg2(100, "Dec reserve=%d dev=%s\n", dev->reserved_device, dev->print_name());
       dcr->reserved_device = false;
    }
-   V(dev->mutex);
+   dev->unlock();
    dev->unblock();
    return NULL;
 }
@@ -461,8 +463,8 @@ bool release_device(DCR *dcr)
 
    if (dev->can_read()) {
       dev->clear_read();              /* clear read bit */
-
-      /******FIXME**** send read volume usage statistics to director */
+      Dmsg0(100, "dir_update_vol_info. Release0\n");
+      dir_update_volume_info(dcr, false); /* send Volume info to Director */
 
    } else if (dev->num_writers > 0) {
       /* 
@@ -486,7 +488,6 @@ bool release_device(DCR *dcr)
          }
          if (!dev->at_weot()) {
             dev->VolCatInfo.VolCatFiles = dev->file;   /* set number of files */
-            dev->VolCatInfo.VolCatJobs++;              /* increment number of jobs */
             /* Note! do volume update before close, which zaps VolCatInfo */
             Dmsg0(100, "dir_update_vol_info. Release0\n");
             dir_update_volume_info(dcr, false); /* send Volume info to Director */