]> git.sur5r.net Git - bacula/bacula/commitdiff
kes Fix bug #462 incorrect error message printed when client script called
authorKern Sibbald <kern@sibbald.com>
Mon, 7 Aug 2006 09:17:25 +0000 (09:17 +0000)
committerKern Sibbald <kern@sibbald.com>
Mon, 7 Aug 2006 09:17:25 +0000 (09:17 +0000)
     from File= was not found.
kes  Fix bug #558 (waiting for feedback) where Bacula needs too much time to
     do a rewind on Solaris when no tape is in the drive (Solaris does not
     have the detailed errno found on Linux).  Added Solaris specific code.
     Note, this may apply to other OSes as well.

git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@3264 91ce42f0-d328-0410-95d8-f526ca767f89

bacula/kernstodo
bacula/src/filed/job.c
bacula/src/lib/berrno.c
bacula/src/lib/berrno.h
bacula/src/lib/bpipe.c
bacula/src/lib/runscript.c
bacula/src/stored/dev.c
bacula/src/version.h
bacula/technotes-1.39

index be2860a656f06395788e23259dad6ad56f11f88a..2603a3b290a348cc617515bbf5e666c0405f10ed 100644 (file)
@@ -31,6 +31,7 @@ Document:
 Priority:
 
 For 1.39:
+- Add manpages to the list of directories for make install.
 - If a job terminates, the DIR connection can close before the
   Volume info is updated, leaving the File count wrong.
 - Look at why SIGPIPE during connection can cause seg fault in
index fb9e3b6bedc8fe830d8a2eef294d2e9c363b33d9..6d5fad97cee033e9b29465b0b6ed47a26108a8f0 100644 (file)
@@ -591,19 +591,22 @@ static void add_file_to_fileset(JCR *jcr, const char *fname, findFILESET *filese
       fn = get_pool_memory(PM_FNAME);
       fn = edit_job_codes(jcr, fn, p, "");
       bpipe = open_bpipe(fn, 0, "r");
-      free_pool_memory(fn);
       if (!bpipe) {
+         berrno be;
          Jmsg(jcr, M_FATAL, 0, _("Cannot run program: %s. ERR=%s\n"),
-            p, strerror(errno));
+            p, be.strerror());
+         free_pool_memory(fn);
          return;
       }
+      free_pool_memory(fn);
       while (fgets(buf, sizeof(buf), bpipe->rfd)) {
          strip_trailing_junk(buf);
          fileset->incexe->name_list.append(bstrdup(buf));
       }
       if ((stat=close_bpipe(bpipe)) != 0) {
-         Jmsg(jcr, M_FATAL, 0, _("Error running program: %s. RtnStat=%d ERR=%s\n"),
-            p, stat, strerror(errno));
+         berrno be;
+         Jmsg(jcr, M_FATAL, 0, _("Error running program: %s. stat=%d: ERR=%s\n"),
+            p, be.code(stat), be.strerror(stat));
          return;
       }
       break;
index 76641fd49b7ba645f3e30cde43e974e0353edc90..2a7109f953d085217ac35fa6ded1b4723b268a59 100644 (file)
@@ -12,7 +12,7 @@
  *
  */
 /*
-   Copyright (C) 2004-2005 Kern Sibbald
+   Copyright (C) 2004-2006 Kern Sibbald
 
    This program is free software; you can redistribute it and/or
    modify it under the terms of the GNU General Public License
@@ -56,7 +56,7 @@ const char *berrno::strerror()
                return _("Unknown error during program execvp");
             }
          } else {
-            Mmsg(&buf_, _("Child exited with code %d"), stat);
+            Mmsg(buf_, _("Child exited with code %d"), stat);
             return buf_;
          }
          /* If we drop out here, berrno_ is set to an execvp errno */
@@ -64,7 +64,7 @@ const char *berrno::strerror()
    }
    if (berrno_ & b_errno_signal) {
       stat = (berrno_ & ~b_errno_signal);        /* remove bit */
-      Mmsg(&buf_, _("Child died from signal %d: %s"), stat, get_signal_name(stat));
+      Mmsg(buf_, _("Child died from signal %d: %s"), stat, get_signal_name(stat));
       return buf_;
    }
 #endif
index adeeab0cb7b939516f8770dad6360e3cbab81130..46a6a3a3040d9e455046a615caef636fee30ee8e 100644 (file)
@@ -5,7 +5,7 @@
  *
  */
 /*
-   Copyright (C) 2004-2005 Kern Sibbald
+   Copyright (C) 2004-2006 Kern Sibbald
 
    This program is free software; you can redistribute it and/or
    modify it under the terms of the GNU General Public License
@@ -19,6 +19,9 @@
 
  */
 
+/*
+ * Extra bits set to interpret errno value differently from errno
+ */
 #ifdef HAVE_WIN32
 #define b_errno_win32  (1<<29)        /* user reserved bit */
 #endif
@@ -48,6 +51,8 @@ public:
    const char *strerror();
    const char *strerror(int errnum);
    void set_errno(int errnum);
+   int code() { return berrno_ & ~(b_errno_exit|b_errno_signal); }
+   int code(int stat) { return stat & ~(b_errno_exit|b_errno_signal); }
 };
 
 /* Constructor */
