]> git.sur5r.net Git - bacula/bacula/commitdiff
Flush daemon messages after each job
authorKern Sibbald <kern@sibbald.com>
Thu, 6 Feb 2003 17:48:37 +0000 (17:48 +0000)
committerKern Sibbald <kern@sibbald.com>
Thu, 6 Feb 2003 17:48:37 +0000 (17:48 +0000)
git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@339 91ce42f0-d328-0410-95d8-f526ca767f89

bacula/kernstodo
bacula/src/lib/jcr.c
bacula/src/lib/message.c

index 03b18a88f89ca990ec42a1d4da560249c17ddc74..5f8d1e5f32c711ae6d400e38280a0e30eca0a2c1 100644 (file)
@@ -1,5 +1,5 @@
                  Kern's ToDo List
-                 25 January 2003 
+                 05 February 2003 
 
 Documentation to do: (a little bit at a time)
 - Document running a test version.
@@ -45,10 +45,8 @@ For 1.30 release:
 - Need a verbose mode in restore, perhaps to bsr.
 - bscan without -v is too quiet -- perhaps show jobs.
 - Add code to reject whole blocks if not wanted on restore.
-- Implement multiple simultaneous file Volumes on a single device.
 - Start working on Base jobs.
 - Make sure the MaxVolFiles is fully implemented in SD
-- Flush all the daemon messages at the end of every job.
 - Check if both CatalogFiles and UseCatalog are set to SD.
 - Check if we can increase Bacula FD priorty in Win2000
 - Need return status on read_cb() from read_records(). Need multiple
@@ -833,4 +831,7 @@ Done: (see kernsdone for more)
 - Umasked 022 daemons
 - Fix restore of hard linked file.
 - Figure out how to allow multiple simultaneous file Volumes on a single device.
+- Implement multiple simultaneous file Volumes on a single device.
 - Cleanup db_update_media and db_update_pool
+- Flush all the daemon messages at the end of every job.
+
index 3fc2a5a4f98f31d1324768123b79cca0238652f6..8bbab3d52d427f68f4b5c7842d1425d538a22dbf 100755 (executable)
@@ -181,6 +181,10 @@ void free_jcr(JCR *jcr)
       jcr->daemon_free_jcr(jcr);      /* call daemon free routine */
    }
    free_common_jcr(jcr);
+
+   P(mutex);
+   close_msg(NULL);                  /* flush any daemon messages */
+   V(mutex);
    Dmsg0(200, "Exit free_jcr\n");
 }
 
index b64036bd76ed86ee96ad41ab3e5a77ee3603c420..d4caf14e03aaaa7cea97bbb9533cdc74d6251f7a 100755 (executable)
@@ -41,9 +41,9 @@ char my_name[20];                   /* daemon name is stored here */
 char *exepath = (char *)NULL;
 char *exename = (char *)NULL;
 int console_msg_pending = 0;
-char con_fname[1000];
-FILE *con_fd = NULL;
-brwlock_t con_lock; 
+char con_fname[500];                 /* Console filename */
+FILE *con_fd = NULL;                 /* Console file descriptor */
+brwlock_t con_lock;                  /* Console lock structure */
 
 #ifdef TRACE_FILE
 FILE *trace_fd = NULL;
@@ -161,7 +161,7 @@ init_msg(void *vjcr, MSGS *msg)
 
    /*
     * Walk down the message resource chain duplicating it
-    * for the current Job.   ****FIXME***** segfault on memcpy
+    * for the current Job.
     */
    for (d=msg->dest_chain; d; d=d->next) {
       dnew = (DEST *)malloc(sizeof(DEST));
@@ -184,6 +184,10 @@ init_msg(void *vjcr, MSGS *msg)
       jcr->jcr_msgs->dest_chain = temp_chain;
       memcpy(jcr->jcr_msgs->send_msg, msg->send_msg, sizeof(msg->send_msg));
    } else {
+      /* If we have default values, release them now */
+      if (daemon_msgs) {
+        free_msgs_res(daemon_msgs);
+      }
       daemon_msgs = (MSGS *)malloc(sizeof(MSGS));
       memset(daemon_msgs, 0, sizeof(MSGS));
       daemon_msgs->dest_chain = temp_chain;
@@ -200,7 +204,7 @@ void init_console_msg(char *wd)
 {
    int fd;
 
-   sprintf(con_fname, "%s/%s.conmsg", wd, my_name);
+   bsnprintf(con_fname, sizeof(con_fname), "%s/%s.conmsg", wd, my_name);
    fd = open(con_fname, O_CREAT|O_RDWR|O_BINARY, 0600);
    if (fd == -1) {
       Emsg2(M_ERROR_TERM, 0, _("Could not open console message file %s: ERR=%s\n"),
@@ -376,7 +380,6 @@ void close_msg(void *vjcr)
 
    if (jcr == NULL) {               /* NULL -> global chain */
       msgs = daemon_msgs;
-      daemon_msgs = NULL;
    } else {
       msgs = jcr->jcr_msgs;
       jcr->jcr_msgs = NULL;
@@ -457,8 +460,10 @@ rem_temp_file:
    }
    free_pool_memory(cmd);
    Dmsg0(150, "Done walking message chain.\n");
-   free_msgs_res(msgs);
-   msgs = NULL;
+   if (jcr) {
+      free_msgs_res(msgs);
+      msgs = NULL;
+   }
    Dmsg0(150, "===End close msg resource\n");
 }
 
@@ -469,6 +474,7 @@ void free_msgs_res(MSGS *msgs)
 {
    DEST *d, *old;
 
+   /* Walk down the message chain releasing allocated buffers */
    for (d=msgs->dest_chain; d; ) {
       if (d->where) {
         free(d->where);
@@ -481,7 +487,7 @@ void free_msgs_res(MSGS *msgs)
       free(old);                     /* free the destination item */
    }
    msgs->dest_chain = NULL;
-   free(msgs);
+   free(msgs);                       /* free the head */
 }
 
 
@@ -496,6 +502,7 @@ void term_msg()
 {
    Dmsg0(100, "Enter term_msg\n");
    close_msg(NULL);                  /* close global chain */
+   free_msgs_res(daemon_msgs);       /* free the resources */
    daemon_msgs = NULL;
    if (con_fd) {
       fflush(con_fd);