]> git.sur5r.net Git - bacula/bacula/commitdiff
Implement Qmsg() + conio linking
authorKern Sibbald <kern@sibbald.com>
Mon, 29 Mar 2004 22:04:03 +0000 (22:04 +0000)
committerKern Sibbald <kern@sibbald.com>
Mon, 29 Mar 2004 22:04:03 +0000 (22:04 +0000)
git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@1162 91ce42f0-d328-0410-95d8-f526ca767f89

12 files changed:
bacula/autoconf/configure.in
bacula/configure
bacula/kernstodo
bacula/src/console/conio.c
bacula/src/console/console.c
bacula/src/filed/win32/winabout.cpp
bacula/src/filed/win32/winabout.h
bacula/src/lib/bnet.c
bacula/src/lib/dlist.c
bacula/src/lib/jcr.c
bacula/src/lib/message.c
bacula/src/version.h

index 908b592f263ceb422e70311b08b2749a8943b0dc..0641dbb08ec74d1d1a68635e64581c3c20598012 100644 (file)
@@ -321,7 +321,17 @@ if test x$support_conio = xyes; then
         got_conio="yes"
         support_readline=no
         AC_DEFINE(HAVE_CONIO, 1, [Set if Bacula conio support enabled]) 
-       ], [ echo " "; echo "termcap library not found. CONIO turned off ..."; echo " "])
+       ],   
+       [ AC_CHECK_LIB(ncurses, tgetent,
+        [ CONS_LIBS="-lncurses"
+          CONS_OBJ="conio.o"
+          CONS_SRC="conio.c"
+          got_conio="yes"
+          support_readline=no
+          AC_DEFINE(HAVE_CONIO, 1, [Set if Bacula conio support enabled]) 
+        ],   
+        [ echo " "; echo "Neither termcap nor ncurses library found. CONIO turned off ..."; echo " "])
+       ])
     ],[echo " "; echo "termcap.h not found. CONIO turned off ..."; echo " "])
 fi
 
index dda4b004ae3102f5258c236914fcb8752911f820..b84fbf035eefac4bea97e467e3bd4cfbda82db35 100755 (executable)
@@ -5264,7 +5264,77 @@ _ACEOF
 
 
 else
