]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/src/lib/btimers.c
First cut of bat rerun a Job from Jobs Run
[bacula/bacula] / bacula / src / lib / btimers.c
index 4c44922f38234ee3feb42573595df4a83e70f5c5..0857b50965a072701f1966f64dac598bae2420c4 100644 (file)
@@ -6,7 +6,7 @@
    The main author of Bacula is Kern Sibbald, with contributions from
    many others, a complete list can be found in the file AUTHORS.
    This program is Free Software; you can redistribute it and/or
-   modify it under the terms of version two of the GNU General Public
+   modify it under the terms of version three of the GNU Affero General Public
    License as published by the Free Software Foundation and included
    in the file LICENSE.
 
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
    General Public License for more details.
 
-   You should have received a copy of the GNU General Public License
+   You should have received a copy of the GNU Affero General Public License
    along with this program; if not, write to the Free Software
    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.
@@ -35,6 +35,8 @@
 #include "bacula.h"
 #include "jcr.h"
 
+const int dbglvl = 900;
+
 /* Forward referenced functions */
 static void stop_btimer(btimer_t *wid);
 static btimer_t *btimer_start_common(uint32_t wait);
@@ -71,7 +73,7 @@ btimer_t *start_child_timer(JCR *jcr, pid_t pid, uint32_t wait)
    wid->wd->interval = wait;
    register_watchdog(wid->wd);
 
-   Dmsg3(900, "Start child timer %p, pid %d for %d secs.\n", wid, pid, wait);
+   Dmsg3(dbglvl, "Start child timer %p, pid %d for %d secs.\n", wid, pid, wait);
    return wid;
 }
 
@@ -81,10 +83,10 @@ btimer_t *start_child_timer(JCR *jcr, pid_t pid, uint32_t wait)
 void stop_child_timer(btimer_t *wid)
 {
    if (wid == NULL) {
-      Dmsg0(900, "stop_child_timer called with NULL btimer_id\n");
+      Dmsg0(dbglvl, "stop_child_timer called with NULL btimer_id\n");
       return;
    }
-   Dmsg2(900, "Stop child timer %p pid %d\n", wid, wid->pid);
+   Dmsg2(dbglvl, "Stop child timer %p pid %d\n", wid, wid->pid);
    stop_btimer(wid);
 }
 
@@ -105,7 +107,7 @@ static void callback_child_timer(watchdog_t *self)
       /* First kill attempt; try killing it softly (kill -SONG) first */
       wid->killed = true;
 
-      Dmsg2(050, "watchdog %p term PID %d\n", self, wid->pid);
+      Dmsg2(dbglvl, "watchdog %p term PID %d\n", self, wid->pid);
 
       /* Kill -TERM the specified PID, and reschedule a -KILL for 5 seconds
        * later. (Warning: this should let dvd-writepart enough time to term
@@ -116,7 +118,7 @@ static void callback_child_timer(watchdog_t *self)
       self->interval = 5;
    } else {
       /* This is the second call - terminate with prejudice. */
-      Dmsg2(050, "watchdog %p kill PID %d\n", self, wid->pid);
+      Dmsg2(dbglvl, "watchdog %p kill PID %d\n", self, wid->pid);
 
       kill(wid->pid, SIGKILL);
 
@@ -125,7 +127,6 @@ static void callback_child_timer(watchdog_t *self)
        */
       self->one_shot = true;
    }
-   Jmsg(wid->jcr, M_INFO, 0, _("Child timer expired. Child process killed.\n"));
 }
 
 /*
@@ -139,7 +140,7 @@ btimer_t *start_thread_timer(JCR *jcr, pthread_t tid, uint32_t wait)
    btimer_t *wid;
    wid = btimer_start_common(wait);
    if (wid == NULL) {
-      Dmsg1(900, "start_thread_timer return NULL from common. wait=%d.\n", wait);
+      Dmsg1(dbglvl, "start_thread_timer return NULL from common. wait=%d.\n", wait);
       return NULL;
    }
    wid->type = TYPE_PTHREAD;
@@ -151,7 +152,7 @@ btimer_t *start_thread_timer(JCR *jcr, pthread_t tid, uint32_t wait)
    wid->wd->interval = wait;
    register_watchdog(wid->wd);
 
-   Dmsg3(900, "Start thread timer %p tid %p for %d secs.\n", wid, tid, wait);
+   Dmsg3(dbglvl, "Start thread timer %p tid %p for %d secs.\n", wid, tid, wait);
 
    return wid;
 }
@@ -165,6 +166,9 @@ btimer_t *start_thread_timer(JCR *jcr, pthread_t tid, uint32_t wait)
 btimer_t *start_bsock_timer(BSOCK *bsock, uint32_t wait)
 {
    btimer_t *wid;
+   if (wait <= 0) {                 /* wait should be > 0 */
+      return NULL;
+   }
    wid = btimer_start_common(wait);
    if (wid == NULL) {
       return NULL;
@@ -179,7 +183,7 @@ btimer_t *start_bsock_timer(BSOCK *bsock, uint32_t wait)
    wid->wd->interval = wait;
    register_watchdog(wid->wd);
 
-   Dmsg4(950, "Start bsock timer %p tid=%p for %d secs at %d\n", wid,
+   Dmsg4(dbglvl, "Start bsock timer %p tid=%p for %d secs at %d\n", wid,
          wid->tid, wait, time(NULL));
 
    return wid;
@@ -194,7 +198,7 @@ void stop_bsock_timer(btimer_t *wid)
       Dmsg0(900, "stop_bsock_timer called with NULL btimer_id\n");
       return;
    }
-   Dmsg3(950, "Stop bsock timer %p tid=%p at %d.\n", wid, wid->tid, time(NULL));
+   Dmsg3(dbglvl, "Stop bsock timer %p tid=%p at %d.\n", wid, wid->tid, time(NULL));
    stop_btimer(wid);
 }
 
@@ -205,10 +209,10 @@ void stop_bsock_timer(btimer_t *wid)
 void stop_thread_timer(btimer_t *wid)
 {
    if (wid == NULL) {
-      Dmsg0(900, "stop_thread_timer called with NULL btimer_id\n");
+      Dmsg0(dbglvl, "stop_thread_timer called with NULL btimer_id\n");
       return;
    }
-   Dmsg2(900, "Stop thread timer %p tid=%p.\n", wid, wid->tid);
+   Dmsg2(dbglvl, "Stop thread timer %p tid=%p.\n", wid, wid->tid);
    stop_btimer(wid);
 }
 
@@ -225,14 +229,16 @@ static void callback_thread_timer(watchdog_t *self)
 {
    btimer_t *wid = (btimer_t *)self->data;
 
-   Dmsg4(50, "thread timer %p kill %s tid=%p at %d.\n", self,
+   Dmsg4(dbglvl, "thread timer %p kill %s tid=%p at %d.\n", self,
       wid->type == TYPE_BSOCK ? "bsock" : "thread", wid->tid, time(NULL));
+   if (wid->jcr) {
+      Dmsg2(dbglvl, "killed jid=%u Job=%s\n", wid->jcr->JobId, wid->jcr->Job);
+   }
 
    if (wid->type == TYPE_BSOCK && wid->bsock) {
       wid->bsock->set_timed_out();
    }
    pthread_kill(wid->tid, TIMEOUT_SIGNAL);
-   Jmsg(wid->jcr, M_INFO, 0, _("Thread timer expired. Thread interrupted.\n"));
 }
 
 static btimer_t *btimer_start_common(uint32_t wait)