]> git.sur5r.net Git - bacula/bacula/commitdiff
Mod bacula-dir.conf; fix VolUseDuration bug
authorKern Sibbald <kern@sibbald.com>
Mon, 20 Jan 2003 14:43:25 +0000 (14:43 +0000)
committerKern Sibbald <kern@sibbald.com>
Mon, 20 Jan 2003 14:43:25 +0000 (14:43 +0000)
git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@308 91ce42f0-d328-0410-95d8-f526ca767f89

bacula/kernstodo
bacula/src/dird/bacula-dir.conf.in
bacula/src/dird/catreq.c
bacula/src/lib/btime.c
bacula/src/lib/protos.h
bacula/src/lib/smartall.c
bacula/src/lib/watchdog.c
bacula/src/lib/watchdog.h
bacula/src/version.h

index 6ae30269ba6f538d8941c5ad91a2c27bd4fed068..301e9337911fa5b76ae5d46a0cbf144cd50c215e 100644 (file)
@@ -1,5 +1,5 @@
                  Kern's ToDo List
-                 17 January 2003 
+                 20 January 2003 
 
 Documentation to do: (a little bit at a time)
 - Document running a test version.
@@ -14,6 +14,8 @@ Testing to do: (painful)
 - blocksize recognition code.
 
 For 1.29 release:
+- Look at handling <> in smtp doesn't work with exim.
+- InitVerify is getting pruned and it shouldn't
 - Priority job to go to top of list.
 - Implement Bar code handling
 - Why is catreq.c:111 Find vol called twice for a job?
index 3fefae2107098477d7fbffb02508de040145f4b8..6b3a98b0ee380f769a3fe2b04917b071cf5d0867 100644 (file)
@@ -34,6 +34,7 @@ Job {
   Storage = DLTDrive
   Messages = Standard
   Pool = Default
+  Write Bootstrap = "@working_dir@/NightlySave.bsr"
 }
 
 # Backup the catalog database (after the nightly save)
@@ -50,6 +51,7 @@ Job {
   RunBeforeJob = "@sysconfdir@/make_catalog_backup"
   # This deletes the copy of the catalog
   RunAfterJob  = "@sysconfdir@/delete_catalog_backup"
+  Write Bootstrap = "@working_dir@/BackupCatalog.bsr"
 }
 
 # Standard Restore template, to be changed by Console program
@@ -108,7 +110,6 @@ FileSet {
   }
 }
 
-
 # Client (File Services) to backup
 Client {
   Name = @hostname@-fd
@@ -116,8 +117,8 @@ Client {
   FDPort = @fd_port@
   Catalog = MyCatalog
   Password = "@fd_password@"          # password for FileDaemon
-  File Retention = 180d               # six months
-  Job Retention = 365d                # one year
+  File Retention = 30d                # 30 days
+  Job Retention = 180d                # six months
   AutoPrune = yes                     # Prune expired Jobs/Files
 }
 
@@ -178,6 +179,12 @@ Messages {
   mail = @job_email@ = all, !skipped            
   operator = @job_email@ = mount
   console = all, !skipped, !saved
+#
+# WARNING! the following will create a file that you must cycle from
+#          time to time as it will grow indefinitely. However, it will
+#          also keep all your messages if the scroll off the console.
+#
+  append = "@working_dir@/log" = all, !skipped
 }
     
 # Default pool definition
index 0b650da52d07dbecacab65027051a311055283cb..0a74a5b79a4f0bb5130d215437261a63882f950d 100644 (file)
@@ -92,15 +92,15 @@ void catalog_request(JCR *jcr, BSOCK *bs, char *msg)
 next_volume:
       strcpy(mr.VolStatus, "Append");  /* want only appendable volumes */
       ok = db_find_next_volume(jcr, jcr->db, index, &mr);  
-      Dmsg1(200, "catreq after find_next_vol ok=%d\n", ok);
+      Dmsg2(100, "catreq after find_next_vol ok=%d FW=%d\n", ok, mr.FirstWritten);
       if (!ok) {
         /* Well, try finding recycled tapes */
         ok = find_recycled_volume(jcr, &mr);
-         Dmsg1(100, "find_recycled_volume1 %d\n", ok);
+         Dmsg2(100, "find_recycled_volume1 %d FW=%d\n", ok, mr.FirstWritten);
         if (!ok) {
            prune_volumes(jcr);  
            ok = recycle_a_volume(jcr, &mr);
-            Dmsg1(100, "find_recycled_volume2 %d\n", ok);
+            Dmsg2(200, "find_recycled_volume2 %d FW=%d\n", ok, mr.FirstWritten);
            if (!ok) {
               /* See if we can create a new Volume */
               ok = newVolume(jcr, &mr);
@@ -108,7 +108,7 @@ next_volume:
         }
       }
       /* Check if use duration has expired */
-      Dmsg2(200, "VolJobs=%d FirstWritten=%d\n", mr.VolJobs, mr.FirstWritten);
+      Dmsg2(100, "VolJobs=%d FirstWritten=%d\n", mr.VolJobs, mr.FirstWritten);
       if (ok && mr.VolJobs > 0 && mr.VolUseDuration > 0 && 
            strcmp(mr.VolStatus, "Recycle") != 0) {
         utime_t now = time(NULL);
index efdfecc2d7cc5b9d6a631af37c06923fbcdd4785..5f78f2430c61b74135ed08b9799f55425ecea56d 100644 (file)
@@ -64,6 +64,7 @@ utime_t str_to_utime(char *str)
       return 0;
    }
    if (tm.tm_year >= 1900) {
+      tm.tm_year -= 1900;
    } else {
       return 0;
    }
index 2efa5524de1d178bf64d2a75411cb6f499c711cc..eca2d6c38558f77d51613957f5bbbad599e1549b 100644 (file)
@@ -156,5 +156,8 @@ POOLMEM     *edit_job_codes(void *jcr, char *omsg, char *imsg, char *to);
 /* watchdog.c */
 int start_watchdog(void);
 int stop_watchdog(void);
-void stop_child_timer(btimer_id wid);
 btimer_t *start_child_timer(pid_t pid, uint32_t wait);
+void stop_child_timer(btimer_id wid);
+btimer_id start_thread_timer(pthread_t tid, uint32_t wait);
+void stop_thread_timer(btimer_id wid);
+
index c7b81f177ccc242f3a779a1d2f667fee5786a022..1f876670c7cbf1065e9f9f19854f911537983d52 100644 (file)
@@ -107,6 +107,8 @@ static void *smalloc(char *fname, int lineno, unsigned int nbytes)
           buf[nbytes - 1] = (((long) buf) & 0xFF) ^ 0xC5;
           buf += HEAD_SIZE;  /* Increment to user data start */
           V(mutex);
+       } else {
+           Emsg0(M_ABORT, 0, _("Out of memory\n"));
        }
         Dmsg4(1150, "smalloc %d at %x from %s:%d\n", nbytes, buf, fname, lineno);
        return (void *)buf;
@@ -195,6 +197,8 @@ void *sm_malloc(char *fname, int lineno, unsigned int nbytes)
               "designer garbage" consisting of alternating bits.  */
 
           memset(buf, 0x55, (int) nbytes);
+       } else {
+           Emsg0(M_ABORT, 0, _("Out of memory\n"));
        }
        return buf;
 }
