- dev->num_waiting--; /* no longer waiting */
- }
-}
-
-/*
- * Check if the device is blocked or not
- */
-int device_is_unmounted(DEVICE *dev)
-{
- int stat;
- P(dev->mutex);
- stat = (dev->dev_blocked == BST_UNMOUNTED) ||
- (dev->dev_blocked == BST_UNMOUNTED_WAITING_FOR_SYSOP);
- V(dev->mutex);
- return stat;
-}
-
-void _unlock_device(char *file, int line, DEVICE *dev)
-{
- Dmsg2(500, "unlock from %s:%d\n", file, line);
- V(dev->mutex);
-}
-
-/*
- * Block all other threads from using the device
- * Device must already be locked. After this call,
- * the device is blocked to any thread calling lock_device(),
- * but the device is not locked (i.e. no P on device). Also,
- * the current thread can do slip through the lock_device()
- * calls without blocking.
- */
-void _block_device(char *file, int line, DEVICE *dev, int state)
-{
- Dmsg3(500, "block set %d from %s:%d\n", state, file, line);
- ASSERT(dev->dev_blocked == BST_NOT_BLOCKED);
- dev->dev_blocked = state; /* make other threads wait */
- dev->no_wait_id = pthread_self(); /* allow us to continue */
-}
-
-
-
-/*
- * Unblock the device, and wake up anyone who went to sleep.
- */
-void _unblock_device(char *file, int line, DEVICE *dev)
-{
- Dmsg3(500, "unblock %d from %s:%d\n", dev->dev_blocked, file, line);
- ASSERT(dev->dev_blocked);
- dev->dev_blocked = BST_NOT_BLOCKED;
- dev->no_wait_id = 0;
- if (dev->num_waiting > 0) {
- pthread_cond_broadcast(&dev->wait); /* wake them up */