]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/src/lib/btimers.c
dhb Medialist : created context menu function and moved lines which create
[bacula/bacula] / bacula / src / lib / btimers.c
index a35e154656b1ec30b88395e0e3a607e54bb077ed..2001284f0e9cee0e73ff3ff53a8d35de824d5199 100644 (file)
@@ -1,28 +1,36 @@
 /*
- * Process and thread timer routines, built on top of watchdogs.
- * 
- *    Nic Bellamy <nic@bellamy.co.nz>, October 2004.
- *
-*/
-/*
-   Copyright (C) 2000-2004 Kern Sibbald and John Walker
+   Bacula® - The Network Backup Solution
 
-   This program is free software; you can redistribute it and/or
-   modify it under the terms of the GNU General Public License as
-   published by the Free Software Foundation; either version 2 of
-   the License, or (at your option) any later version.
+   Copyright (C) 2004-2007 Free Software Foundation Europe e.V.
 
-   This program is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   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
+   License as published by the Free Software Foundation plus additions
+   that are listed in the file LICENSE.
+
+   This program is distributed in the hope that it will be useful, but
+   WITHOUT ANY WARRANTY; without even the implied warranty of
    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 along with this program; if not, write to the Free
-   Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
-   MA 02111-1307, USA.
+   You should have received a copy of the GNU 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.
+   The licensor of Bacula is the Free Software Foundation Europe
+   (FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich,
+   Switzerland, email:ftf@fsfeurope.org.
+*/
+/*
+ * Process and thread timer routines, built on top of watchdogs.
+ *
+ *    Nic Bellamy <nic@bellamy.co.nz>, October 2004.
+ *
+*/
 
 #include "bacula.h"
 #include "jcr.h"
@@ -39,11 +47,11 @@ static void destructor_thread_timer(watchdog_t *self);
 static void destructor_child_timer(watchdog_t *self);
 #endif
 
-/* 
+/*
  * Start a timer on a child process of pid, kill it after wait seconds.
  *
  *  Returns: btimer_t *(pointer to btimer_t struct) on success
- *          NULL on failure
+ *           NULL on failure
  */
 btimer_t *start_child_timer(pid_t pid, uint32_t wait)
 {
@@ -62,7 +70,7 @@ btimer_t *start_child_timer(pid_t pid, uint32_t wait)
    wid->wd->interval = wait;
    register_watchdog(wid->wd);
 
-   Dmsg3(200, "Start child timer %p, pid %d for %d secs.\n", wid, pid, wait);
+   Dmsg3(900, "Start child timer %p, pid %d for %d secs.\n", wid, pid, wait);
    return wid;
 }
 
@@ -72,10 +80,10 @@ btimer_t *start_child_timer(pid_t pid, uint32_t wait)
 void stop_child_timer(btimer_t *wid)
 {
    if (wid == NULL) {
-      Dmsg0(200, "stop_child_timer called with NULL btimer_id\n");
+      Dmsg0(900, "stop_child_timer called with NULL btimer_id\n");
       return;
    }
-   Dmsg2(200, "Stop child timer %p pid %d\n", wid, wid->pid);
+   Dmsg2(900, "Stop child timer %p pid %d\n", wid, wid->pid);
    stop_btimer(wid);
 }
 
@@ -98,11 +106,13 @@ static void callback_child_timer(watchdog_t *self)
 
       Dmsg2(050, "watchdog %p term PID %d\n", self, wid->pid);
 
-      /* Kill -TERM the specified PID, and reschedule a -KILL for 3 seconds
-       * later.
+      /* Kill -TERM the specified PID, and reschedule a -KILL for 5 seconds
+       * later. (Warning: this should let dvd-writepart enough time to term
+       * and kill growisofs, which takes 3 seconds, so the interval must not
+       * be less than 5 seconds)
        */
       kill(wid->pid, SIGTERM);
-      self->interval = 3;
+      self->interval = 5;
    } else {
       /* This is the second call - terminate with prejudice. */
       Dmsg2(050, "watchdog %p kill PID %d\n", self, wid->pid);
@@ -116,18 +126,18 @@ static void callback_child_timer(watchdog_t *self)
    }
 }
 
