/*
Bacula® - The Network Backup Solution
- Copyright (C) 2000-2007 Free Software Foundation Europe e.V.
+ Copyright (C) 2000-2008 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.
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
- Bacula® is a registered trademark of John Walker.
+ Bacula® is a registered trademark of Kern Sibbald.
The licensor of Bacula is the Free Software Foundation Europe
(FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich,
Switzerland, email:ftf@fsfeurope.org.
* 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()
+ * if blocked and not same thread that locked
+ * pthread_cond_wait
+ * leaves device locked
+ *
+ * DEVICE::r_dunlock() unlocks but does not unblock
+ * same as dunlock();
+ *
* DEVICE::dblock(why) does
* r_dlock(); (recursive device lock)
* block_device(this, why)
* unblock_device()
* dunlock()
*
- * DEVICE::r_dlock() does recursive locking
- * dlock()
- * if blocked and not same thread that locked
- * pthread_cond_wait
- * leaves device locked
- *
- * DEVICE::r_dunlock()
- * same as dunlock();
- *
* block_device() does (must be locked and not blocked at entry)
* set blocked status
* set our pid
if (this->blocked() && !pthread_equal(this->no_wait_id, pthread_self())) {
this->num_waiting++; /* indicate that I am waiting */
while (this->blocked()) {
+#ifndef HAVE_WIN32
+ /* thread id on Win32 may be a struct */
Dmsg3(sd_dbglvl, "r_dlock blked=%s no_wait=%p me=%p\n", this->print_blocked(),
this->no_wait_id, pthread_self());
+#endif
if ((stat = pthread_cond_wait(&this->wait, &m_mutex)) != 0) {
berrno be;
this->dunlock();
Dmsg3(sd_dbglvl, "unblock %s from %s:%d\n", dev->print_blocked(), file, line);
ASSERT(dev->blocked());
dev->set_blocked(BST_NOT_BLOCKED);
- dev->no_wait_id = 0;
+ clear_thread_id(dev->no_wait_id);
if (dev->num_waiting > 0) {
pthread_cond_broadcast(&dev->wait); /* wake them up */
}