src/stored/lock.c
void _give_back_device_block(const char *file, int line,
                             DEVICE *dev, bsteal_lock_t *hold)
{
   Dmsg4(sd_dbglvl, "Return lock %s old=%s from %s:%d\n",
      dev->device->hdr.name, dev->print_blocked(), file, line);
   P(block_mutex);
   dev->set_blocked(hold->dev_blocked);
   dev->dev_prev_blocked = hold->dev_prev_blocked;
   dev->no_wait_id = hold->no_wait_id;
   dev->blocked_by = hold->blocked_by;
   Dmsg1(sd_dbglvl, "return lock. new=%s\n", dev->print_blocked());
   if (dev->num_waiting > 0) {
      pthread_cond_broadcast(&dev->wait); /* wake them up */
   }
   V(block_mutex);
}
/*
 * Enter with device blocked and locked by us
 * Exit with device locked, and blocked by previous owner
 */
Enter with device blocked and locked by us
Exit with device locked, and blocked by previous owner
Enter with device blocked and locked by us Exit with device locked and blocked by previous owner
void _give_back_device_block(const char *file, int line,
                             DEVICE *dev, bsteal_lock_t *hold)
{
   Dmsg4(sd_dbglvl, "Return lock %s old=%s from %s:%d\n",
      dev->device->hdr.name, dev->print_blocked(), file, line);
   P(block_mutex);
   dev->set_blocked(hold->dev_blocked);
   dev->dev_prev_blocked = hold->dev_prev_blocked;
   dev->no_wait_id = hold->no_wait_id;
   dev->blocked_by = hold->blocked_by;
   Dmsg1(sd_dbglvl, "return lock. new=%s\n", dev->print_blocked());
   if (dev->num_waiting > 0) {
      pthread_cond_broadcast(&dev->wait); 
   }
   V(block_mutex);
}
void _give_back_device_block ( const char * file , int line , DEVICE * dev , bsteal_lock_t * hold ) { Dmsg4 ( sd_dbglvl , " \n " , dev -> device -> hdr . name , dev -> print_blocked ( ) , file , line ) ; P ( block_mutex ) ; dev -> set_blocked ( hold -> dev_blocked ) ; dev -> dev_prev_blocked = hold -> dev_prev_blocked ; dev -> no_wait_id = hold -> no_wait_id ; dev -> blocked_by = hold -> blocked_by ; Dmsg1 ( sd_dbglvl , " \n " , dev -> print_blocked ( ) ) ; if ( dev -> num_waiting > 0 ) { pthread_cond_broadcast ( & dev -> wait ) ; } V ( block_mutex ) ; }
Enter with device blocked and locked by us
 Exit with device locked, and blocked by previous owner
Enter with device blocked and locked by us Exit with device locked and blocked by previous owner
/* wake them up */