/*
Bacula® - The Network Backup Solution
- Copyright (C) 2002-2010 Free Software Foundation Europe e.V.
+ Copyright (C) 2002-2011 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.
{
AUTOCHANGER *changer_res = dcr->device->changer_res;
if (changer_res) {
+ int errstat;
Dmsg1(200, "Locking changer %s\n", changer_res->hdr.name);
- P(changer_res->changer_mutex); /* Lock changer script */
+ if ((errstat=rwl_writelock(&changer_res->changer_lock)) != 0) {
+ berrno be;
+ Jmsg(dcr->jcr, M_ERROR_TERM, 0, _("Lock failure on autochanger. ERR=%s\n"),
+ be.bstrerror(errstat));
+ }
}
}
{
AUTOCHANGER *changer_res = dcr->device->changer_res;
if (changer_res) {
+ int errstat;
Dmsg1(200, "Unlocking changer %s\n", changer_res->hdr.name);
- V(changer_res->changer_mutex); /* Unlock changer script */
+ if ((errstat=rwl_writeunlock(&changer_res->changer_lock)) != 0) {
+ berrno be;
+ Jmsg(dcr->jcr, M_ERROR_TERM, 0, _("Unlock failure on autochanger. ERR=%s\n"),
+ be.bstrerror(errstat));
+ }
}
}
return true;
}
+ lock_changer(dcr);
if (loaded < 0) {
loaded = get_autochanger_loaded_slot(dcr);
}
if (loaded > 0) {
POOL_MEM results(PM_MESSAGE);
POOLMEM *changer = get_pool_memory(PM_FNAME);
- lock_changer(dcr);
Jmsg(jcr, M_INFO, 0,
_("3307 Issuing autochanger \"unload slot %d, drive %d\" command.\n"),
loaded, dev->drive_index);
} else {
dev->set_slot(0); /* nothing loaded */
}
- unlock_changer(dcr);
free_volume(dev); /* Free any volume associated with this drive */
free_pool_memory(changer);
}
+ unlock_changer(dcr);
if (ok) {
dev->clear_unload();
}
if (res->res_changer.device) {
delete res->res_changer.device;
}
+ rwl_destroy(&res->res_changer.changer_lock);
break;
case R_STORAGE:
if (res->res_store.sdaddrs) {
foreach_alist(dev, res->res_changer.device) {
dev->changer_res = (AUTOCHANGER *)&res->res_changer;
}
- if ((errstat = pthread_mutex_init(&res->res_changer.changer_mutex, NULL)) != 0) {
+ if ((errstat = rwl_init(&res->res_changer.changer_lock)) != 0) {
berrno be;
- Jmsg1(NULL, M_ERROR_TERM, 0, _("Unable to init mutex: ERR=%s\n"),
+ Jmsg1(NULL, M_ERROR_TERM, 0, _("Unable to init lock: ERR=%s\n"),
be.bstrerror(errstat));
}
break;
/*
Bacula® - The Network Backup Solution
- Copyright (C) 2000-2009 Free Software Foundation Europe e.V.
+ Copyright (C) 2000-2011 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.
/*
* Resource codes -- they must be sequential for indexing
*
- * Version $Id$
*/
enum {
alist *device; /* List of DEVRES device pointers */
char *changer_name; /* Changer device name */
char *changer_command; /* Changer command -- external program */
- pthread_mutex_t changer_mutex; /* One changer operation at a time */
+ brwlock_t changer_lock; /* One changer operation at a time */
};
/* Device specific definitions */
/*
Bacula® - The Network Backup Solution
- Copyright (C) 2000-2009 Free Software Foundation Europe e.V.
+ Copyright (C) 2000-2011 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.
*
* Split from reserve.c October 2008
*
- * Version $Id: reserve.c 7380 2008-07-14 10:42:59Z kerns $
- *
*/
#include "bacula.h"
{
VOLRES *vol;
- if (dev->vol == NULL) {
+ lock_volumes();
+ vol = dev->vol;
+ if (vol == NULL) {
Dmsg1(dbglvl, "No vol on dev %s\n", dev->print_name());
+ unlock_volumes();
return false;
}
- lock_volumes();
- vol = dev->vol;
/* Don't free a volume while it is being swapped */
if (!vol->is_swapping()) {
Dmsg1(dbglvl, "=== clear in_use vol=%s\n", vol->vol_name);