]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/src/stored/reserve.c
Move bnet_despool() into class in bsock.c
[bacula/bacula] / bacula / src / stored / reserve.c
index eca2ea3d9b77a0fc974fc07f5c233d75f94e2788..866524fb50b38dc8b3169f0235b9644f948c604c 100644 (file)
@@ -1,3 +1,30 @@
+/*
+   Bacula® - The Network Backup Solution
+
+   Copyright (C) 2000-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.
+   This program is Free Software; you can redistribute it and/or
+   modify it under the terms of version two of the GNU General Public
+   License as published by the Free Software Foundation plus additions
+   that are listed in the file LICENSE.
+
+   This program is distributed in the hope that it will be useful, but
+   WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+   General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+   02110-1301, USA.
+
+   Bacula® is a registered trademark of John Walker.
+   The licensor of Bacula is the Free Software Foundation Europe
+   (FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich,
+   Switzerland, email:ftf@fsfeurope.org.
+*/
 /*
  *   Drive reservation functions for Storage Daemon
  *
@@ -8,20 +35,6 @@
  *   Version $Id$
  *
  */
-/*
-   Copyright (C) 2000-2006 Kern Sibbald
-
-   This program is free software; you can redistribute it and/or
-   modify it under the terms of the GNU General Public License
-   version 2 as amended with additional clauses defined in the
-   file LICENSE in the main source directory.
-
-   This program is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 
-   the file LICENSE for additional details.
-
- */
 
 #include "bacula.h"
 #include "stored.h"
@@ -295,7 +308,7 @@ void free_volume_list()
    }
    P(vol_list_lock);
    for (vol=(VOLRES *)vol_list->first(); vol; vol=(VOLRES *)vol_list->next(vol)) {
-      Dmsg3(000, "Unreleased Volume=%s dcr=0x%x dev=0x%x\n", vol->vol_name,
+      Dmsg3(100, "Unreleased Volume=%s dcr=0x%x dev=0x%x\n", vol->vol_name,
          vol->dcr, vol->dev);
    }
    delete vol_list;
@@ -389,7 +402,7 @@ static bool use_storage_cmd(JCR *jcr)
       store->append = append;
 
       /* Now get all devices */
-      while (bnet_recv(dir) >= 0) {
+      while (dir->recv() >= 0) {
          Dmsg1(100, "<dird device: %s", dir->msg);
          ok = sscanf(dir->msg, use_device, dev_name.c_str()) == 1;
          if (!ok) {
@@ -398,7 +411,7 @@ static bool use_storage_cmd(JCR *jcr)
          unbash_spaces(dev_name);
          store->device->append(bstrdup(dev_name.c_str()));
       }
-   }  while (ok && bnet_recv(dir) >= 0);
+   }  while (ok && dir->recv() >= 0);
 
 #ifdef DEVELOPER
    /* This loop is debug code and can be removed */
@@ -591,7 +604,6 @@ bool find_suitable_device_for_job(JCR *jcr, RCTX &rctx)
          break;
       }
    }
-
    return ok;
 }
 
@@ -767,7 +779,7 @@ static bool reserve_device_for_read(DCR *dcr)
 
    /* Get locks in correct order */
    unlock_reservations();
-   P(dev->mutex);
+   dev->lock();  
    lock_reservations();
 
    if (is_device_unmounted(dev)) {             
@@ -796,7 +808,7 @@ static bool reserve_device_for_read(DCR *dcr)
    dcr->reserved_device = true;
 
 bail_out:
-   V(dev->mutex);
+   dev->unlock();
    return ok;
 }
 
@@ -826,7 +838,7 @@ static bool reserve_device_for_append(DCR *dcr, RCTX &rctx)
 
    /* Get locks in correct order */
    unlock_reservations();
-   P(dev->mutex);
+   dev->lock();
    lock_reservations();
 
    /* If device is being read, we cannot write it */
@@ -862,7 +874,7 @@ static bool reserve_device_for_append(DCR *dcr, RCTX &rctx)
    ok = true;
 
 bail_out:
-   V(dev->mutex);
+   dev->unlock();
    return ok;
 }