/*
Bacula(R) - The Network Backup Solution
- Copyright (C) 2002-2011 Free Software Foundation Europe e.V.
+ Copyright (C) 2002-2012 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.
static void detach_dcr_from_dev(DCR *dcr);
static void set_dcr_from_vol(DCR *dcr, VOL_LIST *vol);
-
/*********************************************************************
* Acquire device for reading.
* The drive should have previously been reserved by calling
int vol_label_status;
int retry = 0;
+ P(dev->read_acquire_mutex);
Dmsg2(950, "dcr=%p dev=%p\n", dcr, dcr->dev);
Dmsg2(950, "MediaType dcr=%s dev=%s\n", dcr->media_type, dev->device->media_type);
dev->dblock(BST_DOING_ACQUIRE);
release_reserve_messages(jcr); /* release queued messages */
unlock_reservations();
- if (stat == 1) {
+ if (stat == 1) { /* found new device to use */
+ /*
+ * Switching devices, so acquire lock on new device,
+ * then release the old one.
+ */
+ P(dcr->dev->read_acquire_mutex);
+ V(dev->read_acquire_mutex);
dev = dcr->dev; /* get new device pointer */
dev->dblock(BST_DOING_ACQUIRE);
}
Dmsg2(950, "dcr=%p dev=%p\n", dcr, dcr->dev);
Dmsg2(950, "MediaType dcr=%s dev=%s\n", dcr->media_type, dev->device->media_type);
+ V(dev->read_acquire_mutex);
return ok;
}
/*
Bacula® - The Network Backup Solution
- Copyright (C) 2000-2010 Free Software Foundation Europe e.V.
+ Copyright (C) 2000-2012 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.
bthread_mutex_set_priority(&dev->m_mutex, PRIO_SD_DEV_ACCESS);
bthread_mutex_set_priority(&dev->spool_mutex, PRIO_SD_DEV_SPOOL);
bthread_mutex_set_priority(&dev->acquire_mutex, PRIO_SD_DEV_ACQUIRE);
+ if ((errstat = pthread_mutex_init(&dev->read_acquire_mutex, NULL)) != 0) {
+ berrno be;
+ dev->dev_errno = errstat;
+ Mmsg1(dev->errmsg, _("Unable to init mutex: ERR=%s\n"), be.bstrerror(errstat));
+ Jmsg0(jcr, M_ERROR_TERM, 0, dev->errmsg);
+ }
#ifdef xxx
if ((errstat = rwl_init(&dev->lock)) != 0) {
berrno be;
/*
Bacula® - The Network Backup Solution
- Copyright (C) 2000-2011 Free Software Foundation Europe e.V.
+ Copyright (C) 2000-2012 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.
bthread_mutex_t m_mutex; /* access control */
bthread_mutex_t spool_mutex; /* mutex for updating spool_size */
bthread_mutex_t acquire_mutex; /* mutex for acquire code */
+ pthread_mutex_t read_acquire_mutex; /* mutex for acquire read code */
pthread_cond_t wait; /* thread wait variable */
pthread_cond_t wait_next_vol; /* wait for tape to be mounted */
pthread_t no_wait_id; /* this thread must not wait */