@@ -208,6 +212,8 @@ void *sm_calloc(char *fname, int lineno,
 
        if ((buf = smalloc(fname, lineno, nelem * elsize)) != NULL) {
           memset(buf, 0, (int) (nelem * elsize));
+       } else {
+           Emsg0(M_ABORT, 0, _("Out of memory\n"));
        }
        return buf;
 }
@@ -236,8 +242,9 @@ void *sm_realloc(char *fname, int lineno, void *ptr, unsigned int size)
           malloc().  SVID is silent  on  this,  but  many  C  libraries
           permit this.  */
 
-       if (ptr == NULL)
+       if (ptr == NULL) {
           return sm_malloc(fname, lineno, size);
+       }
 
        /* If the old and new sizes are the same, be a nice guy and just
           return the buffer passed in.  */
index 52ea23dc73add0665068f31a87afdcabe30abee9..a8272d23f6449d0647536dbc3a109b8ca0d628c1 100755 (executable)
@@ -39,12 +39,14 @@ time_t watchdog_time;                     /* this has granularity of SLEEP_TIME */
 
 /* Forward referenced functions */
 static void *btimer_thread(void *arg);
+static void stop_btimer(btimer_id wid);
+static btimer_id btimer_start_common(uint32_t wait);
 
 /* Static globals */
 static pthread_mutex_t mutex;
 static pthread_cond_t  timer;
 static int quit;
-static btimer_t *child_chain = NULL;
+static btimer_t *timer_chain = NULL;
 
 
 /*
@@ -193,20 +195,26 @@ static void *btimer_thread(void *arg)
       now = time(NULL);
 
       /* Walk child chain killing off any process overdue */