-   echo " "; echo "termcap library not found. CONIO turned off ..."; echo " "
+   echo "$as_me:$LINENO: checking for tgetent in -lncurses" >&5
+echo $ECHO_N "checking for tgetent in -lncurses... $ECHO_C" >&6
+if test "${ac_cv_lib_ncurses_tgetent+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-lncurses  $LIBS"
+cat >conftest.$ac_ext <<_ACEOF
+#line $LINENO "configure"
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+
+/* Override any gcc2 internal prototype to avoid an error.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+/* We use char because int might match the return type of a gcc2
+   builtin and then its argument prototype would still apply.  */
+char tgetent ();
+int
+main ()
+{
+tgetent ();
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+         { ac_try='test -s conftest$ac_exeext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_cv_lib_ncurses_tgetent=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_cv_lib_ncurses_tgetent=no
+fi
+rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+echo "$as_me:$LINENO: result: $ac_cv_lib_ncurses_tgetent" >&5
+echo "${ECHO_T}$ac_cv_lib_ncurses_tgetent" >&6
+if test $ac_cv_lib_ncurses_tgetent = yes; then
+   CONS_LIBS="-lncurses"
+          CONS_OBJ="conio.o"
+          CONS_SRC="conio.c"
+          got_conio="yes"
+          support_readline=no
+
+cat >>confdefs.h <<\_ACEOF
+#define HAVE_CONIO 1
+_ACEOF
+
+
+else
+   echo " "; echo "Neither termcap nor ncurses library found. CONIO turned off ..."; echo " "
+fi
+
+
 fi
 
 
index b4cf9a08f8b56508f1c494607a0d773a289d5107..7e9fb02a8878adf14bb966375baaf848e07abfbb 100644 (file)
@@ -1,5 +1,5 @@
                  Kern's ToDo List
-                  25 March 2004
+                  28 March 2004
 
 Documentation to do: (any release a little bit at a time)
 - DB upgrade to version 5 in bacula-1.27b, DB upgrade to
@@ -72,6 +72,7 @@ For 1.33 Testing/Documentation:
    Overland Neo2000 (LVD)
 
 For 1.33
+- Null dlist head and tail pointers if all items are removed.
 - Complete Win32 installer
 - Finish work on Gnome restore GUI.
 - On unknown client in restore "client=xxx"
@@ -79,9 +80,6 @@ For 1.33
      ERR=no such table: temp1
 - Fix "llist jobid=xx" where no fileset or client exists.
 - Build console in client-only build.
-- Test Qmsg() code to be used in bnet.c to prevent recursion.  Queue the
-  message. If dequeueing toss the messages. Lock while dequeuing so that
-  it cannot be called recursively and set dequeuing flag.
 - Test work on conio.c -- particularly linking.
 - Phil says that Windows file sizes mismatch in Verify when they should,
   and that either the file size or the catalog size was zero.
@@ -1428,3 +1426,6 @@ Block Position: 0
 - Allow "delete job jobid=xx jobid=xxx".   
 - Update volume FromPool (or FromPool=xxx) refreshes the Volume defaults from Pool.
 - Implement multiple Volume in "purge jobs volume=".
+- Test Qmsg() code to be used in bnet.c to prevent recursion.  Queue the
+  message. If dequeueing toss the messages. Lock while dequeuing so that
+  it cannot be called recursively and set dequeuing flag.
index 7447ead95e44beaa45364eab00605c762aad0e5a..5b5cc57514f87226fed0edacc2864262fbcd32c8 100755 (executable)
@@ -224,6 +224,8 @@ static void asdell();
 int input_line(char *string, int length);
 void con_term();
 void trapctlc();
+int usrbrk();
+void clrbrk();
     
 void con_init(FILE *input)
 {
@@ -432,6 +434,10 @@ input_line(char *string, int length)
     }
     noline = 1;                      /* no line fetched yet */
     for (cl=cp=0; cl<length && cl<(int)sizeof(curline); ) {
+       if (usrbrk()) {
+          clrbrk();
+          break;
+       }
        switch (c=(int)input_char()) {
        case F_RETURN:                /* CR */
             t_sendl("\r\n", 2);       /* yes, print it and */
index f61f9e5e58ae8726f0c8db837c84416eac572de2..614951411754f432c660b06e794e292173aa19aa 100644 (file)
@@ -569,6 +569,9 @@ again:
       }
       break;
    }
+   if (usrbrk()) {
+      clrbrk();
+   }
    strip_trailing_junk(sock->msg);
    sock->msglen = strlen(sock->msg);
    return 1;
index 6f941c0cc49678b156b8b4b7b007e281498dfd3f..69ace2286a3863a42e8bef55642044be31170d4f 100755 (executable)
@@ -1,5 +1,5 @@
 /*
-   Copyright (C) 2000-2003 Kern Sibbald and John Walker
+   Copyright (C) 2000-2004 Kern Sibbald and John Walker
 
    This program is free software; you can redistribute it and/or
    modify it under the terms of the GNU General Public License as
@@ -18,7 +18,7 @@
 
    This file is patterned after the VNC Win32 code by ATT
   
-   Copyright (2000) Kern E. Sibbald
+   Kern E. Sibbald, 2000
 */
 
 #include "winbacula.h"
 
 bacAbout::bacAbout()
 {
-   visible = FALSE;
+   visible = false;
 }
 
-bacAbout::~bacAbout()
-{
-}
+bacAbout::~bacAbout() { };
 
 void bacAbout::Show(BOOL show)
 {
@@ -41,21 +39,22 @@ void bacAbout::Show(BOOL show)
    }
 }
 
+
 BOOL CALLBACK
 bacAbout::DialogProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam )
 {
-   /* The dialog-box this pointer is in USERDATA */
-   bacAbout *_this = (bacAbout *)GetWindowLong(hwnd, GWL_USERDATA);
+   /* Get the dialog class pointer from USERDATA */
+   bacAbout *_this;
 
    switch (uMsg) {
    case WM_INITDIALOG:
-      /* Retrieve the Dialog box parameter */
+      /* save the dialog class pointer */
       SetWindowLong(hwnd, GWL_USERDATA, lParam);
       _this = (bacAbout *)lParam;
 
       /* Show the dialog */
       SetForegroundWindow(hwnd);
-      _this->visible = TRUE;
+      _this->visible = true;
       return TRUE;
 
    case WM_COMMAND:
@@ -63,14 +62,16 @@ bacAbout::DialogProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam )
       case IDCANCEL:
       case IDOK:
          EndDialog(hwnd, TRUE);
-         _this->visible = FALSE;
+         _this = (bacAbout *)GetWindowLong(hwnd, GWL_USERDATA);
+         _this->visible = false;
          return TRUE;
       }
       break;
 
    case WM_DESTROY:
       EndDialog(hwnd, FALSE);
