]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/src/stored/wait.c
- Require 5 arguments to mtx-changer except list and slots
[bacula/bacula] / bacula / src / stored / wait.c
index ddd4aaf83273d6f468fa624beeb1147d18ad0476..28d081ba10eb82929c6f3ceca74076060dab361e 100644 (file)
@@ -13,7 +13,7 @@
 
    This program is free software; you can redistribute it and/or
    modify it under the terms of the GNU General Public License
-   version 2 as ammended with additional clauses defined in the
+   version 2 as amended with additional clauses defined in the
    file LICENSE in the main source directory.
 
    This program is distributed in the hope that it will be useful,
@@ -48,8 +48,8 @@ int wait_for_sysop(DCR *dcr)
    JCR *jcr = dcr->jcr;
 
    P(dev->mutex);
-   unmounted = (dev->dev_blocked == BST_UNMOUNTED) ||
-                (dev->dev_blocked == BST_UNMOUNTED_WAITING_FOR_SYSOP);
+   Dmsg1(100, "Enter blocked=%s\n", dev->print_blocked());
+   unmounted = is_device_unmounted(dev);
 
    dev->poll = false;
    /*
@@ -70,8 +70,9 @@ int wait_for_sysop(DCR *dcr)
    }
 
    if (!unmounted) {
+      Dmsg1(400, "blocked=%s\n", dev->print_blocked());
       dev->dev_prev_blocked = dev->dev_blocked;
-      dev->dev_blocked = BST_WAITING_FOR_SYSOP; /* indicate waiting for mount */
+      dev->set_blocked(BST_WAITING_FOR_SYSOP); /* indicate waiting for mount */
    }
 
    for ( ; !job_canceled(jcr); ) {
@@ -86,7 +87,8 @@ int wait_for_sysop(DCR *dcr)
       start = time(NULL);
       /* Wait required time */
       stat = pthread_cond_timedwait(&dev->wait_next_vol, &dev->mutex, &timeout);
-      Dmsg1(400, "Wokeup from sleep on device stat=%d\n", stat);
+      Dmsg2(400, "Wokeup from sleep on device stat=%d blocked=%s\n", stat,
+         dev->print_blocked());
 
       now = time(NULL);
       dev->rem_wait_sec -= (now - start);
@@ -109,8 +111,7 @@ int wait_for_sysop(DCR *dcr)
       /*
        * Check if user unmounted the device while we were waiting
        */
-      unmounted = (dev->dev_blocked == BST_UNMOUNTED) ||
-                   (dev->dev_blocked == BST_UNMOUNTED_WAITING_FOR_SYSOP);
+      unmounted = is_device_unmounted(dev);
 
       if (stat != ETIMEDOUT) {     /* we blocked the device */
          break;                    /* on error return */
@@ -122,14 +123,14 @@ int wait_for_sysop(DCR *dcr)
 
       if (!unmounted && dev->vol_poll_interval &&
           (now - first_start >= dev->vol_poll_interval)) {
-         Dmsg1(400, "In wait blocked=%s\n", edit_blocked_reason(dev));
+         Dmsg1(400, "In wait blocked=%s\n", dev->print_blocked());
          dev->poll = true;            /* returning a poll event */
          break;
       }
       /*
        * Check if user mounted the device while we were waiting
        */
-      if (dev->dev_blocked == BST_MOUNT) {   /* mount request ? */
+      if (dev->get_blocked() == BST_MOUNT) {   /* mount request ? */
          stat = 0;
          break;
       }
@@ -144,8 +145,10 @@ int wait_for_sysop(DCR *dcr)
    }
 
    if (!unmounted) {
-      dev->dev_blocked = dev->dev_prev_blocked;    /* restore entry state */
+      dev->set_blocked(dev->dev_prev_blocked);    /* restore entry state */
+      Dmsg1(400, "set %s\n", dev->print_blocked());
    }
+   Dmsg1(400, "Exit blocked=%s\n", dev->print_blocked());
    V(dev->mutex);
    return stat;
 }
@@ -172,7 +175,7 @@ bool wait_for_device(JCR *jcr, bool first)
    P(device_release_mutex);
 
    if (first) {
-      Jmsg(jcr, M_MOUNT, 0, _("Job %s waiting to obtain a device.\n"), jcr->Job);
+      Jmsg(jcr, M_MOUNT, 0, _("Job %s waiting to reserve a device.\n"), jcr->Job);
    }
 
    /*
@@ -229,7 +232,7 @@ bool wait_for_device(JCR *jcr, bool first)
          if (!double_jcr_wait_time(jcr)) {
             break;                 /* give up */
          }
-         Jmsg(jcr, M_MOUNT, 0, _("Job %s waiting to obtain a device.\n"), jcr->Job);
+         Jmsg(jcr, M_MOUNT, 0, _("Job %s waiting to reserve a device.\n"), jcr->Job);
       }
 
       add_wait = jcr->wait_sec - (now - start);