index d0fa3aaa79e1712cf7b87a0bd62fd8f951a537cc..3f142bb8cbe77691cb345a7756dc6370449c36d3 100644 (file)
@@ -80,8 +80,8 @@ BPIPE *open_bpipe(char *prog, int wait, const char *mode)
    if (mode_write && pipe(writep) == -1) {
       save_errno = errno;
       free(bpipe);
-      errno = save_errno;
       free_pool_memory(tprog);
+      errno = save_errno;
       return NULL;
    }
    if (mode_read && pipe(readp) == -1) {
@@ -91,8 +91,8 @@ BPIPE *open_bpipe(char *prog, int wait, const char *mode)
          close(writep[1]);
       }
       free(bpipe);
-      errno = save_errno;
       free_pool_memory(tprog);
+      errno = save_errno;
       return NULL;
    }
    /* Start worker process */
@@ -108,8 +108,8 @@ BPIPE *open_bpipe(char *prog, int wait, const char *mode)
          close(readp[1]);
       }
       free(bpipe);
-      errno = save_errno;
       free_pool_memory(tprog);
+      errno = save_errno;
       return NULL;
 
    case 0:                            /* child */
@@ -237,7 +237,7 @@ int close_bpipe(BPIPE *bpipe)
 #ifndef HAVE_WIN32
          stat = WTERMSIG(chldstatus);
 #else
-#warning "WTERMSIG undefined in Win32 !!!"
+         stat = 1;                    /* fake child status */
 #endif
          Dmsg1(800, "Child died from signal %d\n", stat);
          stat |= b_errno_signal;      /* exit signal returned */
@@ -247,7 +247,7 @@ int close_bpipe(BPIPE *bpipe)
       stop_child_timer(bpipe->timer_id);
    }
    free(bpipe);
-   Dmsg1(800, "returning stat = %d\n", stat);
+   Dmsg2(800, "returning stat=%d,%d\n", stat & ~(b_errno_exit|b_errno_signal), stat);
    return stat;
 }
 
index aeb99c4e8ef7ec416b77f7136970ada885b9f847..13b6d74e95c6bfeb8853d533b6d4111e111b8f9f 100644 (file)
@@ -203,7 +203,7 @@ int RUNSCRIPT::run(JCR *jcr, const char *name)
    free_pool_memory(ecmd);
    if (bpipe == NULL) {
       berrno be;
-      Jmsg(jcr, M_FATAL, 0, _("%s could not execute. ERR=%s\n"), name,
+      Jmsg(jcr, M_FATAL, 0, _("Runscript: %s could not execute. ERR=%s\n"), name,
          be.strerror());
       return false;
    }
@@ -217,8 +217,8 @@ int RUNSCRIPT::run(JCR *jcr, const char *name)
    status = close_bpipe(bpipe);
    if (status != 0) {
       berrno be;
-      Jmsg(jcr, M_FATAL, 0, _("%s returned non-zero status=%d. ERR=%s\n"), name,
-         status, be.strerror(status));
+      Jmsg(jcr, M_FATAL, 0, _("Runscript: %s returned non-zero status=%d. ERR=%s\n"), name,
+         be.code(status), be.strerror(status));
       return false;
    }
    return true;
index 0643ff3b4e7c0a0f6ba658066e5c6e3f9eb3848b..f394db043dae593505cc2f9a38bfe1a7f3980d7c 100644 (file)
@@ -684,11 +684,18 @@ bool DEVICE::rewind(DCR *dcr)
                first = false;
                continue;
             }
+#ifdef HAVE_SUN_OS
+            if (dev_errno == EIO) {         
+               Mmsg1(errmsg, _("No tape loaded or drive offline on %s.\n"), print_name());
+               return false;
+            }
+#else
             if (dev_errno == EIO && i > 0) {
                Dmsg0(200, "Sleeping 5 seconds.\n");
                bmicrosleep(5, 0);
                continue;
             }
+#endif
             Mmsg2(errmsg, _("Rewind error on %s. ERR=%s.\n"),
                print_name(), be.strerror());
             return false;
@@ -1617,8 +1624,7 @@ void DEVICE::clrerror(int func)
    if (errno == ENOTTY || errno == ENOSYS) { /* Function not implemented */
       switch (func) {
       case -1:
-         Emsg0(M_ABORT, 0, _("Got ENOTTY on read/write!\n"));
-         break;
+         break;              /* ignore message printed later */
       case MTWEOF:
          msg = "WTWEOF";
          capabilities &= ~CAP_EOF; /* turn off feature */
index f636ca7472e603bc0956ae317d69991d055144b9..1acb70209a934dd18bddb8dd6c7121f2b14dec3d 100644 (file)
@@ -3,9 +3,9 @@
  */
 
 #undef  VERSION
-#define VERSION "1.39.18"
-#define BDATE   "04 August 2006"
-#define LSMDATE "04Aug06"
+#define VERSION "1.39.19"
+#define BDATE   "07 August 2006"
+#define LSMDATE "07Aug06"
 #define BYEAR "2006"       /* year for copyright messages in progs */
 
 /* Debug flags */
index 960f7335d64a0581f0dea57bb786434601f6b27a..7d4021b3c9497f9b0fe4506870e9c4e1bdf347a4 100644 (file)
@@ -1,6 +1,13 @@
               Technical notes on version 1.39  
 
 General:
+07Aug06
+kes  Fix bug #462 incorrect error message printed when client script called
+     from File= was not found.
+kes  Fix bug #558 (waiting for feedback) where Bacula needs too much time to
+     do a rewind on Solaris when no tape is in the drive (Solaris does not
+     have the detailed errno found on Linux).  Added Solaris specific code.
+     Note, this may apply to other OSes as well.
 06Aug06
 kes  Defined BUILDING_CATS in src/cats/cats.h so that *nix builds.
 dsb  Updated rpm spec for 1.39 - updatedb 9 to 10, add new man pages,