-      _this->visible = FALSE;
+      _this = (bacAbout *)GetWindowLong(hwnd, GWL_USERDATA);
+      _this->visible = false;
       return TRUE;
    }
    return 0;
index 9d4d086c04ecc70adbed06ef1831c1c63075c700..5408a752830592f8ac3accb78bdb6ccece611f1e 100755 (executable)
@@ -1,5 +1,5 @@
 /*
-   Copyright (C) 2000, 2001, 2002 Kern Sibbald and John Walker
+   Copyright (C) 2000-2004 Kern Sibbald and John Walker
 
    This program is free software; you can redistribute it and/or
    modify it under the terms of the GNU General Public License as
@@ -18,7 +18,7 @@
 
    This file was inspired by the VNC Win32 code by ATT
   
-   Copyright (2000) Kern E. Sibbald
+   Kern E. Sibbald, 2000
 */
 
 
@@ -34,7 +34,7 @@ class bacAbout
 {
 public:
    bacAbout();
-   ~bacAbout();
+  ~bacAbout();
 
    /* The dialog box window proc */
    static BOOL CALLBACK DialogProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
@@ -42,7 +42,7 @@ public:
    void Show(BOOL show);
 
    /* Object local storage */
-   BOOL visible;
+   bool visible;
 };
 
 #endif