-      for (wid = child_chain; wid; wid=wid->next) {
+      for (wid = timer_chain; wid; wid=wid->next) {
         int killed = FALSE;
         /* First ask him politely to go away */
         if (!wid->killed && now > (wid->start_time + wid->wait)) {
 //          Dmsg1(000, "Watchdog sigterm pid=%d\n", wid->pid);
-           kill(wid->pid, SIGTERM);
-           killed = TRUE;
+           if (wid->type == TYPE_CHILD) {
+              kill(wid->pid, SIGTERM);
+              killed = TRUE;
+           } else {
+              pthread_kill(wid->tid, TIMEOUT_SIGNAL);
+              wid->killed = TRUE;
+           }
         }
-        /* If we asked somone to die, wait 3 seconds and slam him */
+        /* If we asked a child to die, wait 3 seconds and slam him */
         if (killed) {
            btimer_t *wid1;
            sleep(3);
-           for (wid1 = child_chain; wid1; wid1=wid1->next) {
-              if (!wid1->killed && now > (wid1->start_time + wid1->wait)) {
+           for (wid1 = timer_chain; wid1; wid1=wid1->next) {
+              if (wid->type == TYPE_CHILD &&
+                  !wid1->killed && now > (wid1->start_time + wid1->wait)) {
                  kill(wid1->pid, SIGKILL);
 //                Dmsg1(000, "Watchdog killed pid=%d\n", wid->pid);
                  wid1->killed = TRUE;
@@ -230,20 +238,44 @@ static void *btimer_thread(void *arg)
  *          NULL on failure
  */
 btimer_id start_child_timer(pid_t pid, uint32_t wait)
+{
+   btimer_t *wid;
+   wid = btimer_start_common(wait);
+   wid->pid = pid;
+   wid->type = TYPE_CHILD;
+   return wid;
+}
+
+/* 
+ * Start a timer on a thread. kill it after wait seconds.
+ *   NOTE!  Granularity is SLEEP_TIME (i.e. 30 seconds)
+ *
+ *  Returns: btimer_id (pointer to btimer_t struct) on success
+ *          NULL on failure
+ */
+btimer_id start_thread_timer(pthread_t tid, uint32_t wait)
+{
+   btimer_t *wid;
+   wid = btimer_start_common(wait);
+   wid->tid = tid;
+   wid->type = TYPE_PTHREAD;
+   return wid;
+}
+
+static btimer_id btimer_start_common(uint32_t wait)
 {
    btimer_id wid = (btimer_id)malloc(sizeof(btimer_t));
 
    P(mutex);
-   /* Chain it into child_chain as the first item */
+   /* Chain it into timer_chain as the first item */
    wid->prev = NULL;
-   wid->next = child_chain;
-   if (child_chain) {
-      child_chain->prev = wid;
+   wid->next = timer_chain;
+   if (timer_chain) {
+      timer_chain->prev = wid;
    }
-   child_chain = wid;
+   timer_chain = wid;
    wid->start_time = time(NULL);
    wid->wait = wait;
-   wid->pid = pid;
    wid->killed = FALSE;
    Dmsg2(200, "Start child timer 0x%x for %d secs.\n", wid, wait);
    V(mutex);
@@ -254,14 +286,31 @@ btimer_id start_child_timer(pid_t pid, uint32_t wait)
  * Stop child timer
  */
 void stop_child_timer(btimer_id wid)
+{
+   stop_btimer(wid);        
+}
+
+/*
+ * Stop thread timer
+ */
+void stop_thread_timer(btimer_id wid)
+{
+   stop_btimer(wid);        
+}
+
+
+/*
+ * Stop btimer
+ */
+static void stop_btimer(btimer_id wid)
 {
    if (wid == NULL) {
       Emsg0(M_ABORT, 0, _("NULL btimer_id.\n"));
    }
    P(mutex);
-   /* Remove wid from child_chain */
+   /* Remove wid from timer_chain */
    if (!wid->prev) {                 /* if no prev */
-      child_chain = wid->next;       /* set new head */
+      timer_chain = wid->next;       /* set new head */
    } else {
       wid->prev->next = wid->next;    /* update prev */
    }
@@ -269,6 +318,6 @@ void stop_child_timer(btimer_id wid)
       wid->next->prev = wid->prev;    /* unlink it */
    }
    V(mutex);
-   Dmsg2(200, "Stop child timer 0x%x for %d secs.\n", wid, wid->wait);
+   Dmsg2(200, "Stop timer 0x%x for %d secs.\n", wid, wid->wait);
    free(wid);
 }
index e921bdeafb85937cb96da6cd4ed388d9e5f56a4b..57f9d677b3b9e91f109e9a48f056c8f6212cd1c9 100644 (file)
 
  */
 
+#define TYPE_CHILD   1
+#define TYPE_PTHREAD 2
+
 typedef struct s_btimer_t {
    struct s_btimer_t *next;
    struct s_btimer_t *prev;
    time_t start_time;
    int32_t  wait;
-   pid_t pid;
+   pid_t pid;                         /* process id if TYPE_CHILD */
    int killed;
+   int type;
+   pthread_t tid;                     /* thread id if TYPE_PTHREAD */
 } btimer_t;
 
 #define btimer_id btimer_t *
index 7398b4a59dabdeaa6023f8f8892e38bfa7ff4e8f..fb1d7ebe23cadd5c23e163c0d9cd737cdee3c453 100644 (file)
@@ -1,8 +1,8 @@
 /* */
 #define VERSION "1.29"
 #define VSTRING "1"
-#define DATE    "18 January 2003"
-#define LSMDATE "18Jan03"
+#define DATE    "20 January 2003"
+#define LSMDATE "20Jan03"
 
 /* Debug flags */
 #define DEBUG 1