return ok;
}
-static pthread_mutex_t acquire_lock = PTHREAD_MUTEX_INITIALIZER;
-
/*
* Acquire device for writing. We permit multiple writers.
* If this is the first one, we read the label.
init_device_wait_timers(dcr);
- P(acquire_lock); /* only one job at a time */
+ P(dev->acquire_mutex); /* only one job at a time */
dev->dlock();
Dmsg1(100, "acquire_append device is %s\n", dev->is_tape()?"tape":
(dev->is_dvd()?"DVD":"disk"));
get_out:
dcr->clear_reserved();
dev->dunlock();
- V(acquire_lock);
+ V(dev->acquire_mutex);
return ok ? dcr : NULL;
}
Mmsg1(dev->errmsg, _("Unable to init mutex: ERR=%s\n"), be.bstrerror(errstat));
Jmsg0(jcr, M_ERROR_TERM, 0, dev->errmsg);
}
+ if ((errstat = pthread_mutex_init(&dev->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;
int m_fd; /* file descriptor */
int m_blocked; /* set if we must wait (i.e. change tape) */
int m_count; /* Mutex use count -- DEBUG only */
+ int m_num_reserved; /* counter of device reservations */
+ int32_t m_slot; /* slot loaded in drive or -1 if none */
pthread_t m_pid; /* Thread that locked -- DEBUG only */
bool m_unload; /* set when Volume must be unloaded */
bool m_load; /* set when Volume must be loaded */
- int m_num_reserved; /* counter of device reservations */
- int32_t m_slot; /* slot loaded in drive or -1 if none */
public:
DEVICE * volatile swap_dev; /* Swap vol from this device */
dlist *attached_dcrs; /* attached DCR list */
pthread_mutex_t m_mutex; /* access control */
pthread_mutex_t spool_mutex; /* mutex for updating spool_size */
+ pthread_mutex_t acquire_mutex; /* mutex for acquire 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 */