index 0cc4ccbd47ba7ffa0b9a968f95db12b9a801d032..bef757e231d459a68eedb0c84ed437d857c7c226 100644 (file)
@@ -92,7 +92,7 @@ static int32_t write_nbytes(BSOCK *bsock, char *ptr, int32_t nbytes)
    if (bsock->spool) {
       nwritten = fwrite(ptr, 1, nbytes, bsock->spool_fd);
       if (nwritten != nbytes) {
-         Jmsg1(bsock->jcr, M_FATAL, 0, _("Attr spool write error. ERR=%s\n"), strerror(errno));
+         Qmsg1(bsock->jcr, M_FATAL, 0, _("Attr spool write error. ERR=%s\n"), strerror(errno));
          Dmsg2(400, "nwritten=%d nbytes=%d.\n", nwritten, nbytes);
         return -1;
       }
@@ -179,8 +179,8 @@ int32_t bnet_recv(BSOCK *bsock)
    if (nbytes != sizeof(int32_t)) {
       bsock->errors++;
       bsock->b_errno = EIO;
-      Jmsg5(bsock->jcr, M_ERROR, 0, _("Read expected %d got %d from %s:%s:%d\n"), pktsiz, nbytes,
-           bsock->who, bsock->host, bsock->port);
+      Qmsg5(bsock->jcr, M_ERROR, 0, _("Read expected %d got %d from %s:%s:%d\n"), 
+           sizeof(int32_t), nbytes, bsock->who, bsock->host, bsock->port);
       return BNET_ERROR;
    }
 
@@ -196,7 +196,7 @@ int32_t bnet_recv(BSOCK *bsock)
    /* If signal or packet size too big */
    if (pktsiz < 0 || pktsiz > 1000000) {
       if (pktsiz > 0) {              /* if packet too big */
-        Jmsg3(bsock->jcr, M_FATAL, 0, 
+        Qmsg3(bsock->jcr, M_FATAL, 0, 
             _("Packet size too big from \"%s:%s:%d. Terminating connection.\n"),
            bsock->who, bsock->host, bsock->port);
         pktsiz = BNET_TERMINATE;     /* hang up */
@@ -226,7 +226,7 @@ int32_t bnet_recv(BSOCK *bsock)
         bsock->b_errno = errno;
       }
       bsock->errors++;
-      Jmsg4(bsock->jcr, M_ERROR, 0, _("Read error from %s:%s:%d: ERR=%s\n"), 
+      Qmsg4(bsock->jcr, M_ERROR, 0, _("Read error from %s:%s:%d: ERR=%s\n"), 
            bsock->who, bsock->host, bsock->port, bnet_strerror(bsock));
       return BNET_ERROR;
    }
@@ -236,7 +236,7 @@ int32_t bnet_recv(BSOCK *bsock)
    if (nbytes != pktsiz) {
       bsock->b_errno = EIO;
       bsock->errors++;
-      Jmsg5(bsock->jcr, M_ERROR, 0, _("Read expected %d got %d from %s:%s:%d\n"), pktsiz, nbytes,
+      Qmsg5(bsock->jcr, M_ERROR, 0, _("Read expected %d got %d from %s:%s:%d\n"), pktsiz, nbytes,
            bsock->who, bsock->host, bsock->port);
       return BNET_ERROR;
    }
@@ -296,14 +296,14 @@ int bnet_despool_to_bsock(BSOCK *bsock)
         nbytes = fread(bsock->msg, 1, bsock->msglen, bsock->spool_fd);
         if (nbytes != (size_t)bsock->msglen) {
             Dmsg2(400, "nbytes=%d msglen=%d\n", nbytes, bsock->msglen);
-            Jmsg1(bsock->jcr, M_FATAL, 0, _("fread attr spool error. ERR=%s\n"), strerror(errno));
+            Qmsg1(bsock->jcr, M_FATAL, 0, _("fread attr spool error. ERR=%s\n"), strerror(errno));
            return 0;
         }
       }
       bnet_send(bsock);
    }
    if (ferror(bsock->spool_fd)) {
-      Jmsg1(bsock->jcr, M_FATAL, 0, _("fread attr spool error. ERR=%s\n"), strerror(errno));
+      Qmsg1(bsock->jcr, M_FATAL, 0, _("fread attr spool error. ERR=%s\n"), strerror(errno));
       return 0;
    }
    return 1;
@@ -348,11 +348,11 @@ bnet_send(BSOCK *bsock)
       }
       if (rc < 0) {
         if (!bsock->suppress_error_msgs && !bsock->timed_out) {
-            Jmsg4(bsock->jcr, M_ERROR, 0, _("Write error sending to %s:%s:%d: ERR=%s\n"), 
+            Qmsg4(bsock->jcr, M_ERROR, 0, _("Write error sending to %s:%s:%d: ERR=%s\n"), 
                  bsock->who, bsock->host, bsock->port,  bnet_strerror(bsock));
         }
       } else {
-         Jmsg5(bsock->jcr, M_ERROR, 0, _("Wrote %d bytes to %s:%s:%d, but only %d accepted.\n"), 
+         Qmsg5(bsock->jcr, M_ERROR, 0, _("Wrote %d bytes to %s:%s:%d, but only %d accepted.\n"), 
               bsock->who, bsock->host, bsock->port, bsock->msglen, rc);
       }
       return 0;
@@ -377,11 +377,11 @@ bnet_send(BSOCK *bsock)
       }
       if (rc < 0) {
         if (!bsock->suppress_error_msgs) {
-            Jmsg4(bsock->jcr, M_ERROR, 0, _("Write error sending to %s:%s:%d: ERR=%s\n"), 
+            Qmsg4(bsock->jcr, M_ERROR, 0, _("Write error sending to %s:%s:%d: ERR=%s\n"), 
                  bsock->who, bsock->host, bsock->port,  bnet_strerror(bsock));
         }
       } else {
-         Jmsg5(bsock->jcr, M_ERROR, 0, _("Wrote %d bytes to %s:%s:%d, but only %d accepted.\n"), 
+         Qmsg5(bsock->jcr, M_ERROR, 0, _("Wrote %d bytes to %s:%s:%d, but only %d accepted.\n"), 
               bsock->msglen, bsock->who, bsock->host, bsock->port, rc);
       }
       return 0;
@@ -542,13 +542,13 @@ static uint32_t *bget_host_ip(JCR *jcr, char *host)
    } else {
       P(ip_mutex);
       if ((hp = gethostbyname(host)) == NULL) {
-         Jmsg2(jcr, M_ERROR, 0, "gethostbyname() for host \"%s\" failed: ERR=%s\n", 
+         Qmsg2(jcr, M_ERROR, 0, "gethostbyname() for host \"%s\" failed: ERR=%s\n", 
               host, gethost_strerror());
         V(ip_mutex);
         return NULL;
       }
       if (hp->h_length != sizeof(inaddr.s_addr) || hp->h_addrtype != AF_INET) {
-         Jmsg2(jcr, M_ERROR, 0, _("gethostbyname() network address length error.\n\
+         Qmsg2(jcr, M_ERROR, 0, _("gethostbyname() network address length error.\n\
 Wanted %d got %d bytes for s_addr.\n"), sizeof(inaddr.s_addr), hp->h_length);
         V(ip_mutex);
         return NULL;
@@ -609,7 +609,7 @@ bnet_open(JCR *jcr, const char *name, char *host, char *service, int port, int *
     * Receive notification when connection dies.
     */
    if (setsockopt(sockfd, SOL_SOCKET, SO_KEEPALIVE, (sockopt_val_t)&turnon, sizeof(turnon)) < 0) {
-      Jmsg(jcr, M_WARNING, 0, _("Cannot set SO_KEEPALIVE on socket: %s\n"), strerror(errno));
+      Qmsg1(jcr, M_WARNING, 0, _("Cannot set SO_KEEPALIVE on socket: %s\n"), strerror(errno));
    }
    
    for (i = 0; addr_list[i] != ((uint32_t) -1); i++) {
@@ -650,13 +650,13 @@ bnet_connect(JCR *jcr, int retry_interval, int max_retry_time, const char *name,
       if (i < 0) {
         i = 60 * 5;                  /* complain again in 5 minutes */
         if (verbose)
-            Jmsg(jcr, M_WARNING, 0, "Could not connect to %s on %s:%d. ERR=%s\n\
+            Qmsg4(jcr, M_WARNING, 0, "Could not connect to %s on %s:%d. ERR=%s\n\
 Retrying ...\n", name, host, port, strerror(errno));
       }
       bmicrosleep(retry_interval, 0);
       max_retry_time -= retry_interval;
       if (max_retry_time <= 0) {
-         Jmsg(jcr, M_FATAL, 0, _("Unable to connect to %s on %s:%d. ERR=%s\n"),
+         Qmsg4(jcr, M_FATAL, 0, _("Unable to connect to %s on %s:%d. ERR=%s\n"),
              name, host, port, strerror(errno));
         return NULL;
       }
@@ -729,21 +729,21 @@ int bnet_set_buffer_size(BSOCK *bs, uint32_t size, int rw)
    }
    start_size = dbuf_size;
    if ((bs->msg = realloc_pool_memory(bs->msg, dbuf_size+100)) == NULL) {
-      Jmsg0(bs->jcr, M_FATAL, 0, _("Could not malloc BSOCK data buffer\n"));
+      Qmsg0(bs->jcr, M_FATAL, 0, _("Could not malloc BSOCK data buffer\n"));
       return 0;
    }
    if (rw & BNET_SETBUF_READ) {
       while ((dbuf_size > TAPE_BSIZE) &&
         (setsockopt(bs->fd, SOL_SOCKET, SO_RCVBUF, (sockopt_val_t)&dbuf_size, sizeof(dbuf_size)) < 0)) {
-         Jmsg1(bs->jcr, M_ERROR, 0, _("sockopt error: %s\n"), strerror(errno));
+         Qmsg1(bs->jcr, M_ERROR, 0, _("sockopt error: %s\n"), strerror(errno));
         dbuf_size -= TAPE_BSIZE;
       }
       Dmsg1(200, "set network buffer size=%d\n", dbuf_size);
       if (dbuf_size != start_size) {
-         Jmsg1(bs->jcr, M_WARNING, 0, _("Warning network buffer = %d bytes not max size.\n"), dbuf_size);
+         Qmsg1(bs->jcr, M_WARNING, 0, _("Warning network buffer = %d bytes not max size.\n"), dbuf_size);
       }
       if (dbuf_size % TAPE_BSIZE != 0) {
-         Jmsg1(bs->jcr, M_ABORT, 0, _("Network buffer size %d not multiple of tape block size.\n"),
+         Qmsg1(bs->jcr, M_ABORT, 0, _("Network buffer size %d not multiple of tape block size.\n"),
              dbuf_size);
       }
    }
@@ -756,15 +756,15 @@ int bnet_set_buffer_size(BSOCK *bs, uint32_t size, int rw)
    if (rw & BNET_SETBUF_WRITE) {
       while ((dbuf_size > TAPE_BSIZE) &&
         (setsockopt(bs->fd, SOL_SOCKET, SO_SNDBUF, (sockopt_val_t)&dbuf_size, sizeof(dbuf_size)) < 0)) {
-         Jmsg1(bs->jcr, M_ERROR, 0, _("sockopt error: %s\n"), strerror(errno));
+         Qmsg1(bs->jcr, M_ERROR, 0, _("sockopt error: %s\n"), strerror(errno));
         dbuf_size -= TAPE_BSIZE;
       }
       Dmsg1(200, "set network buffer size=%d\n", dbuf_size);
       if (dbuf_size != start_size) {
-         Jmsg1(bs->jcr, M_WARNING, 0, _("Warning network buffer = %d bytes not max size.\n"), dbuf_size);
+         Qmsg1(bs->jcr, M_WARNING, 0, _("Warning network buffer = %d bytes not max size.\n"), dbuf_size);
       }
       if (dbuf_size % TAPE_BSIZE != 0) {
-         Jmsg1(bs->jcr, M_ABORT, 0, _("Network buffer size %d not multiple of tape block size.\n"),
+         Qmsg1(bs->jcr, M_ABORT, 0, _("Network buffer size %d not multiple of tape block size.\n"),
              dbuf_size);
       }
    }
index 9dd304e2f24d8a2e8f76fcc81bb3a0e5dc37d6c9..c0d124263881447a2bbbd22b4283580500821dd6 100644 (file)
@@ -155,6 +155,7 @@ void dlist::destroy()
       n = ni;
    }
    num_items = 0;
+   head = tail = NULL;
 }
 
 
index 3b97f59341e05f89cd571342e487ed45830c7560..8f7d60bd1b828e12400d3af0028fcade3e0dc2a2 100755 (executable)
@@ -286,8 +286,8 @@ static void free_common_jcr(JCR *jcr)
    }
    pthread_mutex_destroy(&jcr->mutex);
 
-   close_msg(jcr);                   /* close messages for this job */
    delete jcr->msg_queue;
+   close_msg(jcr);                   /* close messages for this job */
 
    /* do this after closing messages */
    if (jcr->client_name) {
@@ -355,6 +355,7 @@ void free_jcr(JCR *jcr)
       Dmsg2(400, "free_jcr 0x%x use_count=%d\n", jcr, jcr->use_count);
       return;
    }
+   dequeue_messages(jcr);
    remove_jcr(jcr);
    job_end_pop(jcr);                 /* pop and call hooked routines */
 
index b8b4b004d0c1019035a8cb0b52427c1b858a2c03..e6cb8f010b33aef4dc9404398aba5070e138ddbc 100755 (executable)
@@ -1033,14 +1033,16 @@ void j_msg(const char *file, int line, JCR *jcr, int type, int level, const char
    pool_buf = get_pool_memory(PM_EMSG);
    i = Mmsg(&pool_buf, "%s:%d ", file, line);
 
-again:
-   maxlen = sizeof_pool_memory(pool_buf) - i - 1; 
-   va_start(arg_ptr, fmt);
-   len = bvsnprintf(pool_buf+i, maxlen, fmt, arg_ptr);
-   va_end(arg_ptr);
-   if (len < 0 || len >= maxlen) {
-      pool_buf = realloc_pool_memory(pool_buf, maxlen + i + maxlen/2);
-      goto again;
+   for (;;) {
+      maxlen = sizeof_pool_memory(pool_buf) - i - 1; 
+      va_start(arg_ptr, fmt);
+      len = bvsnprintf(pool_buf+i, maxlen, fmt, arg_ptr);
+      va_end(arg_ptr);
+      if (len < 0 || len >= maxlen) {
+        pool_buf = realloc_pool_memory(pool_buf, maxlen + i + maxlen/2);
+        continue;
+      }
+      break;
    }
 
    Jmsg(jcr, type, level, "%s", pool_buf);
@@ -1058,14 +1060,16 @@ int m_msg(const char *file, int line, POOLMEM **pool_buf, const char *fmt, ...)
 
    i = sprintf(mp_chr(*pool_buf), "%s:%d ", file, line);
 
-again:
-   maxlen = sizeof_pool_memory(*pool_buf) - i - 1; 
-   va_start(arg_ptr, fmt);
-   len = bvsnprintf(*pool_buf+i, maxlen, fmt, arg_ptr);
-   va_end(arg_ptr);
-   if (len < 0 || len >= maxlen) {
-      *pool_buf = realloc_pool_memory(*pool_buf, maxlen + i + maxlen/2);
-      goto again;
+   for (;;) {
+      maxlen = sizeof_pool_memory(*pool_buf) - i - 1; 
+      va_start(arg_ptr, fmt);
+      len = bvsnprintf(*pool_buf+i, maxlen, fmt, arg_ptr);
+      va_end(arg_ptr);
+      if (len < 0 || len >= maxlen) {
+        *pool_buf = realloc_pool_memory(*pool_buf, maxlen + i + maxlen/2);
+        continue;
+      }
+      break;
    }
    return len;
 }
@@ -1079,14 +1083,16 @@ int Mmsg(POOLMEM **pool_buf, const char *fmt, ...)
    va_list   arg_ptr;
    int len, maxlen;
 
-again:
-   maxlen = sizeof_pool_memory(*pool_buf) - 1; 
-   va_start(arg_ptr, fmt);
-   len = bvsnprintf(*pool_buf, maxlen, fmt, arg_ptr);
-   va_end(arg_ptr);
-   if (len < 0 || len >= maxlen) {
-      *pool_buf = realloc_pool_memory(*pool_buf, maxlen + maxlen/2);
-      goto again;
+   for (;;) {
+      maxlen = sizeof_pool_memory(*pool_buf) - 1; 
+      va_start(arg_ptr, fmt);
+      len = bvsnprintf(*pool_buf, maxlen, fmt, arg_ptr);
+      va_end(arg_ptr);
+      if (len < 0 || len >= maxlen) {
+        *pool_buf = realloc_pool_memory(*pool_buf, maxlen + maxlen/2);
+        continue;
+      }
+      break;
    }
    return len;
 }
@@ -1096,7 +1102,9 @@ static pthread_mutex_t msg_queue_mutex = PTHREAD_MUTEX_INITIALIZER;
 /*
  * We queue messages rather than print them directly. This
  *  is generally used in low level routines (msg handler, bnet)
- *  to prevent recursion.
+ *  to prevent recursion (i.e. if you are in the middle of 
+ *  sending a message, it is a bit messy to recursively call
+ *  yourself when the bnet packet is not reentrant).
  */
 void Qmsg(JCR *jcr, int type, int level, const char *fmt,...)
 {
@@ -1105,26 +1113,33 @@ void Qmsg(JCR *jcr, int type, int level, const char *fmt,...)
    POOLMEM *pool_buf;
    MQUEUE_ITEM *item;
 
-   if (jcr->dequeuing) {             /* do not allow recursion */
-      return;
-   }
    pool_buf = get_pool_memory(PM_EMSG);
 
-again:
-   maxlen = sizeof_pool_memory(pool_buf) - 1; 
-   va_start(arg_ptr, fmt);
-   len = bvsnprintf(pool_buf, maxlen, fmt, arg_ptr);
-   va_end(arg_ptr);
-   if (len < 0 || len >= maxlen) {
-      pool_buf = realloc_pool_memory(pool_buf, maxlen + maxlen/2);
-      goto again;
+   for (;;) {
+      maxlen = sizeof_pool_memory(pool_buf) - 1; 
+      va_start(arg_ptr, fmt);
+      len = bvsnprintf(pool_buf, maxlen, fmt, arg_ptr);
+      va_end(arg_ptr);
+      if (len < 0 || len >= maxlen) {
+        pool_buf = realloc_pool_memory(pool_buf, maxlen + maxlen/2);
+        continue;
+      }
+      break;
    }
    item = (MQUEUE_ITEM *)malloc(sizeof(MQUEUE_ITEM) + strlen(pool_buf) + 1);
    item->type = type;
    item->level = level;
    strcpy(item->msg, pool_buf);  
    P(msg_queue_mutex);
-   jcr->msg_queue->append(item);
+   /* If no jcr or dequeuing send to daemon to avoid recursion */
+   if (!jcr || jcr->dequeuing) {
+      /* jcr==NULL => daemon message, safe to send now */
+      Jmsg(NULL, item->type, item->level, "%s", item->msg);
+      free(item);
+   } else {
+      /* Queue message for later sending */
+      jcr->msg_queue->append(item);
+   }
    V(msg_queue_mutex);
    free_memory(pool_buf);
 }
@@ -1159,14 +1174,16 @@ void q_msg(const char *file, int line, JCR *jcr, int type, int level, const char
    pool_buf = get_pool_memory(PM_EMSG);
    i = Mmsg(&pool_buf, "%s:%d ", file, line);
 
-again:
-   maxlen = sizeof_pool_memory(pool_buf) - i - 1; 
-   va_start(arg_ptr, fmt);
-   len = bvsnprintf(pool_buf+i, maxlen, fmt, arg_ptr);
-   va_end(arg_ptr);
-   if (len < 0 || len >= maxlen) {
-      pool_buf = realloc_pool_memory(pool_buf, maxlen + i + maxlen/2);
-      goto again;
+   for (;;) {
+      maxlen = sizeof_pool_memory(pool_buf) - i - 1; 
+      va_start(arg_ptr, fmt);
+      len = bvsnprintf(pool_buf+i, maxlen, fmt, arg_ptr);
+      va_end(arg_ptr);
+      if (len < 0 || len >= maxlen) {
+        pool_buf = realloc_pool_memory(pool_buf, maxlen + i + maxlen/2);
+        continue;
+      }
+      break;
    }
 
    Qmsg(jcr, type, level, "%s", pool_buf);
index 3015c23ed285a2acca5d09918ee5312c9f388886..45169f0c1d4dc559f0e6bf51042d7892df504f4e 100644 (file)
@@ -2,8 +2,8 @@
 #undef  VERSION
 #define VERSION "1.33.6"
 #define VSTRING "1"
-#define BDATE   "27 Mar 2004"
-#define LSMDATE "27Mar04"
+#define BDATE   "28 Mar 2004"
+#define LSMDATE "28Mar04"
 
 /* Debug flags */
 #undef  DEBUG