]> git.sur5r.net Git - bacula/bacula/commitdiff
Small tweaks to locking code no substantial change
authorKern Sibbald <kern@sibbald.com>
Mon, 7 Dec 2009 17:18:03 +0000 (18:18 +0100)
committerKern Sibbald <kern@sibbald.com>
Tue, 8 Dec 2009 13:33:49 +0000 (14:33 +0100)
bacula/src/stored/acquire.c
bacula/src/stored/lock.c
bacula/src/stored/protos.h
bacula/src/stored/vol_mgr.c

index 70424402e033a272b30b491f1a93fee6fed709b3..dead10b0226d37e64f58210a04e4cc136037b3eb 100644 (file)
@@ -498,7 +498,6 @@ bool release_device(DCR *dcr)
    unlock_volumes();
    Dmsg3(100, "%d writers, %d reserve, dev=%s\n", dev->num_writers, dev->num_reserved(),
          dev->print_name());
-   debug_list_volumes("acquire:release_device()");
 
 
    /* If no writers, close if file or !CAP_ALWAYS_OPEN */
index aea4b6a2039a2d940ffc1390c01796d4037b1820..ecb2d0ac90cdfbbb7016ae6c2d1b5c52079e3a50 100644 (file)
@@ -55,12 +55,14 @@ const int dbglvl = 500;
  *  2. dlock()   simple mutex that locks the device structure. A dlock
  *               can be acquired while a device is blocked if it is not
  *               locked.      
- *  3. r_dlock   "recursive" dlock, when means that a dlock (mutex)
+ *  3. r_dlock(locked)  "recursive" dlock, when means that a dlock (mutex)
  *               will be acquired on the device if it is not blocked
  *               by some other thread. If the device was blocked by
  *               the current thread, it will acquire the lock.
  *               If some other thread has set a block on the device,
  *               this call will wait until the device is unblocked.
+ *               Can be called with locked true, which means the
+ *               dlock is already set
  *
  *  A lock is normally set when modifying the device structure.
  *  A r_lock is normally acquired when you want to block the device
@@ -88,9 +90,10 @@ const int dbglvl = 500;
  *   DEVICE::dlock()   does P(m_mutex)     (in dev.h)
  *   DEVICE::dunlock() does V(m_mutex)
  *
- *   DEVICE::r_dlock() allows locking the device when this thread
-                         already has the device blocked.
- *                    dlock()
+ *   DEVICE::r_dlock(locked) allows locking the device when this thread
+ *                     already has the device blocked.
+ *                    if (!locked)
+ *                       dlock()
  *                    if blocked and not same thread that locked
  *                       pthread_cond_wait
  *                    leaves device locked 
index 526d59fa1c6b7b1fe791cf54d4bff4c4899f7ef4..e28f1794dee0370434b8467d5d9174a0264b60d5 100644 (file)
@@ -282,7 +282,6 @@ void    create_volume_lists();
 void    free_volume_lists();
 void    list_volumes(void sendit(const char *msg, int len, void *sarg), void *arg);
 bool    is_volume_in_use(DCR *dcr);
-void    debug_list_volumes(const char *imsg);
 extern  int vol_list_lock_count;
 void    add_read_volume(JCR *jcr, const char *VolumeName);
 void    remove_read_volume(JCR *jcr, const char *VolumeName);
index 0d6b088912039a914e75408797eca835477e70d6..2836c82269ec52f2786af9ac7a8de528236007ff 100644 (file)
@@ -49,6 +49,7 @@ static pthread_mutex_t read_vol_lock = PTHREAD_MUTEX_INITIALIZER;
 /* Forward referenced functions */
 static void free_vol_item(VOLRES *vol);
 static VOLRES *new_vol_item(DCR *dcr, const char *VolumeName);
+static void debug_list_volumes(const char *imsg);
 
 /*
  * For append volumes the key is the VolumeName.
@@ -195,7 +196,7 @@ enum {
    debug_nolock = false
 };
 
-void debug_list_volumes(const char *imsg)
+static void debug_list_volumes(const char *imsg)
 {
    VOLRES *vol;
    POOL_MEM msg(PM_MESSAGE);