-/* 
+/*
  * Start a timer on a thread. kill it after wait seconds.
  *
  *  Returns: btimer_t *(pointer to btimer_t struct) on success
- *          NULL on failure
+ *           NULL on failure
  */
 btimer_t *start_thread_timer(pthread_t tid, uint32_t wait)
 {
    btimer_t *wid;
    wid = btimer_start_common(wait);
    if (wid == NULL) {
-      Dmsg1(200, "start_thread_timer return NULL from common. wait=%d.\n", wait);
+      Dmsg1(900, "start_thread_timer return NULL from common. wait=%d.\n", wait);
       return NULL;
    }
    wid->type = TYPE_PTHREAD;
@@ -138,16 +148,16 @@ btimer_t *start_thread_timer(pthread_t tid, uint32_t wait)
    wid->wd->interval = wait;
    register_watchdog(wid->wd);
 
-   Dmsg3(200, "Start thread timer %p tid %p for %d secs.\n", wid, tid, wait);
+   Dmsg3(900, "Start thread timer %p tid %p for %d secs.\n", wid, tid, wait);
 
    return wid;
 }
 
-/* 
+/*
  * Start a timer on a BSOCK. kill it after wait seconds.
  *
  *  Returns: btimer_t *(pointer to btimer_t struct) on success
- *          NULL on failure
+ *           NULL on failure
  */
 btimer_t *start_bsock_timer(BSOCK *bsock, uint32_t wait)
 {
@@ -165,8 +175,8 @@ btimer_t *start_bsock_timer(BSOCK *bsock, uint32_t wait)
    wid->wd->interval = wait;
    register_watchdog(wid->wd);
 
-   Dmsg4(50, "Start bsock timer %p tid=%p for %d secs at %d\n", wid, 
-        wid->tid, wait, time(NULL));
+   Dmsg4(950, "Start bsock timer %p tid=%p for %d secs at %d\n", wid,
+         wid->tid, wait, time(NULL));
 
    return wid;
 }
@@ -177,10 +187,10 @@ btimer_t *start_bsock_timer(BSOCK *bsock, uint32_t wait)
 void stop_bsock_timer(btimer_t *wid)
 {
    if (wid == NULL) {
-      Dmsg0(200, "stop_bsock_timer called with NULL btimer_id\n");
+      Dmsg0(900, "stop_bsock_timer called with NULL btimer_id\n");
       return;
    }
-   Dmsg3(50, "Stop bsock timer %p tid=%p at %d.\n", wid, wid->tid, time(NULL));
+   Dmsg3(950, "Stop bsock timer %p tid=%p at %d.\n", wid, wid->tid, time(NULL));
    stop_btimer(wid);
 }
 
@@ -191,10 +201,10 @@ void stop_bsock_timer(btimer_t *wid)
 void stop_thread_timer(btimer_t *wid)
 {
    if (wid == NULL) {
-      Dmsg0(200, "stop_thread_timer called with NULL btimer_id\n");
+      Dmsg0(900, "stop_thread_timer called with NULL btimer_id\n");
       return;
    }
-   Dmsg2(200, "Stop thread timer %p tid=%p.\n", wid, wid->tid);
+   Dmsg2(900, "Stop thread timer %p tid=%p.\n", wid, wid->tid);
    stop_btimer(wid);
 }
 
@@ -211,7 +221,7 @@ 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(50, "thread timer %p kill %s tid=%p at %d.\n", self,
       wid->type == TYPE_BSOCK ? "bsock" : "thread", wid->tid, time(NULL));
 
    if (wid->type == TYPE_BSOCK && wid->bsock) {
@@ -241,7 +251,7 @@ static btimer_t *btimer_start_common(uint32_t wait)
 static void stop_btimer(btimer_t *wid)
 {
    if (wid == NULL) {
-      Emsg0(M_ABORT, 0, "stop_btimer called with NULL btimer_id\n");
+      Emsg0(M_ABORT, 0, _("stop_btimer called with NULL btimer_id\n"));
    }
    unregister_watchdog(wid->wd);
    free(wid->wd);