]> git.sur5r.net Git - bacula/bacula/commitdiff
Add regex to FileSet + fix ACL crash + gnome1 Makefile + 30 second retry for DB
authorKern Sibbald <kern@sibbald.com>
Thu, 1 Jul 2004 16:41:54 +0000 (16:41 +0000)
committerKern Sibbald <kern@sibbald.com>
Thu, 1 Jul 2004 16:41:54 +0000 (16:41 +0000)
git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@1453 91ce42f0-d328-0410-95d8-f526ca767f89

25 files changed:
bacula/autoconf/config.h.in
bacula/autoconf/configure.in
bacula/configure
bacula/kernstodo
bacula/src/baconfig.h
bacula/src/cats/cats.h
bacula/src/cats/mysql.c
bacula/src/cats/postgresql.c
bacula/src/cats/sql_create.c
bacula/src/cats/sql_find.c
bacula/src/cats/sql_get.c
bacula/src/cats/sqlite.c
bacula/src/dird/inc_conf.c
bacula/src/filed/backup.c
bacula/src/filed/bacula-fd.conf.in
bacula/src/filed/filed.c
bacula/src/filed/job.c
bacula/src/filed/restore.c
bacula/src/findlib/find.c
bacula/src/findlib/find.h
bacula/src/lib/bnet.c
bacula/src/lib/protos.h
bacula/src/lib/watchdog.c
bacula/src/stored/bacula-sd.conf.in
bacula/src/version.h

index a4dee78ce5da89217582c200a10f90e18a457097..b0222086756eda15e14a68f2172fd4f8b2f7f379 100644 (file)
 /* Define to 1 if you have the `readdir_r' function. */
 #undef HAVE_READDIR_R
 
+/* Define to 1 if you have the <regex.h> header file. */
+#undef HAVE_REGEX_H
+
 /* Define to 1 if you have the <resolv.h> header file. */
 #undef HAVE_RESOLV_H
 
index 1c32b035edfa1995071e788962e6e9efcaeef80c..35b024b28b9fa8e791fab00c78977f20ed23d3df 100644 (file)
@@ -451,13 +451,10 @@ AC_SUBST(READLINE_SRC)
 # Minimal stuff for readline Makefile configuration
 MAKE_SHELL=/bin/sh
 AC_SUBST(MAKE_SHELL)
-
 AC_HEADER_STAT
 AC_HEADER_DIRENT
-
 AC_CHECK_FUNCS(strcasecmp select setenv putenv tcgetattr setlocale lstat lchown)
 AC_CHECK_FUNCS(nanosleep nl_langinfo)
-
 AC_CHECK_HEADERS(varargs.h)
 
 # End of readline/conio stuff
@@ -985,6 +982,7 @@ AC_CHECK_HEADERS( \
        resolv.h \
        mtio.h \
        sys/mtio.h \
+       regex.h \
 )
 AC_HEADER_STDC
 AC_HEADER_MAJOR
@@ -1232,7 +1230,7 @@ fi
 
 
 dnl# --------------------------------------------------------------------------
-dnl# CHECKING FOR LIBRARY FUNCTIONS
+dnl# CHECKING FOR REQUIRED LIBRARY FUNCTIONS
 dnl# --------------------------------------------------------------------------
 AC_CHECK_FUNCS( \
        fork \
@@ -1700,7 +1698,7 @@ AC_OUTPUT([autoconf/Make.common \
           src/win32/console/bconsole.conf \
           src/win32/wx-console/wx-console.conf \
           $PFILES ],  
-         [(echo "Doing make of dependencies"; make depend;) ]
+         [(echo "Doing make of dependencies"; ${MAKE:-make} depend;) ]
 )
 
 cd scripts
index a1efe89302b4f71ec04870232df3b394decd0114..3236987c35f6d0ad724479f7f332dcb0c91d528d 100755 (executable)
@@ -5884,7 +5884,6 @@ fi
 # Minimal stuff for readline Makefile configuration
 MAKE_SHELL=/bin/sh
 
-
 echo "$as_me:$LINENO: checking whether stat file-mode macros are broken" >&5
 echo $ECHO_N "checking whether stat file-mode macros are broken... $ECHO_C" >&6
 if test "${ac_cv_header_stat_broken+set}" = set; then
@@ -6233,7 +6232,6 @@ fi
 
 
 
-
 for ac_func in strcasecmp select setenv putenv tcgetattr setlocale lstat lchown
 do
 as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
@@ -6403,7 +6401,6 @@ fi
 done
 
 
-
 for ac_header in varargs.h
 do
 as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
@@ -9150,6 +9147,7 @@ fi
 
 
 
+
 
 
 for ac_header in \
@@ -9175,6 +9173,7 @@ for ac_header in \
        resolv.h \
        mtio.h \
        sys/mtio.h \
+       regex.h \
 
 do
 as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
@@ -19736,7 +19735,7 @@ ac_abs_top_srcdir=`cd "$ac_dir" && cd $ac_top_srcdir && pwd`
   { echo "$as_me:$LINENO: executing $ac_dest commands" >&5
 echo "$as_me: executing $ac_dest commands" >&6;}
   case $ac_dest in
-    default ) (echo "Doing make of dependencies"; make depend;)
+    default ) (echo "Doing make of dependencies"; ${MAKE:-make} depend;)
  ;;
   esac
 done
index 95e10108c6819e9db9beeefb5ddda799e1e5cb6a..f85cdbe43b6436658814f72f1392384db6ce171a 100644 (file)
@@ -1,5 +1,5 @@
                  Kern's ToDo List
-                  26 June 2004
+                  01 July 2004
 
 1.35 Items to do:
 - Make btape release the drive during the "test" append.
@@ -10,7 +10,7 @@
   you lost/broke the Catalog -- do the same for "I know my
   file is there how do I get it back?".
 - When restore started from console, report jobid.
-- Win32 inc problem when new directory added.
+- Look at Win32 inc problem when new directory added files not saved???
 - Make FD run on Win95 if possible:
    The error I when I installed 1.34.2 clients:
    The BACULA-FD file is  
   user to the doc.
 - Make Verify jobs require exclusive use of Volume as Restore 
   jobs do.
-- Add regular expressions to FileSets.
 - Perhaps add read/write programs and/or plugins to FileSets.
 - Look at adding Client run command that will use the
   port opened by the client.
-- Test new I/O error despooling code.
 
 Documentation to do: (any release a little bit at a time)
 - Document query file format.
@@ -1087,3 +1085,6 @@ Block Position: 0
 - Add InChanger to "list media"
 - Implement second cut of SIGHUP in Dir
   (Implement resources on a single pointer)
+- Add regular expressions to FileSets.
+- Test new I/O error despooling code.
+
index 9153d271178ff0b9d1f30c0e608593c185080356..35f857de328199534fc6942bbc1502ea3a2dce87 100644 (file)
@@ -510,4 +510,13 @@ extern "C" int getdomainname(char *name, int len);
 #define nl_langinfo(x) ("ANSI_X3.4-1968")
 #endif
 
+/* Fake entry points if regex does not exist */
+#ifndef HAVE_REGEX_H
+#define regcomp(x, y, z) 1
+#define regfree(x)
+#define regerror(rc, preg, prbuf, len) bstrncpy(prbuf, "REGEX not available on this system.", len)
+#define regex_t int
+#define regmatch_t char
+#endif
+
 #endif /* _BACONFIG_H */
index a2fa2779aaf8ca5eced594102dc69d3c9b4cdd40..cea246d74b27099667949b101e0a1dcbc913ca8f 100644 (file)
@@ -57,71 +57,71 @@ struct sqlite {
    char dummy;
 };
 
-#define IS_NUM(x)             ((x) == 1)
-#define IS_NOT_NULL(x)        ((x) == 1)
+#define IS_NUM(x)            ((x) == 1)
+#define IS_NOT_NULL(x)       ((x) == 1)
 
 typedef struct s_sql_field {
-   char *name;                        /* name of column */
-   int length;                        /* length */
-   int max_length;                    /* max length */
-   uint32_t type;                     /* type */
-   uint32_t flags;                    /* flags */
+   char *name;                       /* name of column */
+   int length;                       /* length */
+   int max_length;                   /* max length */
+   uint32_t type;                    /* type */
+   uint32_t flags;                   /* flags */
 } SQL_FIELD;
 
 /*
  * This is the "real" definition that should only be
  * used inside sql.c and associated database interface
  * subroutines.
- *                    S Q L I T E
+ *                   S Q L I T E
  */
 typedef struct s_db {
-   BQUEUE bq;                         /* queue control */
-   brwlock_t lock;                    /* transaction lock */
+   BQUEUE bq;                        /* queue control */
+   brwlock_t lock;                   /* transaction lock */
    struct sqlite *db;
    char **result;
    int status;
-   int nrow;                          /* nrow returned from sqlite */
-   int ncolumn;                       /* ncolum returned from sqlite */
-   int num_rows;                      /* used by code */
-   int row;                           /* seek row */
-   int have_insert_id;                /* do not have insert id */
-   int fields_defined;                /* set when fields defined */
-   int field;                         /* seek field */
-   SQL_FIELD **fields;                /* defined fields */
+   int nrow;                         /* nrow returned from sqlite */
+   int ncolumn;                      /* ncolum returned from sqlite */
+   int num_rows;                     /* used by code */
+   int row;                          /* seek row */
+   int field;                        /* seek field */
+   SQL_FIELD **fields;               /* defined fields */
    int ref_count;
    char *db_name;
    char *db_user;
-   char *db_address;                  /* host name address */
-   char *db_socket;                   /* socket for local access */
+   char *db_address;                 /* host name address */
+   char *db_socket;                  /* socket for local access */
    char *db_password;
-   int  db_port;                      /* port for host name address */
-   bool connected;                    /* connection made to db */
-   char *sqlite_errmsg;               /* error message returned by sqlite */
-   POOLMEM *errmsg;                   /* nicely edited error message */
-   POOLMEM *cmd;                      /* SQL command string */
-   POOLMEM *cached_path;              /* cached path name */
-   int cached_path_len;               /* length of cached path */
-   uint32_t cached_path_id;           /* cached path id */
-   int transaction;                   /* transaction started */
-   int changes;                       /* changes during transaction */
-   POOLMEM *fname;                    /* Filename only */
-   POOLMEM *path;                     /* Path only */
-   POOLMEM *esc_name;                 /* Escaped file/path name */
-   int fnl;                           /* file name length */
-   int pnl;                           /* path name length */
+   int db_port;                      /* port for host name address */
+   bool connected;                   /* connection made to db */
+   bool have_insert_id;              /* do not have insert id */
+   bool fields_defined;              /* set when fields defined */
+   char *sqlite_errmsg;              /* error message returned by sqlite */
+   POOLMEM *errmsg;                  /* nicely edited error message */
+   POOLMEM *cmd;                     /* SQL command string */
+   POOLMEM *cached_path;             /* cached path name */
+   int cached_path_len;              /* length of cached path */
+   uint32_t cached_path_id;          /* cached path id */
+   int transaction;                  /* transaction started */
+   int changes;                      /* changes during transaction */
+   POOLMEM *fname;                   /* Filename only */
+   POOLMEM *path;                    /* Path only */
+   POOLMEM *esc_name;                /* Escaped file/path name */
+   int fnl;                          /* file name length */
+   int pnl;                          /* path name length */
 } B_DB;
 
 
 /* 
  * "Generic" names for easier conversion   
  *
- *                    S Q L I T E
+ *                   S Q L I T E
  */
 #define sql_store_result(x)   (x)->result
 #define sql_free_result(x)    my_sqlite_free_table(x)
 #define sql_fetch_row(x)      my_sqlite_fetch_row(x)
 #define sql_query(x, y)       my_sqlite_query((x), (y))
-#define sql_close(x)          sqlite_close((x)->db)  
+#define sql_close(x)         sqlite_close((x)->db)  
 #define sql_strerror(x)       (x)->sqlite_errmsg?(x)->sqlite_errmsg:"unknown"
 #define sql_num_rows(x)       (x)->nrow
 #define sql_data_seek(x, i)   (x)->row = (i)
@@ -130,15 +130,15 @@ typedef struct s_db {
 #define sql_field_seek(x, y)  my_sqlite_field_seek((x), (y))
 #define sql_fetch_field(x)    my_sqlite_fetch_field(x)
 #define sql_num_fields(x)     ((x)->ncolumn)
-#define SQL_ROW               char**   
+#define SQL_ROW              char**   
 
 
 
 /* In cats/sqlite.c */
-void       my_sqlite_free_table(B_DB *mdb);
+void      my_sqlite_free_table(B_DB *mdb);
 SQL_ROW    my_sqlite_fetch_row(B_DB *mdb);
-int        my_sqlite_query(B_DB *mdb, char *cmd);
-void       my_sqlite_field_seek(B_DB *mdb, int field);
+int       my_sqlite_query(B_DB *mdb, char *cmd);
+void      my_sqlite_field_seek(B_DB *mdb, int field);
 SQL_FIELD *my_sqlite_fetch_field(B_DB *mdb);
 
 
@@ -155,11 +155,11 @@ SQL_FIELD *my_sqlite_fetch_field(B_DB *mdb);
  * used inside sql.c and associated database interface
  * subroutines.
  *
- *                     M Y S Q L
+ *                    M Y S Q L
  */
 typedef struct s_db {
-   BQUEUE bq;                         /* queue control */
-   brwlock_t lock;                    /* transaction lock */
+   BQUEUE bq;                        /* queue control */
+   brwlock_t lock;                   /* transaction lock */
    MYSQL mysql;
    MYSQL *db;
    MYSQL_RES *result;
@@ -169,22 +169,22 @@ typedef struct s_db {
    char *db_name;
    char *db_user;
    char *db_password;
-   char *db_address;                  /* host address */
-   char *db_socket;                   /* socket for local access */
-   int db_port;                       /* port of host address */
-   int have_insert_id;                /* do have insert_id() */
+   char *db_address;                 /* host address */
+   char *db_socket;                  /* socket for local access */
+   int db_port;                      /* port of host address */
+   int have_insert_id;               /* do have insert_id() */
    bool connected;
-   POOLMEM *errmsg;                   /* nicely edited error message */
-   POOLMEM *cmd;                      /* SQL command string */
+   POOLMEM *errmsg;                  /* nicely edited error message */
+   POOLMEM *cmd;                     /* SQL command string */
    POOLMEM *cached_path;
-   int cached_path_len;               /* length of cached path */
+   int cached_path_len;              /* length of cached path */
    uint32_t cached_path_id;
-   int changes;                       /* changes made to db */
-   POOLMEM *fname;                    /* Filename only */
-   POOLMEM *path;                     /* Path only */
-   POOLMEM *esc_name;                 /* Escaped file/path name */
-   int fnl;                           /* file name length */
-   int pnl;                           /* path name length */
+   int changes;                      /* changes made to db */
+   POOLMEM *fname;                   /* Filename only */
+   POOLMEM *path;                    /* Path only */
+   POOLMEM *esc_name;                /* Escaped file/path name */
+   int fnl;                          /* file name length */
+   int pnl;                          /* path name length */
 } B_DB;
 
 #define DB_STATUS int
@@ -194,7 +194,7 @@ typedef struct s_db {
 #define sql_free_result(x)    mysql_free_result((x)->result)
 #define sql_fetch_row(x)      mysql_fetch_row((x)->result)
 #define sql_query(x, y)       mysql_query((x)->db, (y))
-#define sql_close(x)          mysql_close((x)->db)  
+#define sql_close(x)         mysql_close((x)->db)  
 #define sql_strerror(x)       mysql_error((x)->db)
 #define sql_num_rows(x)       mysql_num_rows((x)->result)
 #define sql_data_seek(x, i)   mysql_data_seek((x)->result, (i))
@@ -203,8 +203,8 @@ typedef struct s_db {
 #define sql_field_seek(x, y)  mysql_field_seek((x)->result, (y))
 #define sql_fetch_field(x)    mysql_fetch_field((x)->result)
 #define sql_num_fields(x)     (int)mysql_num_fields((x)->result)
-#define SQL_ROW               MYSQL_ROW
-#define SQL_FIELD             MYSQL_FIELD
+#define SQL_ROW              MYSQL_ROW
+#define SQL_FIELD            MYSQL_FIELD
 
 #else
 
@@ -215,15 +215,15 @@ typedef struct s_db {
 #include <libpq-fe.h>
 
 /* TEMP: the following is taken from select OID, typname from pg_type; */
-#define IS_NUM(x)             ((x) == 20 || (x) == 21 || (x) == 23 || (x) == 700 || (x) == 701)
-#define IS_NOT_NULL(x)        ((x) == 1)
+#define IS_NUM(x)            ((x) == 20 || (x) == 21 || (x) == 23 || (x) == 700 || (x) == 701)
+#define IS_NOT_NULL(x)       ((x) == 1)
 
 typedef char **POSTGRESQL_ROW;
 typedef struct pg_field {
-        char         *name;
-        int           max_length;
-        unsigned int  type;
-        unsigned int  flags;       // 1 == not null
+       char         *name;
+       int           max_length;
+       unsigned int  type;
+       unsigned int  flags;       // 1 == not null
 } POSTGRESQL_FIELD;
 
 
@@ -232,11 +232,11 @@ typedef struct pg_field {
  * used inside sql.c and associated database interface
  * subroutines.
  *
- *                     P O S T G R E S Q L
+ *                    P O S T G R E S Q L
  */
 typedef struct s_db {
-   BQUEUE bq;                         /* queue control */
-   brwlock_t lock;                    /* transaction lock */
+   BQUEUE bq;                        /* queue control */
+   brwlock_t lock;                   /* transaction lock */
    PGconn *db;
    PGresult *result;
    int status;
@@ -244,37 +244,37 @@ typedef struct s_db {
    POSTGRESQL_FIELD *fields;
    int num_rows;
    int num_fields;
-   int row_number;            /* what row number did we get via my_postgresql_data_seek? */
-   int field_number;          /* what field number did we get via my_postgresql_field_seek? */
+   int row_number;           /* what row number did we get via my_postgresql_data_seek? */
+   int field_number;         /* what field number did we get via my_postgresql_field_seek? */
    int ref_count;
    char *db_name;
    char *db_user;
    char *db_password;
-   char *db_address;              /* host address */
-   char *db_socket;               /* socket for local access */
-   int db_port;                   /* port of host address */
-   int have_insert_id;            /* do have insert_id() */
+   char *db_address;             /* host address */
+   char *db_socket;              /* socket for local access */
+   int db_port;                  /* port of host address */
+   int have_insert_id;           /* do have insert_id() */
    bool connected;
-   POOLMEM *errmsg;               /* nicely edited error message */
-   POOLMEM *cmd;                  /* SQL command string */
+   POOLMEM *errmsg;              /* nicely edited error message */
+   POOLMEM *cmd;                 /* SQL command string */
    POOLMEM *cached_path;
-   int cached_path_len;           /* length of cached path */
+   int cached_path_len;          /* length of cached path */
    uint32_t cached_path_id;
-   int transaction;                   /* transaction started */
-   int changes;                   /* changes made to db */
-   POOLMEM *fname;                /* Filename only */
-   POOLMEM *path;                 /* Path only */
-   POOLMEM *esc_name;             /* Escaped file/path name */
-   int fnl;                       /* file name length */
-   int pnl;                       /* path name length */
+   int transaction;                  /* transaction started */
+   int changes;                  /* changes made to db */
+   POOLMEM *fname;               /* Filename only */
+   POOLMEM *path;                /* Path only */
+   POOLMEM *esc_name;            /* Escaped file/path name */
+   int fnl;                      /* file name length */
+   int pnl;                      /* path name length */
 } B_DB;
 
-void               my_postgresql_free_result(B_DB *mdb);
-POSTGRESQL_ROW     my_postgresql_fetch_row  (B_DB *mdb);
-int                my_postgresql_query      (B_DB *mdb, char *query);
-void               my_postgresql_data_seek  (B_DB *mdb, int row);
-int                my_postgresql_currval    (B_DB *mdb, char *table_name);
-void               my_postgresql_field_seek (B_DB *mdb, int row);
+void              my_postgresql_free_result(B_DB *mdb);
+POSTGRESQL_ROW    my_postgresql_fetch_row  (B_DB *mdb);
+int               my_postgresql_query      (B_DB *mdb, char *query);
+void              my_postgresql_data_seek  (B_DB *mdb, int row);
+int               my_postgresql_currval    (B_DB *mdb, char *table_name);
+void              my_postgresql_field_seek (B_DB *mdb, int row);
 POSTGRESQL_FIELD * my_postgresql_fetch_field(B_DB *mdb);
 
 
@@ -283,7 +283,7 @@ POSTGRESQL_FIELD * my_postgresql_fetch_field(B_DB *mdb);
 #define sql_free_result(x)    my_postgresql_free_result(x)
 #define sql_fetch_row(x)      my_postgresql_fetch_row(x)
 #define sql_query(x, y)       my_postgresql_query((x), (y))
-#define sql_close(x)          PQfinish((x)->db)  
+#define sql_close(x)         PQfinish((x)->db)  
 #define sql_strerror(x)       PQresultErrorMessage((x)->result)
 #define sql_num_rows(x)       ((unsigned) PQntuples((x)->result))
 #define sql_data_seek(x, i)   my_postgresql_data_seek((x), (i))
@@ -292,8 +292,8 @@ POSTGRESQL_FIELD * my_postgresql_fetch_field(B_DB *mdb);
 #define sql_field_seek(x, y)  my_postgresql_field_seek((x), (y))
 #define sql_fetch_field(x)    my_postgresql_fetch_field(x)
 #define sql_num_fields(x)     ((x)->num_fields)
-#define SQL_ROW               POSTGRESQL_ROW
-#define SQL_FIELD             POSTGRESQL_FIELD
+#define SQL_ROW              POSTGRESQL_ROW
+#define SQL_FIELD            POSTGRESQL_FIELD
 
 #else  /* USE BACULA DB routines */
 
@@ -302,17 +302,17 @@ POSTGRESQL_FIELD * my_postgresql_fetch_field(B_DB *mdb);
 /* Change this each time there is some incompatible
  * file format change!!!!
  */
-#define BDB_VERSION 12                /* file version number */
+#define BDB_VERSION 12               /* file version number */
 
 struct s_control {
-   int bdb_version;                   /* Version number */
-   uint32_t JobId;                    /* next Job Id */
-   uint32_t PoolId;                   /* next Pool Id */
-   uint32_t MediaId;                  /* next Media Id */
-   uint32_t JobMediaId;               /* next JobMedia Id */
-   uint32_t ClientId;                 /* next Client Id */
-   uint32_t FileSetId;                /* nest FileSet Id */
-   time_t time;                       /* time file written */
+   int bdb_version;                  /* Version number */
+   uint32_t JobId;                   /* next Job Id */
+   uint32_t PoolId;                  /* next Pool Id */
+   uint32_t MediaId;                 /* next Media Id */
+   uint32_t JobMediaId;              /* next JobMedia Id */
+   uint32_t ClientId;                /* next Client Id */
+   uint32_t FileSetId;               /* nest FileSet Id */
+   time_t time;                      /* time file written */
 };
 
 
@@ -320,23 +320,23 @@ struct s_control {
  *  Bacula internal DB
  */
 typedef struct s_db {
-   BQUEUE bq;                         /* queue control */
-/* pthread_mutex_t mutex;  */         /* single thread lock */
-   brwlock_t lock;                    /* transaction lock */
-   int ref_count;                     /* number of times opened */
-   struct s_control control;          /* control file structure */
-   int cfd;                           /* control file device */
-   FILE *jobfd;                       /* Jobs records file descriptor */
-   FILE *poolfd;                      /* Pool records fd */
-   FILE *mediafd;                     /* Media records fd */
-   FILE *jobmediafd;                  /* JobMedia records fd */
-   FILE *clientfd;                    /* Client records fd */
-   FILE *filesetfd;                   /* FileSet records fd */
-   char *db_name;                     /* name of database */
-   POOLMEM *errmsg;                   /* nicely edited error message */
-   POOLMEM *cmd;                      /* Command string */
+   BQUEUE bq;                        /* queue control */
+/* pthread_mutex_t mutex;  */        /* single thread lock */
+   brwlock_t lock;                   /* transaction lock */
+   int ref_count;                    /* number of times opened */
+   struct s_control control;         /* control file structure */
+   int cfd;                          /* control file device */
+   FILE *jobfd;                      /* Jobs records file descriptor */
+   FILE *poolfd;                     /* Pool records fd */
+   FILE *mediafd;                    /* Media records fd */
+   FILE *jobmediafd;                 /* JobMedia records fd */
+   FILE *clientfd;                   /* Client records fd */
+   FILE *filesetfd;                  /* FileSet records fd */
+   char *db_name;                    /* name of database */
+   POOLMEM *errmsg;                  /* nicely edited error message */
+   POOLMEM *cmd;                     /* Command string */
    POOLMEM *cached_path;
-   int cached_path_len;               /* length of cached path */
+   int cached_path_len;              /* length of cached path */
    uint32_t cached_path_id;
 } B_DB;
 
@@ -351,12 +351,12 @@ typedef struct s_db {
 #define DELETE_DB(jcr, db, cmd) DeleteDB(__FILE__, __LINE__, jcr, db, cmd)
 
 
-#else    /* not __SQL_C */
+#else   /* not __SQL_C */
 
 /* This is a "dummy" definition for use outside of sql.c
  */
-typedef struct s_db {     
-   int dummy;                         /* for SunOS compiler */
+typedef struct s_db {    
+   int dummy;                        /* for SunOS compiler */
 } B_DB;  
 
 #endif /*  __SQL_C */
@@ -367,7 +367,7 @@ extern uint32_t bacula_db_version;
  *  but at the current time, this breaks MySQL.
  */
 typedef uint32_t FileId_t;
-typedef uint32_t DBId_t;              /* general DB id type */
+typedef uint32_t DBId_t;             /* general DB id type */
 typedef uint32_t JobId_t;
       
 #define faddr_t long
@@ -381,18 +381,18 @@ typedef uint32_t JobId_t;
 /* Job record */
 struct JOB_DBR {
    JobId_t JobId;
-   char Job[MAX_NAME_LENGTH];         /* Job unique name */
-   char Name[MAX_NAME_LENGTH];        /* Job base name */
-   int JobType;                       /* actually char(1) */
-   int JobLevel;                      /* actually char(1) */
-   int JobStatus;                     /* actually char(1) */
-   DBId_t ClientId;                   /* Id of client */
-   DBId_t PoolId;                     /* Id of pool */
-   DBId_t FileSetId;                  /* Id of FileSet */
-   time_t SchedTime;                  /* Time job scheduled */
-   time_t StartTime;                  /* Job start time */
-   time_t EndTime;                    /* Job termination time */
-   utime_t JobTDate;                  /* Backup time/date in seconds */
+   char Job[MAX_NAME_LENGTH];        /* Job unique name */
+   char Name[MAX_NAME_LENGTH];       /* Job base name */
+   int JobType;                      /* actually char(1) */
+   int JobLevel;                     /* actually char(1) */
+   int JobStatus;                    /* actually char(1) */
+   DBId_t ClientId;                  /* Id of client */
+   DBId_t PoolId;                    /* Id of pool */
+   DBId_t FileSetId;                 /* Id of FileSet */
+   time_t SchedTime;                 /* Time job scheduled */
+   time_t StartTime;                 /* Job start time */
+   time_t EndTime;                   /* Job termination time */
+   utime_t JobTDate;                 /* Backup time/date in seconds */
    uint32_t VolSessionId;
    uint32_t VolSessionTime;
    uint32_t JobFiles;
@@ -403,8 +403,8 @@ struct JOB_DBR {
    /* Note, FirstIndex, LastIndex, Start/End File and Block
     * are only used in the JobMedia record.
     */
-   uint32_t FirstIndex;               /* First index this Volume */
-   uint32_t LastIndex;                /* Last index this Volume */
+   uint32_t FirstIndex;              /* First index this Volume */
+   uint32_t LastIndex;               /* Last index this Volume */
    uint32_t StartFile;
    uint32_t EndFile;
    uint32_t StartBlock;
@@ -422,28 +422,28 @@ struct JOB_DBR {
  */
 /* JobMedia record */
 struct JOBMEDIA_DBR {
-   DBId_t JobMediaId;                 /* record id */
-   JobId_t  JobId;                    /* JobId */
-   DBId_t MediaId;                    /* MediaId */
-   uint32_t FirstIndex;               /* First index this Volume */
-   uint32_t LastIndex;                /* Last index this Volume */
-   uint32_t StartFile;                /* File for start of data */
-   uint32_t EndFile;                  /* End file on Volume */
-   uint32_t StartBlock;               /* start block on tape */
-   uint32_t EndBlock;                 /* last block */
+   DBId_t JobMediaId;                /* record id */
+   JobId_t  JobId;                   /* JobId */
+   DBId_t MediaId;                   /* MediaId */
+   uint32_t FirstIndex;              /* First index this Volume */
+   uint32_t LastIndex;               /* Last index this Volume */
+   uint32_t StartFile;               /* File for start of data */
+   uint32_t EndFile;                 /* End file on Volume */
+   uint32_t StartBlock;              /* start block on tape */
+   uint32_t EndBlock;                /* last block */
 };
 
 
 /* Volume Parameter structure */
 struct VOL_PARAMS {
    char VolumeName[MAX_NAME_LENGTH];  /* Volume name */
-   uint32_t VolIndex;                 /* Volume seqence no. */ 
-   uint32_t FirstIndex;               /* First index this Volume */
-   uint32_t LastIndex;                /* Last index this Volume */
-   uint32_t StartFile;                /* File for start of data */
-   uint32_t EndFile;                  /* End file on Volume */
-   uint32_t StartBlock;               /* start block on tape */
-   uint32_t EndBlock;                 /* last block */
+   uint32_t VolIndex;                /* Volume seqence no. */ 
+   uint32_t FirstIndex;              /* First index this Volume */
+   uint32_t LastIndex;               /* Last index this Volume */
+   uint32_t StartFile;               /* File for start of data */
+   uint32_t EndFile;                 /* End file on Volume */
+   uint32_t StartBlock;              /* start block on tape */
+   uint32_t EndBlock;                /* last block */
 };
 
 
@@ -452,9 +452,9 @@ struct VOL_PARAMS {
  *  records (e.g. pathname, filename, fileattributes).
  */
 struct ATTR_DBR {
-   char *fname;                       /* full path & filename */
-   char *link;                        /* link if any */
-   char *attr;                        /* attributes statp */
+   char *fname;                      /* full path & filename */
+   char *link;                       /* link if any */
+   char *attr;                       /* attributes statp */
    uint32_t FileIndex;
    uint32_t Stream;
    JobId_t  JobId;
@@ -476,26 +476,26 @@ struct FILE_DBR {
    char LStat[256];
 /*   int Status; */
    char SIG[50];
-   int SigType;                       /* NO_SIG/MD5_SIG/SHA1_SIG */
+   int SigType;                      /* NO_SIG/MD5_SIG/SHA1_SIG */
 };
 
 /* Pool record -- same format as database */
 struct POOL_DBR {
    DBId_t PoolId;
-   char Name[MAX_NAME_LENGTH];        /* Pool name */
-   uint32_t NumVols;                  /* total number of volumes */
-   uint32_t MaxVols;                  /* max allowed volumes */
-   int32_t UseOnce;                   /* set to use once only */
-   int32_t UseCatalog;                /* set to use catalog */
-   int32_t AcceptAnyVolume;           /* set to accept any volume sequence */
-   int32_t AutoPrune;                 /* set to prune automatically */
-   int32_t Recycle;                   /* default Vol recycle flag */
-   utime_t  VolRetention;             /* retention period in seconds */
-   utime_t  VolUseDuration;           /* time in secs volume can be used */
-   uint32_t MaxVolJobs;               /* Max Jobs on Volume */
-   uint32_t MaxVolFiles;              /* Max files on Volume */
-   uint64_t MaxVolBytes;              /* Max bytes on Volume */
-   char PoolType[MAX_NAME_LENGTH];             
+   char Name[MAX_NAME_LENGTH];       /* Pool name */
+   uint32_t NumVols;                 /* total number of volumes */
+   uint32_t MaxVols;                 /* max allowed volumes */
+   int32_t UseOnce;                  /* set to use once only */
+   int32_t UseCatalog;               /* set to use catalog */
+   int32_t AcceptAnyVolume;          /* set to accept any volume sequence */
+   int32_t AutoPrune;                /* set to prune automatically */
+   int32_t Recycle;                  /* default Vol recycle flag */
+   utime_t  VolRetention;            /* retention period in seconds */
+   utime_t  VolUseDuration;          /* time in secs volume can be used */
+   uint32_t MaxVolJobs;              /* Max Jobs on Volume */
+   uint32_t MaxVolFiles;             /* Max files on Volume */
+   uint64_t MaxVolBytes;             /* Max bytes on Volume */
+   char PoolType[MAX_NAME_LENGTH];            
    char LabelFormat[MAX_NAME_LENGTH];
    /* Extra stuff not in DB */
    faddr_t rec_addr;
@@ -503,37 +503,37 @@ struct POOL_DBR {
 
 /* Media record -- same as the database */
 struct MEDIA_DBR {
-   DBId_t MediaId;                    /* Unique volume id */
+   DBId_t MediaId;                   /* Unique volume id */
    char VolumeName[MAX_NAME_LENGTH];  /* Volume name */
    char MediaType[MAX_NAME_LENGTH];   /* Media type */
-   DBId_t PoolId;                     /* Pool id */
-   time_t   FirstWritten;             /* Time Volume first written */
-   time_t   LastWritten;              /* Time Volume last written */
-   time_t   LabelDate;                /* Date/Time Volume labeled */
-   uint32_t VolJobs;                  /* number of jobs on this medium */
-   uint32_t VolFiles;                 /* Number of files */
-   uint32_t VolBlocks;                /* Number of blocks */
-   uint32_t VolMounts;                /* Number of times mounted */
-   uint32_t VolErrors;                /* Number of read/write errors */
-   uint32_t VolWrites;                /* Number of writes */
-   uint32_t VolReads;                 /* Number of reads */
-   uint64_t VolBytes;                 /* Number of bytes written */
-   uint64_t MaxVolBytes;              /* Max bytes to write to Volume */
-   uint64_t VolCapacityBytes;         /* capacity estimate */
-   uint64_t VolReadTime;              /* time spent reading volume */
-   uint64_t VolWriteTime;             /* time spent writing volume */
-   utime_t  VolRetention;             /* Volume retention in seconds */
-   utime_t  VolUseDuration;           /* time in secs volume can be used */
-   uint32_t MaxVolJobs;               /* Max Jobs on Volume */
-   uint32_t MaxVolFiles;              /* Max files on Volume */
-   int32_t  Recycle;                  /* recycle yes/no */
-   int32_t  Slot;                     /* slot in changer */
-   int32_t  InChanger;                /* Volume currently in changer */
-   char VolStatus[20];                /* Volume status */
+   DBId_t PoolId;                    /* Pool id */
+   time_t   FirstWritten;            /* Time Volume first written */
+   time_t   LastWritten;             /* Time Volume last written */
+   time_t   LabelDate;               /* Date/Time Volume labeled */
+   uint32_t VolJobs;                 /* number of jobs on this medium */
+   uint32_t VolFiles;                /* Number of files */
+   uint32_t VolBlocks;               /* Number of blocks */
+   uint32_t VolMounts;               /* Number of times mounted */
+   uint32_t VolErrors;               /* Number of read/write errors */
+   uint32_t VolWrites;               /* Number of writes */
+   uint32_t VolReads;                /* Number of reads */
+   uint64_t VolBytes;                /* Number of bytes written */
+   uint64_t MaxVolBytes;             /* Max bytes to write to Volume */
+   uint64_t VolCapacityBytes;        /* capacity estimate */
+   uint64_t VolReadTime;             /* time spent reading volume */
+   uint64_t VolWriteTime;            /* time spent writing volume */
+   utime_t  VolRetention;            /* Volume retention in seconds */
+   utime_t  VolUseDuration;          /* time in secs volume can be used */
+   uint32_t MaxVolJobs;              /* Max Jobs on Volume */
+   uint32_t MaxVolFiles;             /* Max files on Volume */
+   int32_t  Recycle;                 /* recycle yes/no */
+   int32_t  Slot;                    /* slot in changer */
+   int32_t  InChanger;               /* Volume currently in changer */
+   char VolStatus[20];               /* Volume status */
    /* Extra stuff not in DB */
-   faddr_t rec_addr;                  /* found record address */
+   faddr_t rec_addr;                 /* found record address */
    /* Since the database returns times as strings, this is how we pass
-    *   them back.
+    *  them back.
     */
    char    cFirstWritten[MAX_TIME_LENGTH]; /* FirstWritten returned from DB */
    char    cLastWritten[MAX_TIME_LENGTH];  /* LastWritten returned from DB */
@@ -542,12 +542,12 @@ struct MEDIA_DBR {
 
 /* Client record -- same as the database */
 struct CLIENT_DBR {
-   DBId_t ClientId;                   /* Unique Client id */
+   DBId_t ClientId;                  /* Unique Client id */
    int AutoPrune;
    utime_t FileRetention;
    utime_t JobRetention;
-   char Name[MAX_NAME_LENGTH];        /* Client name */
-   char Uname[256];                   /* Uname for client */
+   char Name[MAX_NAME_LENGTH];       /* Client name */
+   char Uname[256];                  /* Uname for client */
 };
 
 /* Counter record as in database */
@@ -562,16 +562,16 @@ struct COUNTER_DBR {
 
 /* FileSet record -- same as the database */
 struct FILESET_DBR {
-   DBId_t FileSetId;                  /* Unique FileSet id */
+   DBId_t FileSetId;                 /* Unique FileSet id */
    char FileSet[MAX_NAME_LENGTH];     /* FileSet name */
-   char MD5[50];                      /* MD5 signature of include/exclude */
-   time_t CreateTime;                 /* date created */
+   char MD5[50];                     /* MD5 signature of include/exclude */
+   time_t CreateTime;                /* date created */
    /*
     * This is where we return CreateTime
     */
    char cCreateTime[MAX_TIME_LENGTH]; /* CreateTime as returned from DB */
    /* Not in DB but returned by db_create_fileset() */
-   bool created;                      /* set when record newly created */
+   bool created;                     /* set when record newly created */
 };
 
 
index 9352f00ede97f38e1c5dc08642a1f43574a55098..8dc2711581a85fc920cc96e0905ba1d793adcb67 100644 (file)
@@ -136,18 +136,8 @@ db_open_database(JCR *jcr, B_DB *mdb)
 #endif
    mysql_init(&(mdb->mysql));
    Dmsg0(50, "mysql_init done\n");
-   mdb->db = mysql_real_connect(
-       &(mdb->mysql),                /* db */
-       mdb->db_address,              /* default = localhost */
-       mdb->db_user,                 /*  login name */
-       mdb->db_password,             /*  password */
-       mdb->db_name,                 /* database name */
-       mdb->db_port,                 /* default port */
-       mdb->db_socket,               /* default = socket */
-       CLIENT_FOUND_ROWS);           /* flags */
-
-   /* If no connect, try once more in case it is a timing problem */
-   if (mdb->db == NULL) {
+   /* If connection fails, try at 5 sec intervals for 30 seconds. */
+   for (int return=0; retry < 6; retry++) {
       mdb->db = mysql_real_connect(
           &(mdb->mysql),                /* db */
           mdb->db_address,              /* default = localhost */
@@ -157,6 +147,12 @@ db_open_database(JCR *jcr, B_DB *mdb)
           mdb->db_port,                 /* default port */
           mdb->db_socket,               /* default = socket */
           CLIENT_FOUND_ROWS);           /* flags */
+
+      /* If no connect, try once more in case it is a timing problem */
+      if (mdb->db != NULL) {
+        break;
+      }
+      bmicrosleep(5,0);
    }
     
    Dmsg0(50, "mysql_real_connect done\n");
index 9dfa401e3f4ea1d4c5ac8ef0050dce5c872b5258..360168288ec9eda88750c58ca898a83e5fa03d27 100644 (file)
@@ -124,7 +124,7 @@ db_open_database(JCR *jcr, B_DB *mdb)
       V(mutex);
       return 1;
    }
-   mdb->connected = FALSE;
+   mdb->connected = false;
 
    if ((errstat=rwl_init(&mdb->lock)) != 0) {
       Mmsg1(&mdb->errmsg, _("Unable to initialize DB lock. ERR=%s\n"), 
@@ -139,28 +139,26 @@ db_open_database(JCR *jcr, B_DB *mdb)
    } else {
       port = NULL;
    }
-   /* connect to the database */
-   mdb->db = PQsetdbLogin(
-       mdb->db_address,              /* default = localhost */
-       port,                         /* default port */
-       NULL,                         /* pg options */
-       NULL,                         /* tty, ignored */
-       mdb->db_name,                 /* database name */
-       mdb->db_user,                 /* login name */
-       mdb->db_password);            /* password */
-
-   /* If no connect, try once more in case it is a timing problem */
-   if (PQstatus(mdb->db) != CONNECTION_OK) {
-   mdb->db = PQsetdbLogin(
-       mdb->db_address,              /* default = localhost */
-       port,                         /* default port */
-       NULL,                         /* pg options */
-       NULL,                         /* tty, ignored */
-       mdb->db_name,                 /* database name */
-       mdb->db_user,                 /* login name */
-       mdb->db_password);            /* password */
+
+   /* If connection fails, try at 5 sec intervals for 30 seconds. */
+   for (int retry=0; retry < 6; retry++) {
+      /* connect to the database */
+      mdb->db = PQsetdbLogin(
+          mdb->db_address,           /* default = localhost */
+          port,                      /* default port */
+          NULL,                      /* pg options */
+          NULL,                      /* tty, ignored */
+          mdb->db_name,              /* database name */
+          mdb->db_user,              /* login name */
+          mdb->db_password);         /* password */
+
+      /* If no connect, try once more in case it is a timing problem */
+      if (PQstatus(mdb->db) == CONNECTION_OK) {
+        break;   
+      }
+      bmicrosleep(5, 0);
    }
-    
+
    Dmsg0(50, "pg_real_connect done\n");
    Dmsg3(50, "db_user=%s db_name=%s db_password=%s\n", mdb->db_user, mdb->db_name, 
             mdb->db_password==NULL?"(NULL)":mdb->db_password);
@@ -179,7 +177,7 @@ db_open_database(JCR *jcr, B_DB *mdb)
       return 0;
    }
 
-   mdb->connected = TRUE;
+   mdb->connected = true;
    V(mutex);
    return 1;
 }
@@ -219,6 +217,7 @@ db_close_database(JCR *jcr, B_DB *mdb)
       if (mdb->db_socket) {
         free(mdb->db_socket);
       }
+      my_postgresql_free_result(mdb);      
       free(mdb);
    }
    V(mutex);
@@ -297,7 +296,7 @@ int db_sql_query(B_DB *mdb, const char *query, DB_RESULT_HANDLER *result_handler
 
 POSTGRESQL_ROW my_postgresql_fetch_row(B_DB *mdb) 
 {
-   int           j;
+   int j;
    POSTGRESQL_ROW row = NULL; // by default, return NULL
 
    Dmsg0(500, "my_postgresql_fetch_row start\n");
@@ -306,9 +305,9 @@ POSTGRESQL_ROW my_postgresql_fetch_row(B_DB *mdb)
       Dmsg1(500, "we have need space of %d bytes\n", sizeof(char *) * mdb->num_fields);
 
       if (mdb->row != NULL) {
-              Dmsg0(500, "my_postgresql_fetch_row freeing space\n");
-             free(mdb->row);
-             mdb->row = NULL;
+         Dmsg0(500, "my_postgresql_fetch_row freeing space\n");
+        free(mdb->row);
+        mdb->row = NULL;
       }
 
       mdb->row = (POSTGRESQL_ROW) malloc(sizeof(char *) * mdb->num_fields);
@@ -322,8 +321,8 @@ POSTGRESQL_ROW my_postgresql_fetch_row(B_DB *mdb)
       Dmsg2(500, "my_postgresql_fetch_row row number '%d' is acceptable (0..%d)\n", mdb->row_number, mdb->num_rows);
       // get each value from this row
       for (j = 0; j < mdb->num_fields; j++) {
-             mdb->row[j] = PQgetvalue(mdb->result, mdb->row_number, j);
-              Dmsg2(500, "my_postgresql_fetch_row field '%d' has value '%s'\n", j, mdb->row[j]);
+        mdb->row[j] = PQgetvalue(mdb->result, mdb->row_number, j);
+         Dmsg2(500, "my_postgresql_fetch_row field '%d' has value '%s'\n", j, mdb->row[j]);
       }
       // increment the row number for the next call
       mdb->row_number++;
@@ -342,9 +341,9 @@ int my_postgresql_max_length(B_DB *mdb, int field_num) {
    //
    // for a given column, find the max length
    //
-   int    max_length;
+   int max_length;
    int i;
-   int    this_length;
+   int this_length;
 
    max_length = 0;
    for (i = 0; i < mdb->num_rows; i++) {
@@ -402,6 +401,10 @@ void my_postgresql_field_seek(B_DB *mdb, int field)
    mdb->field_number = field;
 }
 
+/*
+ * Note, if this routine returns 1 (failure), Bacula expects
+ *  that no result has been stored.
+ */
 int my_postgresql_query(B_DB *mdb, char *query) {
    Dmsg0(500, "my_postgresql_query started\n");
    // We are starting a new query.  reset everything.
@@ -409,6 +412,9 @@ int my_postgresql_query(B_DB *mdb, char *query) {
    mdb->row_number   = -1;
    mdb->field_number = -1;
 
+   if (mdb->result != NULL) {
+      PQclear(mdb->result);  /* hmm, someone forgot to free?? */
+   }
 
    Dmsg1(500, "my_postgresql_query starts with '%s'\n", query);
    mdb->result = PQexec(mdb->db, query);
@@ -438,6 +444,7 @@ void my_postgresql_free_result (B_DB *mdb)
 {
    if (mdb->result) {
       PQclear(mdb->result);
+      mdb->result = NULL;
    }
 
    if (mdb->row) {
index cf5da1558e8b7c26dd1dc247a007529f81a02b96..2d0187fa76833ba51797652750073575762e08bd 100644 (file)
@@ -177,9 +177,7 @@ db_create_pool_record(JCR *jcr, B_DB *mdb, POOL_DBR *pr)
    Dmsg1(200, "selectpool: %s\n", mdb->cmd);
 
    if (QUERY_DB(jcr, mdb, mdb->cmd)) {
-
       mdb->num_rows = sql_num_rows(mdb);
-   
       if (mdb->num_rows > 0) {
          Mmsg1(&mdb->errmsg, _("pool record %s already exists\n"), pr->Name);
         sql_free_result(mdb);
@@ -319,9 +317,7 @@ int db_create_client_record(JCR *jcr, B_DB *mdb, CLIENT_DBR *cr)
 
    cr->ClientId = 0;
    if (QUERY_DB(jcr, mdb, mdb->cmd)) {
-
       mdb->num_rows = sql_num_rows(mdb);
-      
       /* If more than one, report error, but return first row */
       if (mdb->num_rows > 1) {
          Mmsg1(&mdb->errmsg, _("More than one Client!: %d\n"), (int)(mdb->num_rows));
@@ -427,9 +423,7 @@ int db_create_fileset_record(JCR *jcr, B_DB *mdb, FILESET_DBR *fsr)
 
    fsr->FileSetId = 0;
    if (QUERY_DB(jcr, mdb, mdb->cmd)) {
-
       mdb->num_rows = sql_num_rows(mdb);
-      
       if (mdb->num_rows > 1) {
          Mmsg1(&mdb->errmsg, _("More than one FileSet!: %d\n"), (int)(mdb->num_rows));
          Jmsg(jcr, M_ERROR, 0, "%s", mdb->errmsg);
@@ -635,7 +629,6 @@ static int db_create_path_record(JCR *jcr, B_DB *mdb, ATTR_DBR *ar)
         ASSERT(ar->PathId);
         return 1;
       }
-
       sql_free_result(mdb);
    }
 
index 31dd629a4af769f3240545c0e41cebab9dddbc60..a74cfd2048614fb76f6f45c77457a9028ddb4250 100644 (file)
@@ -97,7 +97,7 @@ db_find_job_start_time(JCR *jcr, B_DB *mdb, JOB_DBR *jr, POOLMEM **stime)
         }
         if ((row = sql_fetch_row(mdb)) == NULL) {
            sql_free_result(mdb);
-               Mmsg(&mdb->errmsg, _("No prior Full backup Job record found.\n"));
+            Mmsg(&mdb->errmsg, _("No prior Full backup Job record found.\n"));
            db_unlock(mdb);
            return 0;
         }
index 1172cfd88e189575832a17a395d2993e70e10c34..85689733d3cef73677429cc77ebcba9f17ca733b 100644 (file)
@@ -122,10 +122,8 @@ int db_get_file_record(JCR *jcr, B_DB *mdb, JOB_DBR *jr, FILE_DBR *fdbr)
    Dmsg1(100, "Query=%s\n", mdb->cmd);
 
    if (QUERY_DB(jcr, mdb, mdb->cmd)) {
-
       mdb->num_rows = sql_num_rows(mdb);
       Dmsg1(050, "get_file_record num_rows=%d\n", (int)mdb->num_rows);
-
       if (mdb->num_rows > 1) {
          Mmsg1(&mdb->errmsg, _("get_file_record want 1 got rows=%d\n"),
            mdb->num_rows);
@@ -168,9 +166,7 @@ static int db_get_filename_record(JCR *jcr, B_DB *mdb)
    Mmsg(&mdb->cmd, "SELECT FilenameId FROM Filename WHERE Name='%s'", mdb->esc_name);
    if (QUERY_DB(jcr, mdb, mdb->cmd)) {
       char ed1[30];
-
       mdb->num_rows = sql_num_rows(mdb);
-
       if (mdb->num_rows > 1) {
          Mmsg2(&mdb->errmsg, _("More than one Filename!: %s for file: %s\n"),
            edit_uint64(mdb->num_rows, ed1), mdb->fname);
@@ -221,7 +217,6 @@ static int db_get_path_record(JCR *jcr, B_DB *mdb)
    if (QUERY_DB(jcr, mdb, mdb->cmd)) {
       char ed1[30];
       mdb->num_rows = sql_num_rows(mdb);
-
       if (mdb->num_rows > 1) {
          Mmsg2(&mdb->errmsg, _("More than one Path!: %s for path: %s\n"),
            edit_uint64(mdb->num_rows, ed1), mdb->path);
@@ -651,7 +646,6 @@ int db_get_counter_record(JCR *jcr, B_DB *mdb, COUNTER_DBR *cr)
       "FROM Counters WHERE Counter='%s'", cr->Counter);
 
    if (QUERY_DB(jcr, mdb, mdb->cmd)) {
-
       mdb->num_rows = sql_num_rows(mdb);
       
       /* If more than one, report error, but return first row */
index db0914a1da24f031e2af9eaae240e9401bd33201..7a3d46b421f088386bbc89c1196559d8e20900ab 100644 (file)
@@ -341,7 +341,7 @@ void my_sqlite_free_table(B_DB *mdb)
         free(mdb->fields[i]);
       }
       free(mdb->fields);
-      mdb->fields_defined = FALSE;
+      mdb->fields_defined = false;
    }
    sqlite_free_table(mdb->result);
    mdb->nrow = mdb->ncolumn = 0; 
index b4c26c3f8bf4ff58759e554351a21a28da211574..45cc42e6a4fb147f490f531ea5ebbf998b38bd45 100644 (file)
@@ -28,6 +28,9 @@
 
 #include "bacula.h"
 #include "dird.h"
+#ifdef HAVE_REGEX_H
+#include <regex.h>
+#endif
 
 /* Forward referenced subroutines */
 
@@ -442,7 +445,9 @@ static void store_newinc(LEX *lc, RES_ITEM *item, int index, int pass)
 /* Store regex info */
 static void store_regex(LEX *lc, RES_ITEM *item, int index, int pass)
 {
-   int token;
+   int token, rc;
+   regex_t preg;
+   char prbuf[500];
 
    if (pass == 1) {
       /* Pickup regex string
@@ -452,6 +457,14 @@ static void store_regex(LEX *lc, RES_ITEM *item, int index, int pass)
       case T_IDENTIFIER:
       case T_UNQUOTED_STRING:
       case T_QUOTED_STRING:
+        rc = regcomp(&preg, lc->str, REG_EXTENDED);
+        if (rc != 0) {
+           regerror(rc, &preg, prbuf, sizeof(prbuf));
+           regfree(&preg);
+            scan_err1(lc, _("Regex compile error. ERR=%s\n"), prbuf);
+           break;
+        }
+        regfree(&preg);
         res_incexe.current_opts->regex.append(bstrdup(lc->str));
          Dmsg3(900, "set regex %p size=%d %s\n", 
            res_incexe.current_opts, res_incexe.current_opts->regex.size(),lc->str);
index 5cdc25b9e6e53aeccf7566ea4f44ca7aaf3f36e8..819fd6e64fd21f25e52e27ebfce8b6760dcba57b 100644 (file)
@@ -472,17 +472,17 @@ static int save_file(FF_PKT *ff_pkt, void *vjcr)
    
 #ifdef HAVE_ACL
    /* ACL stream */
-   if(ff_pkt->flags & FO_ACL) {
+   if (ff_pkt->flags & FO_ACL) {
       char *acl_text;
       /* Read ACLs for files, dirs and links */
-      if(ff_pkt->type == FT_DIREND) {
+      if (ff_pkt->type == FT_DIREND) {
         /* Directory: Try for default ACL*/
         acl_t myAcl = acl_get_file(ff_pkt->fname, ACL_TYPE_DEFAULT);
-        if(!myAcl) {
+        if (!myAcl) {
             Dmsg1(200, "No default ACL defined for directory: %s!\n", ff_pkt->fname);
            /* If there is no default ACL get standard ACL */
            myAcl = acl_get_file(ff_pkt->fname, ACL_TYPE_ACCESS);
-           if(!myAcl) {
+           if (!myAcl) {
                Emsg1(M_WARNING, 0, "Error while trying to get ACL of directory: %s!\n", ff_pkt->fname);
            }
         }
@@ -492,7 +492,7 @@ static int save_file(FF_PKT *ff_pkt, void *vjcr)
       } else {
         /* Files or links */
         acl_t myAcl = acl_get_file(ff_pkt->fname, ACL_TYPE_ACCESS);
-        if(!myAcl) {
+        if (!myAcl) {
             Emsg1(M_WARNING, 0, "Error while trying to get ACL of file: %s!\n", ff_pkt->fname);
            acl_free(myAcl);
         }
@@ -500,41 +500,41 @@ static int save_file(FF_PKT *ff_pkt, void *vjcr)
         acl_free(myAcl);
       }
       
-      /* Send stream to server */
-      sd = jcr->store_bsock;
+      /* If there is an ACL, send it to the Storage daemon */
+      if (acl_text) {
+        sd = jcr->store_bsock;
+        pm_strcpy(&jcr->last_fname, ff_pkt->fname);
       
-      msgsave = sd->msg;
-      
-      pm_strcpy(&jcr->last_fname, ff_pkt->fname);
-      
-      /*
-      * Send ACL header
-      *
-      */
-      if(!bnet_fsend(sd, "%ld %d 0", jcr->JobFiles, STREAM_UNIX_ATTRIBUTES_ACL)) {
-        set_jcr_job_status(jcr, JS_ErrorTerminated);
-        return 0;
-      }
+        /*
+        * Send ACL header
+        *
+        */
+         if (!bnet_fsend(sd, "%ld %d 0", jcr->JobFiles, STREAM_UNIX_ATTRIBUTES_ACL)) {
+           set_jcr_job_status(jcr, JS_ErrorTerminated);
+           return 0;
+        }
       
-      /* Send the buffer to the storage deamon */
-      sd->msg = acl_text;
-      sd->msglen = strlen(acl_text) + 1;
-      if(!bnet_send(sd)) {
-        sd->msg = msgsave;
-        sd->msglen = 0;
-        bclose(&ff_pkt->bfd);
-        set_jcr_job_status(jcr, JS_ErrorTerminated);
-         Emsg1(M_WARNING, 0, "Error while trying to send ACL of %s to SD!\n", ff_pkt->fname);
-      } else {
-        jcr->JobBytes += sd->msglen;
-        sd->msg = msgsave;
-        bclose(&ff_pkt->bfd);
-        if(!bnet_sig(sd, BNET_EOD)) {
+        /* Send the buffer to the storage deamon */
+        msgsave = sd->msg;
+        sd->msg = acl_text;
+        sd->msglen = strlen(acl_text) + 1;
+        if (!bnet_send(sd)) {
+           sd->msg = msgsave;
+           sd->msglen = 0;
+           bclose(&ff_pkt->bfd);
            set_jcr_job_status(jcr, JS_ErrorTerminated);
+            Emsg1(M_WARNING, 0, "Error while trying to send ACL of %s to SD!\n", ff_pkt->fname);
         } else {
-            Dmsg1(200, "ACL of file: %s successfully backed up!\n", ff_pkt->fname);
-        }
-      }  
+           jcr->JobBytes += sd->msglen;
+           sd->msg = msgsave;
+           bclose(&ff_pkt->bfd);
+           if (!bnet_sig(sd, BNET_EOD)) {
+              set_jcr_job_status(jcr, JS_ErrorTerminated);
+           } else {
+               Dmsg1(200, "ACL of file: %s successfully backed up!\n", ff_pkt->fname);
+           }
+        }  
+      }
    }
 #endif
 
index a73011ae7f7dc868095bbdd803eb527462e51047..e83250e8c9aabfb6d800a581bb243307ef2e06b0 100644 (file)
@@ -23,6 +23,7 @@ FileDaemon {                          # this is me
   FDport = @fd_port@                  # where we listen for the director
   WorkingDirectory = @working_dir@
   Pid Directory = @piddir@
+  Maximum Concurrent Jobs = 1
 }
 
 # Send all messages except skipped files back to Director
index adf7c3364fcdb30ac7ce83efc554ff3dcfb7cf31..40bb9152c65d1b430d0c891cdce28f5de1628082 100644 (file)
@@ -32,6 +32,9 @@
 /* Imported Functions */
 extern void *handle_client_request(void *dir_sock);
 
+/* Imported Variables */
+extern time_t watchdog_sleep_time;
+
 /* Forward referenced functions */
 void terminate_filed(int sig);
 
@@ -40,7 +43,6 @@ CLIENT *me;                         /* my resource */
 char OK_msg[]   = "2000 OK\n";
 char TERM_msg[] = "2999 Terminate\n";
 
-
 #if defined(HAVE_CYGWIN) || defined(HAVE_WIN32)
 const int win32_client = 1;
 #else
@@ -51,8 +53,8 @@ const int win32_client = 0;
 #define CONFIG_FILE "./bacula-fd.conf" /* default config file */
 
 static char *configfile = NULL;
-static int foreground = 0;
-static int inetd_request = 0;
+static bool foreground = false;
+static bool inetd_request = false;
 static workq_t dir_workq;            /* queue of work from Director */
 static pthread_t server_tid;
 
@@ -89,8 +91,8 @@ static void usage()
 int main (int argc, char *argv[])
 {
    int ch;
-   int no_signals = FALSE;
-   int test_config = FALSE;
+   bool no_signals = false;
+   bool test_config = false;
    DIRRES *director;
    char *uid = NULL;
    char *gid = NULL;
@@ -118,7 +120,7 @@ int main (int argc, char *argv[])
         break;
 
       case 'f':                    /* run in foreground */
-        foreground = TRUE;
+        foreground = true;
         break;
 
       case 'g':                    /* set group */
@@ -126,14 +128,14 @@ int main (int argc, char *argv[])
         break;
 
       case 'i':
-        inetd_request = TRUE;
+        inetd_request = true;
         break;
       case 's':
-        no_signals = TRUE;
+        no_signals = true;
         break;
 
       case 't':
-        test_config = TRUE;
+        test_config = true;
         break;
 
       case 'u':                    /* set userid */
@@ -166,6 +168,9 @@ int main (int argc, char *argv[])
 
    if (!no_signals) {
       init_signals(terminate_filed);
+   } else {
+      /* This reduces the number of signals facilitating debugging */
+      watchdog_sleep_time = 120;      /* long timeout for debugging */
    }
 
    if (configfile == NULL) {
@@ -225,9 +230,10 @@ Without that I don't know who I am :-(\n"), configfile);
 
    set_thread_concurrency(10);
 
-   start_watchdog();                 /* start watchdog thread */
-
-   init_jcr_subsystem();             /* start JCR watchdogs etc. */
+   if (!no_signals) {
+      start_watchdog();              /* start watchdog thread */
+      init_jcr_subsystem();          /* start JCR watchdogs etc. */
+   }
    server_tid = pthread_self();
 
    if (inetd_request) {
index dadea8b1421ae51ca2d3a3f1f019223b0540f8b9..09ea2129587a713dc7ab5a38bbe22bdf91dc39f3 100644 (file)
@@ -226,12 +226,15 @@ void *handle_client_request(void *dirp)
    FF_PKT *ff = (FF_PKT *)jcr->ff;
    findFILESET *fileset = ff->fileset;
    if (fileset) {
-      int i, j;
+      int i, j, k;
       /* Delete FileSet Include lists */
       for (i=0; i<fileset->include_list.size(); i++) {
         findINCEXE *incexe = (findINCEXE *)fileset->include_list.get(i);
         for (j=0; j<incexe->opts_list.size(); j++) {
            findFOPTS *fo = (findFOPTS *)incexe->opts_list.get(j);
+           for (k=0; k<fo->regex.size(); k++) {
+              regfree((regex_t *)fo->regex.get(k));
+           }
            fo->regex.destroy();
            fo->wild.destroy();
            fo->base.destroy();
@@ -711,7 +714,20 @@ static void add_fileset(JCR *jcr, const char *item)
       break;
    case 'R':
       current_opts = start_options(ff);
-      current_opts->regex.append(bstrdup(item));
+      regex_t *preg;
+      int rc;
+      char prbuf[500];
+      preg = (regex_t *)malloc(sizeof(regex_t));
+      rc = regcomp(preg, item, REG_EXTENDED);
+      if (rc != 0) {
+        regerror(rc, preg, prbuf, sizeof(prbuf));
+        regfree(preg);
+        free(preg);
+         Jmsg(jcr, M_FATAL, 0, "REGEX %s compile error. ERR=%s\n", item, prbuf);
+        state = state_error;
+        break;
+      }
+      current_opts->regex.append(preg);
       state = state_options;
       break;
    case 'B':
index 1ad10c0179a638cc70fcddf769928376c5a0dd95..f2354234be72148b1e6e1328d933741f1ea5eff6 100644 (file)
@@ -315,34 +315,30 @@ void do_restore(JCR *jcr)
 #endif
         break;
 
-#ifdef HAVE_ACL
       case STREAM_UNIX_ATTRIBUTES_ACL:  
+#ifdef HAVE_ACL
         /* Recover ACL from stream and check it */
         acl = acl_from_text(sd->msg);
-        if(acl_valid(acl) != 0) {
+        if (acl_valid(acl) != 0) {
             Emsg1(M_WARNING, 0, "Failure in the ACL of %s! FD is not able to restore it!\n", jcr->last_fname);
            acl_free(acl);
         }
         
         /* Try to restore ACL */
-        if(attr->type == FT_DIREND) {
+        if (attr->type == FT_DIREND) {
            /* Directory */
-           if(acl_set_file(jcr->last_fname, ACL_TYPE_DEFAULT, acl) != 0) {
-              if(acl_set_file(jcr->last_fname, ACL_TYPE_ACCESS, acl) != 0) {
-                  Emsg1(M_WARNING, 0, "Error! Can't restore ACL of directory: %s! Maybe system does not support ACLs!\n", jcr->last_fname);
-              }
-           }
-        } else {
-           /* File or Link */
-           if(acl_set_file(jcr->last_fname, ACL_TYPE_ACCESS, acl) != 0) {
-               Emsg1(M_WARNING, 0, "Error! Can't restore ACL of file: %s! Maybe system does not support ACLs!\n", jcr->last_fname);
+           if (acl_set_file(jcr->last_fname, ACL_TYPE_DEFAULT, acl) != 0 &&
+               acl_set_file(jcr->last_fname, ACL_TYPE_ACCESS, acl) != 0) {
+               Emsg1(M_WARNING, 0, "Error! Can't restore ACL of directory: %s! Maybe system does not support ACLs!\n", jcr->last_fname);
            }
+        /* File or Link */
+        } else if (acl_set_file(jcr->last_fname, ACL_TYPE_ACCESS, acl) != 0) {
+            Emsg1(M_WARNING, 0, "Error! Can't restore ACL of file: %s! Maybe system does not support ACLs!\n", jcr->last_fname);
         }
         acl_free(acl);
          Dmsg1(200, "ACL of file: %s successfully restored!", jcr->last_fname);
         break;
 #else 
-      case STREAM_UNIX_ATTRIBUTES_ACL:  
         non_support_acl++;
         break;                       /* unconfigured, ignore */
 #endif  
index b74f90c2d4561a793343996b29273c708b4d9ab5..f3d4ef93190a26dda469b8ed09bdc34073a3c168 100644 (file)
@@ -28,7 +28,6 @@
 #include "bacula.h"
 #include "find.h"
 
-
 int32_t name_max;             /* filename max length */
 int32_t path_max;             /* path name max length */
 
@@ -170,6 +169,18 @@ static bool accept_file(FF_PKT *ff)
            return true;              /* accept file */
         }
       }
+      for (k=0; k<fo->regex.size(); k++) {
+        const int nmatch = 30;
+        regmatch_t pmatch[nmatch];
+        if (regexec((regex_t *)fo->regex.get(k), ff->fname, nmatch, pmatch,  0) == 0) {
+           ff->flags = fo->flags;
+           ff->GZIP_level = fo->GZIP_level;
+           if (ff->flags & FO_EXCLUDE) {
+              return false;          /* reject file */
+           }
+           return true;              /* accept file */
+        }
+      }
    }
 
    for (i=0; i<fileset->exclude_list.size(); i++) {
index 7bdf0c2778ce83aa0992a5370f3ff3ff935c9c82..1bf334c1250b5f78afb7dcbeb8607b103d0ca134 100755 (executable)
@@ -52,6 +52,10 @@ struct utimbuf {
 #include "lib/fnmatch.h"
 #endif
 
+#ifdef HAVE_REGEX_H
+#include <regex.h>
+#endif
+
 #include "save-cwd.h"
 
 #ifndef HAVE_READDIR_R
@@ -63,38 +67,38 @@ int readdir_r(DIR *dirp, struct dirent *entry, struct dirent **result);
  * Status codes returned by create_file()
  */
 enum {
-   CF_SKIP = 1,                       /* skip file (not newer or something) */
-   CF_ERROR,                          /* error creating file */
-   CF_EXTRACT,                        /* file created, data to extract */
-   CF_CREATED                         /* file created, no data to extract */
+   CF_SKIP = 1,                      /* skip file (not newer or something) */
+   CF_ERROR,                         /* error creating file */
+   CF_EXTRACT,                       /* file created, data to extract */
+   CF_CREATED                        /* file created, no data to extract */
 };
 
 
 /* Options saved int "options" of the include/exclude lists.
  * They are directly jammed ito  "flag" of ff packet 
  */
-#define FO_MD5          (1<<1)        /* Do MD5 checksum */
-#define FO_GZIP         (1<<2)        /* Do Zlib compression */
-#define FO_NO_RECURSION (1<<3)        /* no recursion in directories */
-#define FO_MULTIFS      (1<<4)        /* multiple file systems */
-#define FO_SPARSE       (1<<5)        /* do sparse file checking */
-#define FO_IF_NEWER     (1<<6)        /* replace if newer */
-#define FO_NOREPLACE    (1<<7)        /* never replace */
-#define FO_READFIFO     (1<<8)        /* read data from fifo */
-#define FO_SHA1         (1<<9)        /* Do SHA1 checksum */
-#define FO_PORTABLE     (1<<10)       /* Use portable data format -- no BackupWrite */
-#define FO_MTIMEONLY    (1<<11)       /* Use mtime rather than mtime & ctime */
-#define FO_KEEPATIME    (1<<12)       /* Reset access time */
-#define FO_EXCLUDE      (1<<13)       /* Exclude file */
-#define FO_ACL         (1<<14)         /* Backup ACLs */
+#define FO_MD5         (1<<1)        /* Do MD5 checksum */
+#define FO_GZIP        (1<<2)        /* Do Zlib compression */
+#define FO_NO_RECURSION (1<<3)       /* no recursion in directories */
+#define FO_MULTIFS     (1<<4)        /* multiple file systems */
+#define FO_SPARSE      (1<<5)        /* do sparse file checking */
+#define FO_IF_NEWER    (1<<6)        /* replace if newer */
+#define FO_NOREPLACE   (1<<7)        /* never replace */
+#define FO_READFIFO    (1<<8)        /* read data from fifo */
+#define FO_SHA1        (1<<9)        /* Do SHA1 checksum */
+#define FO_PORTABLE    (1<<10)       /* Use portable data format -- no BackupWrite */
+#define FO_MTIMEONLY   (1<<11)       /* Use mtime rather than mtime & ctime */
+#define FO_KEEPATIME   (1<<12)       /* Reset access time */
+#define FO_EXCLUDE     (1<<13)       /* Exclude file */
+#define FO_ACL         (1<<14)         /* Backup ACLs */
 
 struct s_included_file {
    struct s_included_file *next;
-   uint32_t options;                  /* backup options */
-   int level;                         /* compression level */
-   int len;                           /* length of fname */
-   int pattern;                       /* set if wild card pattern */
-   char VerifyOpts[20];               /* Options for verify */
+   uint32_t options;                 /* backup options */
+   int level;                        /* compression level */
+   int len;                          /* length of fname */
+   int pattern;                      /* set if wild card pattern */
+   char VerifyOpts[20];              /* Options for verify */
    char fname[1];
 };
 
@@ -109,7 +113,7 @@ struct s_excluded_file {
  *  of the structure are passed by the Director to the
  *  File daemon and recompiled back into this structure
  */
-#undef  MAX_FOPTS 
+#undef MAX_FOPTS 
 #define MAX_FOPTS 30
 
 enum {
@@ -121,20 +125,20 @@ enum {
 
 /* File options structure */
 struct findFOPTS {
-   uint32_t flags;                    /* options in bits */
-   int GZIP_level;                    /* GZIP level */
-   char VerifyOpts[MAX_FOPTS];        /* verify options */
-   alist regex;                       /* regex string(s) */
-   alist wild;                        /* wild card strings */
-   alist base;                        /* list of base names */
+   uint32_t flags;                   /* options in bits */
+   int GZIP_level;                   /* GZIP level */
+   char VerifyOpts[MAX_FOPTS];       /* verify options */
+   alist regex;                      /* regex string(s) */
+   alist wild;                       /* wild card strings */
+   alist base;                       /* list of base names */
 };
 
 
 /* This is either an include item or an exclude item */
 struct findINCEXE {
-   findFOPTS *current_opts;           /* points to current options structure */
-   alist opts_list;                   /* options list */
-   alist name_list;                   /* filename list -- holds char * */
+   findFOPTS *current_opts;          /* points to current options structure */
+   alist opts_list;                  /* options list */
+   alist name_list;                  /* filename list -- holds char * */
 };
 
 /* 
@@ -143,7 +147,7 @@ struct findINCEXE {
  */
 struct findFILESET {
    int state;
-   findINCEXE *incexe;                /* current item */
+   findINCEXE *incexe;               /* current item */
    alist include_list;
    alist exclude_list;
 };
@@ -154,22 +158,22 @@ struct findFILESET {
  * first argument to the find_files callback subroutine.
  */
 struct FF_PKT {
-   char *fname;                       /* filename */
-   char *link;                        /* link if file linked */
-   POOLMEM *sys_fname;                /* system filename */
-   struct stat statp;                 /* stat packet */
-   int32_t FileIndex;                 /* FileIndex of this file */
-   int32_t LinkFI;                    /* FileIndex of main hard linked file */
-   struct f_link *linked;             /* Set if this file is hard linked */
-   int type;                          /* FT_ type from above */
-   uint32_t flags;                    /* backup options */
-   int ff_errno;                      /* errno */
-   BFILE bfd;                         /* Bacula file descriptor */
-   time_t save_time;                  /* start of incremental time */
-   bool dereference;                  /* follow links (not implemented) */
-   bool null_output_device;           /* using null output device */
-   bool incremental;                  /* incremental save */
-   int GZIP_level;                    /* compression level */
+   char *fname;                      /* filename */
+   char *link;                       /* link if file linked */
+   POOLMEM *sys_fname;               /* system filename */
+   struct stat statp;                /* stat packet */
+   int32_t FileIndex;                /* FileIndex of this file */
+   int32_t LinkFI;                   /* FileIndex of main hard linked file */
+   struct f_link *linked;            /* Set if this file is hard linked */
+   int type;                         /* FT_ type from above */
+   uint32_t flags;                   /* backup options */
+   int ff_errno;                     /* errno */
+   BFILE bfd;                        /* Bacula file descriptor */
+   time_t save_time;                 /* start of incremental time */
+   bool dereference;                 /* follow links (not implemented) */
+   bool null_output_device;          /* using null output device */
+   bool incremental;                 /* incremental save */
+   int GZIP_level;                   /* compression level */
    char VerifyOpts[20];
    struct s_included_file *included_files_list;
    struct s_excluded_file *excluded_files_list;
@@ -178,7 +182,7 @@ struct FF_PKT {
    int (*callback)(FF_PKT *, void *); /* User's callback */
 
    /* List of all hard linked files found */
-   struct f_link *linklist;           /* hard linked files */
+   struct f_link *linklist;          /* hard linked files */
 };
 
 
index 70f39143bfb52eed87a0c7348009c0bffec6d088..15db3d006fab75c30b34814d17705b21d4e52b90 100644 (file)
 extern time_t watchdog_time;
 
 #ifndef   INADDR_NONE
-#define   INADDR_NONE   -1
+#define   INADDR_NONE    -1
 #endif
 
-#ifndef ENODATA                      /* not defined on BSD systems */
+#ifndef ENODATA                       /* not defined on BSD systems */
 #define ENODATA EPIPE
 #endif
 
 #ifdef HAVE_WIN32
 #define socketRead(fd, buf, len)  recv(fd, buf, len, 0)
 #define socketWrite(fd, buf, len) send(fd, buf, len, 0)
-#define socketClose(fd)          closesocket(fd)
+#define socketClose(fd)           closesocket(fd)
 #else
 #define socketRead(fd, buf, len)  read(fd, buf, len)
 #define socketWrite(fd, buf, len) write(fd, buf, len)
-#define socketClose(fd)          close(fd)
+#define socketClose(fd)           close(fd)
 #endif
 
 
@@ -67,19 +67,19 @@ static int32_t read_nbytes(BSOCK *bsock, char *ptr, int32_t nbytes)
    nleft = nbytes;
    while (nleft > 0) {
       do {
-        errno = 0;
-        nread = socketRead(bsock->fd, ptr, nleft);      
-        if (bsock->timed_out || bsock->terminated) {
-           return nread;
-        }
+         errno = 0;
+         nread = socketRead(bsock->fd, ptr, nleft);      
+         if (bsock->timed_out || bsock->terminated) {
+            return nread;
+         }
       } while (nread == -1 && (errno == EINTR || errno == EAGAIN));
       if (nread <= 0) {
-        return nread;               /* error, or EOF */
+         return nread;               /* error, or EOF */
       }
       nleft -= nread;
       ptr += nread;
    }
-   return nbytes - nleft;           /* return >= 0 */
+   return nbytes - nleft;            /* return >= 0 */
 }
 
 /*
@@ -96,18 +96,18 @@ static int32_t write_nbytes(BSOCK *bsock, char *ptr, int32_t nbytes)
       if (nwritten != nbytes) {
          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;
+         return -1;
       }
       return nbytes;
    }
    nleft = nbytes;
    while (nleft > 0) {
       do {
-        errno = 0;
-        nwritten = socketWrite(bsock->fd, ptr, nleft);
-        if (bsock->timed_out || bsock->terminated) {
-           return nwritten;
-        }
+         errno = 0;
+         nwritten = socketWrite(bsock->fd, ptr, nleft);
+         if (bsock->timed_out || bsock->terminated) {
+            return nwritten;
+         }
       } while (nwritten == -1 && errno == EINTR);
       /*
        * If connection is non-blocking, we will get EAGAIN, so
@@ -115,18 +115,18 @@ static int32_t write_nbytes(BSOCK *bsock, char *ptr, int32_t nbytes)
        * and try again.
        */
       if (nwritten == -1 && errno == EAGAIN) {
-        fd_set fdset;
-        struct timeval tv;
-
-        FD_ZERO(&fdset);
-        FD_SET((unsigned)bsock->fd, &fdset);
-        tv.tv_sec = 10;
-        tv.tv_usec = 0;
-        select(bsock->fd + 1, NULL, &fdset, NULL, &tv);
-        continue;
+         fd_set fdset;
+         struct timeval tv;
+
+         FD_ZERO(&fdset);
+         FD_SET((unsigned)bsock->fd, &fdset);
+         tv.tv_sec = 10;
+         tv.tv_usec = 0;
+         select(bsock->fd + 1, NULL, &fdset, NULL, &tv);
+         continue;
       }
       if (nwritten <= 0) {
-        return nwritten;            /* error */
+         return nwritten;            /* error */
       }
       nleft -= nwritten;
       ptr += nwritten;
@@ -141,13 +141,13 @@ static int32_t write_nbytes(BSOCK *bsock, char *ptr, int32_t nbytes)
  * Returns number of bytes read (may return zero)
  * Returns -1 on signal (BNET_SIGNAL) 
  * Returns -2 on hard end of file (BNET_HARDEOF)
- * Returns -3 on error (BNET_ERROR)
+ * Returns -3 on error  (BNET_ERROR)
  *
  *  Unfortunately, it is a bit complicated because we have these
  *    four return types:
  *    1. Normal data
  *    2. Signal including end of data stream
- *    3. Hard end of file                
+ *    3. Hard end of file                 
  *    4. Error
  *  Using is_bnet_stop() and is_bnet_error() you can figure this all out.
  */
@@ -162,54 +162,54 @@ int32_t bnet_recv(BSOCK *bsock)
       return BNET_HARDEOF;
    }
 
-   bsock->read_seqno++;              /* bump sequence number */
-   bsock->timer_start = watchdog_time; /* set start wait time */
+   bsock->read_seqno++;               /* bump sequence number */
+   bsock->timer_start = watchdog_time;  /* set start wait time */
    bsock->timed_out = 0;
    /* get data size -- in int32_t */
    if ((nbytes = read_nbytes(bsock, (char *)&pktsiz, sizeof(int32_t))) <= 0) {
-      bsock->timer_start = 0;        /* clear timer */
+      bsock->timer_start = 0;         /* clear timer */
       /* probably pipe broken because client died */
       if (errno == 0) {
-        bsock->b_errno = ENODATA;
+         bsock->b_errno = ENODATA;
       } else {
-        bsock->b_errno = errno;
+         bsock->b_errno = errno;
       }
       bsock->errors++;
-      return BNET_HARDEOF;           /* assume hard EOF received */
+      return BNET_HARDEOF;            /* assume hard EOF received */
    }
-   bsock->timer_start = 0;           /* clear timer */
+   bsock->timer_start = 0;            /* clear timer */
    if (nbytes != sizeof(int32_t)) {
       bsock->errors++;
       bsock->b_errno = EIO;
       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);
+            sizeof(int32_t), nbytes, bsock->who, bsock->host, bsock->port);
       return BNET_ERROR;
    }
 
-   pktsiz = ntohl(pktsiz);           /* decode no. of bytes that follow */
+   pktsiz = ntohl(pktsiz);            /* decode no. of bytes that follow */
 
-   if (pktsiz == 0) {                /* No data transferred */
-      bsock->timer_start = 0;        /* clear timer */
+   if (pktsiz == 0) {                 /* No data transferred */
+      bsock->timer_start = 0;         /* clear timer */
       bsock->in_msg_no++;
       bsock->msglen = 0;
-      return 0;                      /* zero bytes read */
+      return 0;                       /* zero bytes read */
    }
 
    /* If signal or packet size too big */
    if (pktsiz < 0 || pktsiz > 1000000) {
-      if (pktsiz > 0) {              /* if packet too big */
-        Qmsg3(bsock->jcr, M_FATAL, 0, 
+      if (pktsiz > 0) {               /* if packet too big */
+         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 */
+            bsock->who, bsock->host, bsock->port);
+         pktsiz = BNET_TERMINATE;     /* hang up */
       }
       if (pktsiz == BNET_TERMINATE) {
-        bsock->terminated = 1;
+         bsock->terminated = 1;
       }
-      bsock->timer_start = 0;        /* clear timer */
+      bsock->timer_start = 0;         /* clear timer */
       bsock->b_errno = ENODATA;
-      bsock->msglen = pktsiz;        /* signal code */
-      return BNET_SIGNAL;            /* signal */
+      bsock->msglen = pktsiz;         /* signal code */
+      return BNET_SIGNAL;             /* signal */
    }
 
    /* Make sure the buffer is big enough + one byte for EOS */
@@ -217,29 +217,29 @@ int32_t bnet_recv(BSOCK *bsock)
       bsock->msg = realloc_pool_memory(bsock->msg, pktsiz + 100);
    }
 
-   bsock->timer_start = watchdog_time; /* set start wait time */
+   bsock->timer_start = watchdog_time;  /* set start wait time */
    bsock->timed_out = 0;
    /* now read the actual data */
    if ((nbytes = read_nbytes(bsock, mp_chr(bsock->msg), pktsiz)) <=  0) {
-      bsock->timer_start = 0;        /* clear timer */
+      bsock->timer_start = 0;         /* clear timer */
       if (errno == 0) {
-        bsock->b_errno = ENODATA;
+         bsock->b_errno = ENODATA;
       } else {
-        bsock->b_errno = errno;
+         bsock->b_errno = errno;
       }
       bsock->errors++;
       Qmsg4(bsock->jcr, M_ERROR, 0, _("Read error from %s:%s:%d: ERR=%s\n"), 
-           bsock->who, bsock->host, bsock->port, bnet_strerror(bsock));
+            bsock->who, bsock->host, bsock->port, bnet_strerror(bsock));
       return BNET_ERROR;
    }
-   bsock->timer_start = 0;           /* clear timer */
+   bsock->timer_start = 0;            /* clear timer */
    bsock->in_msg_no++;
    bsock->msglen = nbytes;
    if (nbytes != pktsiz) {
       bsock->b_errno = EIO;
       bsock->errors++;
       Qmsg5(bsock->jcr, M_ERROR, 0, _("Read expected %d got %d from %s:%s:%d\n"), pktsiz, nbytes,
-           bsock->who, bsock->host, bsock->port);
+            bsock->who, bsock->host, bsock->port);
       return BNET_ERROR;
    }
    /* always add a zero by to properly terminate any
@@ -248,15 +248,15 @@ int32_t bnet_recv(BSOCK *bsock)
     */
    mp_chr(bsock->msg)[nbytes] = 0;    /* terminate in case it is a string */
    sm_check(__FILE__, __LINE__, false);
-   return nbytes;                    /* return actual length of message */
+   return nbytes;                     /* return actual length of message */
 }
 
 
 /*
- * Return 1 if there are errors on this bsock or it is closed, 
+ * Return 1 if there are errors on this bsock or it is closed,  
  *   i.e. stop communicating on this line.
  */
-int is_bnet_stop(BSOCK *bsock) 
+bool is_bnet_stop(BSOCK *bsock) 
 {
    return bsock->errors || bsock->terminated;
 }
@@ -295,21 +295,21 @@ int bnet_despool_to_bsock(BSOCK *bsock, void update_attr_spool_size(ssize_t size
       size += sizeof(int32_t);
       bsock->msglen = ntohl(pktsiz);
       if (bsock->msglen > 0) {
-        if (bsock->msglen > (int32_t)sizeof_pool_memory(bsock->msg)) {
-           bsock->msg = realloc_pool_memory(bsock->msg, bsock->msglen + 1);
-        }
-        nbytes = fread(bsock->msg, 1, bsock->msglen, bsock->spool_fd);
-        if (nbytes != (size_t)bsock->msglen) {
+         if (bsock->msglen > (int32_t)sizeof_pool_memory(bsock->msg)) {
+            bsock->msg = realloc_pool_memory(bsock->msg, bsock->msglen + 1);
+         }
+         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);
             Qmsg1(bsock->jcr, M_FATAL, 0, _("fread attr spool error. ERR=%s\n"), strerror(errno));
-           update_attr_spool_size(tsize-last);
-           return 0;
-        }
-        size += nbytes;
-        if ((++count & 0x3F) == 0) {
-           update_attr_spool_size(size-last);
-           last = size;
-        }
+            update_attr_spool_size(tsize-last);
+            return 0;
+         }
+         size += nbytes;
+         if ((++count & 0x3F) == 0) {
+            update_attr_spool_size(size-last);
+            last = size;
+         }
       }
       bnet_send(bsock);
    }
@@ -328,9 +328,9 @@ int bnet_despool_to_bsock(BSOCK *bsock, void update_attr_spool_size(ssize_t size
  * the length of the data packet which follows.
  *
  * Returns: 0 on failure
- *         1 on success
+ *          1 on success
  */
-int
+bool
 bnet_send(BSOCK *bsock)
 {
    int32_t rc;
@@ -338,77 +338,77 @@ bnet_send(BSOCK *bsock)
    int32_t msglen;
 
    if (bsock->errors || bsock->terminated || bsock->msglen > 1000000) {
-      return 0;
+      return false;
    }
    msglen = bsock->msglen;
    pktsiz = htonl((int32_t)bsock->msglen);
    /* send int32_t containing size of data packet */
    bsock->timer_start = watchdog_time; /* start timer */
-   bsock->timed_out = 0;              
+   bsock->timed_out = 0;               
    rc = write_nbytes(bsock, (char *)&pktsiz, sizeof(int32_t));
-   bsock->timer_start = 0;           /* clear timer */
+   bsock->timer_start = 0;            /* clear timer */
    if (rc != sizeof(int32_t)) {
       if (bsock->msglen == BNET_TERMINATE) { /* if we were terminating */
-        bsock->terminated = 1;
-        return 0;                    /* ignore any errors */
+         bsock->terminated = 1;
+         return false;                /* ignore any errors */
       }
       bsock->errors++;
       if (errno == 0) {
-        bsock->b_errno = EIO;
+         bsock->b_errno = EIO;
       } else {
-        bsock->b_errno = errno;
+         bsock->b_errno = errno;
       }
       if (rc < 0) {
-        if (!bsock->suppress_error_msgs && !bsock->timed_out) {
+         if (!bsock->suppress_error_msgs && !bsock->timed_out) {
             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));
-        }
+                  bsock->who, bsock->host, bsock->port,  bnet_strerror(bsock));
+         }
       } else {
          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);
+               bsock->who, bsock->host, bsock->port, bsock->msglen, rc);
       }
-      return 0;
+      return false;
    }
 
-   bsock->out_msg_no++;              /* increment message number */
-   if (bsock->msglen <= 0) {         /* length only? */
-      return 1;                      /* yes, no data */
+   bsock->out_msg_no++;               /* increment message number */
+   if (bsock->msglen <= 0) {          /* length only? */
+      return true;                    /* yes, no data */
    }
 
    /* send data packet */
    bsock->timer_start = watchdog_time; /* start timer */
-   bsock->timed_out = 0;              
+   bsock->timed_out = 0;               
    rc = write_nbytes(bsock, mp_chr(bsock->msg), bsock->msglen);
-   bsock->timer_start = 0;           /* clear timer */
+   bsock->timer_start = 0;            /* clear timer */
    if (rc != bsock->msglen) {
       bsock->errors++;
       if (errno == 0) {
-        bsock->b_errno = EIO;
+         bsock->b_errno = EIO;
       } else {
-        bsock->b_errno = errno;
+         bsock->b_errno = errno;
       }
       if (rc < 0) {
-        if (!bsock->suppress_error_msgs) {
+         if (!bsock->suppress_error_msgs) {
             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));
-        }
+                  bsock->who, bsock->host, bsock->port,  bnet_strerror(bsock));
+         }
       } else {
          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);
+               bsock->msglen, bsock->who, bsock->host, bsock->port, rc);
       }
-      return 0;
+      return false;
    }
-   return 1;
+   return true;
 }
 
 /*
- * Establish an SSL connection -- server side        
+ * Establish an SSL connection -- server side         
  *  Codes that ssl_need and ssl_has can take
- *    BNET_SSL_NONE     I cannot do ssl
- *    BNET_SSL_OK       I can do ssl, but it is not required on my end
+ *    BNET_SSL_NONE      I cannot do ssl
+ *    BNET_SSL_OK        I can do ssl, but it is not required on my end
  *    BNET_SSL_REQUIRED  ssl is required on my end
  */
-int    
+int     
 bnet_ssl_server(BSOCK *bsock, char *password, int ssl_need, int ssl_has)
 {
    /* Check to see if what we need (ssl_need) corresponds to what he has (ssl_has) */
@@ -417,7 +417,7 @@ bnet_ssl_server(BSOCK *bsock, char *password, int ssl_need, int ssl_has)
 }
 
 /*
- * Establish an SSL connection -- client side  
+ * Establish an SSL connection -- client side   
  */
 int bnet_ssl_client(BSOCK *bsock, char *password, int ssl_need)
 {
@@ -431,11 +431,11 @@ int bnet_ssl_client(BSOCK *bsock, char *password, int ssl_need)
  * the BSOCK connection.
  *
  *   Returns: 1 if data available
- *           0 if timeout
- *          -1 if error
+ *            0 if timeout
+ *           -1 if error
  */
 int 
-bnet_wait_data(BSOCK *bsock, int sec)         
+bnet_wait_data(BSOCK *bsock, int sec)          
 {
    fd_set fdset;
    struct timeval tv;
@@ -446,18 +446,18 @@ bnet_wait_data(BSOCK *bsock, int sec)
    tv.tv_usec = 0;
    for ( ;; ) {
       switch(select(bsock->fd + 1, &fdset, NULL, NULL, &tv)) {
-      case 0:                        /* timeout */
-        bsock->b_errno = 0;
-        return 0;
+      case 0:                         /* timeout */
+         bsock->b_errno = 0;
+         return 0;
       case -1:
-        bsock->b_errno = errno;
-        if (errno == EINTR || errno == EAGAIN) {
-           continue;
-        }
-        return -1;                  /* error return */
+         bsock->b_errno = errno;
+         if (errno == EINTR || errno == EAGAIN) {
+            continue;
+         }
+         return -1;                  /* error return */
       default:
-        bsock->b_errno = 0;
-        return 1;
+         bsock->b_errno = 0;
+         return 1;
       }
    }
 }
@@ -466,7 +466,7 @@ bnet_wait_data(BSOCK *bsock, int sec)
  * As above, but returns on interrupt
  */
 int
-bnet_wait_data_intr(BSOCK *bsock, int sec)         
+bnet_wait_data_intr(BSOCK *bsock, int sec)          
 {
    fd_set fdset;
    struct timeval tv;
@@ -477,36 +477,36 @@ bnet_wait_data_intr(BSOCK *bsock, int sec)
    tv.tv_usec = 0;
    for ( ;; ) {
       switch(select(bsock->fd + 1, &fdset, NULL, NULL, &tv)) {
-      case 0:                        /* timeout */
-        bsock->b_errno = 0;
-        return 0;
+      case 0:                         /* timeout */
+         bsock->b_errno = 0;
+         return 0;
       case -1:
-        bsock->b_errno = errno;
-        return -1;                  /* error return */
+         bsock->b_errno = errno;
+         return -1;                  /* error return */
       default:
-        bsock->b_errno = 0;
-        return 1;
+         bsock->b_errno = 0;
+         return 1;
       }
    }
 }
 
 #ifndef NETDB_INTERNAL
-#define NETDB_INTERNAL -1      /* See errno. */
+#define NETDB_INTERNAL  -1      /* See errno. */
 #endif
 #ifndef NETDB_SUCCESS
-#define NETDB_SUCCESS  0       /* No problem. */
+#define NETDB_SUCCESS   0       /* No problem. */
 #endif
 #ifndef HOST_NOT_FOUND
-#define HOST_NOT_FOUND 1       /* Authoritative Answer Host not found. */
+#define HOST_NOT_FOUND  1       /* Authoritative Answer Host not found. */
 #endif
 #ifndef TRY_AGAIN
-#define TRY_AGAIN      2       /* Non-Authoritative Host not found, or SERVERFAIL. */
+#define TRY_AGAIN       2       /* Non-Authoritative Host not found, or SERVERFAIL. */
 #endif
 #ifndef NO_RECOVERY
-#define NO_RECOVERY    3       /* Non recoverable errors, FORMERR, REFUSED, NOTIMP. */
+#define NO_RECOVERY     3       /* Non recoverable errors, FORMERR, REFUSED, NOTIMP. */
 #endif
 #ifndef NO_DATA
-#define NO_DATA        4       /* Valid name, no data record of requested type. */
+#define NO_DATA         4       /* Valid name, no data record of requested type. */
 #endif
 
 /*
@@ -542,7 +542,7 @@ static pthread_mutex_t ip_mutex = PTHREAD_MUTEX_INITIALIZER;
 static uint32_t *bget_host_ip(JCR *jcr, char *host)
 {
    struct in_addr inaddr;
-   uint32_t *addr_list;              /* this really should be struct in_addr */
+   uint32_t *addr_list;               /* this really should be struct in_addr */
    struct hostent *hp;
    char **p;
    int i;
@@ -555,25 +555,25 @@ static uint32_t *bget_host_ip(JCR *jcr, char *host)
       P(ip_mutex);
       if ((hp = gethostbyname(host)) == NULL) {
          Qmsg2(jcr, M_ERROR, 0, "gethostbyname() for host \"%s\" failed: ERR=%s\n", 
-              host, gethost_strerror());
-        V(ip_mutex);
-        return NULL;
+               host, gethost_strerror());
+         V(ip_mutex);
+         return NULL;
       }
       if (hp->h_length != sizeof(inaddr.s_addr) || hp->h_addrtype != AF_INET) {
          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;
+         V(ip_mutex);
+         return NULL;
       }
       i = 0;
       for (p = hp->h_addr_list; *p != 0; p++) {
-        i++;
+         i++;
       }
       i++;
       addr_list = (uint32_t *)malloc(sizeof(uint32_t) * i);
       i = 0;
       for (p = hp->h_addr_list; *p != 0; p++) {
-        addr_list[i++] = (*(struct in_addr **)p)->s_addr;
+         addr_list[i++] = (*(struct in_addr **)p)->s_addr;
       }
       addr_list[i] = (uint32_t) -1;
       V(ip_mutex);
@@ -592,7 +592,7 @@ static BSOCK *
 bnet_open(JCR *jcr, const char *name, char *host, char *service, int port, int *fatal)
 {
    int sockfd;
-   struct sockaddr_in tcp_serv_addr;    /* socket information */
+   struct sockaddr_in tcp_serv_addr;     /* socket information */
    uint32_t *addr_list;
    int i, connected = 0;
    int turnon = 1;
@@ -628,7 +628,7 @@ bnet_open(JCR *jcr, const char *name, char *host, char *service, int port, int *
       /* connect to server */
       tcp_serv_addr.sin_addr.s_addr = addr_list[i];
       if (connect(sockfd, (struct sockaddr *)&tcp_serv_addr, sizeof(tcp_serv_addr)) < 0) {
-        continue;
+         continue;
       }
       connected = 1;
       break;
@@ -647,7 +647,7 @@ bnet_open(JCR *jcr, const char *name, char *host, char *service, int port, int *
  */
 BSOCK *
 bnet_connect(JCR *jcr, int retry_interval, int max_retry_time, const char *name,
-            char *host, char *service, int port, int verbose)
+             char *host, char *service, int port, int verbose)
 {
    int i;
    BSOCK *bsock;
@@ -655,13 +655,13 @@ bnet_connect(JCR *jcr, int retry_interval, int max_retry_time, const char *name,
 
    for (i=0; (bsock = bnet_open(jcr, name, host, service, port, &fatal)) == NULL; i -= retry_interval) {
      if (fatal || (jcr && job_canceled(jcr))) {
-       return NULL;
+        return NULL;
      }
      Dmsg4(100, "Unable to connect to %s on %s:%d. ERR=%s\n",
-             name, host, port, strerror(errno));
+              name, host, port, strerror(errno));
       if (i < 0) {
-        i = 60 * 5;                  /* complain again in 5 minutes */
-        if (verbose)
+         i = 60 * 5;                  /* complain again in 5 minutes */
+         if (verbose)
             Qmsg4(jcr, M_WARNING, 0, "Could not connect to %s on %s:%d. ERR=%s\n\
 Retrying ...\n", name, host, port, strerror(errno));
       }
@@ -669,8 +669,8 @@ Retrying ...\n", name, host, port, strerror(errno));
       max_retry_time -= retry_interval;
       if (max_retry_time <= 0) {
          Qmsg4(jcr, M_FATAL, 0, _("Unable to connect to %s on %s:%d. ERR=%s\n"),
-             name, host, port, strerror(errno));
-        return NULL;
+              name, host, port, strerror(errno));
+         return NULL;
       }
    }
    return bsock;
@@ -689,16 +689,16 @@ char *bnet_strerror(BSOCK *bsock)
 /*
  * Format and send a message
  *  Returns: 0 on failure
- *          1 on success
+ *           1 on success
  */
-int
+bool
 bnet_fsend(BSOCK *bs, const char *fmt, ...)
 {
    va_list arg_ptr;
    int maxlen;
 
    if (bs->errors || bs->terminated) {
-      return 0;
+      return false;
    }
    /* This probably won't work, but we vsnprintf, then if we
     * get a negative length or a length greater than our buffer
@@ -722,9 +722,9 @@ again:
  *  Actual size obtained is returned in bs->msglen
  *
  *  Returns: 0 on failure
- *          1 on success
+ *           1 on success
  */
-int bnet_set_buffer_size(BSOCK *bs, uint32_t size, int rw)
+bool bnet_set_buffer_size(BSOCK *bs, uint32_t size, int rw)
 {
    uint32_t dbuf_size, start_size;
 #if defined(IP_TOS) && defined(IPTOS_THROUGHPUT)
@@ -742,13 +742,13 @@ 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) {
       Qmsg0(bs->jcr, M_FATAL, 0, _("Could not malloc BSOCK data buffer\n"));
-      return 0;
+      return false;
    }
    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)) {
+         (setsockopt(bs->fd, SOL_SOCKET, SO_RCVBUF, (sockopt_val_t)&dbuf_size, sizeof(dbuf_size)) < 0)) {
          Qmsg1(bs->jcr, M_ERROR, 0, _("sockopt error: %s\n"), strerror(errno));
-        dbuf_size -= TAPE_BSIZE;
+         dbuf_size -= TAPE_BSIZE;
       }
       Dmsg1(200, "set network buffer size=%d\n", dbuf_size);
       if (dbuf_size != start_size) {
@@ -756,7 +756,7 @@ int bnet_set_buffer_size(BSOCK *bs, uint32_t size, int rw)
       }
       if (dbuf_size % TAPE_BSIZE != 0) {
          Qmsg1(bs->jcr, M_ABORT, 0, _("Network buffer size %d not multiple of tape block size.\n"),
-             dbuf_size);
+              dbuf_size);
       }
    }
    if (size != 0) {
@@ -767,9 +767,9 @@ int bnet_set_buffer_size(BSOCK *bs, uint32_t size, int rw)
    start_size = dbuf_size;
    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)) {
+         (setsockopt(bs->fd, SOL_SOCKET, SO_SNDBUF, (sockopt_val_t)&dbuf_size, sizeof(dbuf_size)) < 0)) {
          Qmsg1(bs->jcr, M_ERROR, 0, _("sockopt error: %s\n"), strerror(errno));
-        dbuf_size -= TAPE_BSIZE;
+         dbuf_size -= TAPE_BSIZE;
       }
       Dmsg1(200, "set network buffer size=%d\n", dbuf_size);
       if (dbuf_size != start_size) {
@@ -777,12 +777,12 @@ int bnet_set_buffer_size(BSOCK *bs, uint32_t size, int rw)
       }
       if (dbuf_size % TAPE_BSIZE != 0) {
          Qmsg1(bs->jcr, M_ABORT, 0, _("Network buffer size %d not multiple of tape block size.\n"),
-             dbuf_size);
+              dbuf_size);
       }
    }
 
    bs->msglen = dbuf_size;
-   return 1;
+   return true;
 }
 
 /*
@@ -790,9 +790,9 @@ int bnet_set_buffer_size(BSOCK *bs, uint32_t size, int rw)
  *  This consists of sending a negative packet length
  *
  *  Returns: 0 on failure
- *          1 on success
+ *           1 on success
  */
-int bnet_sig(BSOCK *bs, int sig)
+bool bnet_sig(BSOCK *bs, int sig)
 {
    bs->msglen = sig;
    return bnet_send(bs);
@@ -824,7 +824,7 @@ const char *bnet_sig_to_ascii(BSOCK *bs)
          return "BNET_PROMPT";
       default:
          sprintf(buf, "Unknown sig %d", bs->msglen);
-        return buf;
+         return buf;
    }
 }
 
@@ -834,7 +834,7 @@ const char *bnet_sig_to_ascii(BSOCK *bs)
  */
 BSOCK *
 init_bsock(JCR *jcr, int sockfd, const char *who, const char *host, int port, 
-          struct sockaddr_in *client_addr) 
+           struct sockaddr_in *client_addr) 
 {
    BSOCK *bsock = (BSOCK *)malloc(sizeof(BSOCK));
    memset(bsock, 0, sizeof(BSOCK));
@@ -848,7 +848,7 @@ init_bsock(JCR *jcr, int sockfd, const char *who, const char *host, int port,
    memcpy(&bsock->client_addr, client_addr, sizeof(bsock->client_addr));
    /*
     * ****FIXME**** reduce this to a few hours once   
-    *  heartbeats are implemented
+    *   heartbeats are implemented
     */
    bsock->timeout = 60 * 60 * 6 * 24; /* 6 days timeout */
    bsock->jcr = jcr;
@@ -881,10 +881,10 @@ bnet_close(BSOCK *bsock)
    for ( ; bsock != NULL; bsock = next) {
       next = bsock->next;
       if (!bsock->duped) {
-        if (bsock->timed_out) {
-           shutdown(bsock->fd, 2);   /* discard any pending I/O */
-        }
-        socketClose(bsock->fd);      /* normal close */
+         if (bsock->timed_out) {
+            shutdown(bsock->fd, 2);   /* discard any pending I/O */
+         }
+         socketClose(bsock->fd);      /* normal close */
       }
       term_bsock(bsock);
    }
@@ -898,7 +898,7 @@ term_bsock(BSOCK *bsock)
       free_pool_memory(bsock->msg);
       bsock->msg = NULL;
    } else {
-      ASSERT(1==0);                  /* double close */
+      ASSERT(1==0);                   /* double close */
    }
    if (bsock->errmsg) {
       free_pool_memory(bsock->errmsg);
index a5fb6dd78b81fe7b42bbb9c4291bb81236a2c869..eec978c01d38382c831068333daf1b6a84cb9917 100644 (file)
@@ -63,10 +63,10 @@ void read_state_file(char *dir, const char *progname, int port);
 
 /* bnet.c */
 int32_t    bnet_recv             (BSOCK *bsock);
-int        bnet_send             (BSOCK *bsock);
-int        bnet_fsend            (BSOCK *bs, const char *fmt, ...);
-int        bnet_set_buffer_size  (BSOCK *bs, uint32_t size, int rw);
-int        bnet_sig              (BSOCK *bs, int sig);
+bool       bnet_send             (BSOCK *bsock);
+bool       bnet_fsend            (BSOCK *bs, const char *fmt, ...);
+bool       bnet_set_buffer_size  (BSOCK *bs, uint32_t size, int rw);
+bool       bnet_sig              (BSOCK *bs, int sig);
 int        bnet_ssl_server       (BSOCK *bsock, char *password, int ssl_need, int ssl_has);
 int        bnet_ssl_client       (BSOCK *bsock, char *password, int ssl_need);
 BSOCK *    bnet_connect            (JCR *jcr, int retry_interval,
@@ -82,7 +82,7 @@ const char *bnet_sig_to_ascii     (BSOCK *bsock);
 int        bnet_wait_data        (BSOCK *bsock, int sec);
 int        bnet_wait_data_intr   (BSOCK *bsock, int sec);
 int        bnet_despool_to_bsock (BSOCK *bsock, void update(ssize_t size), ssize_t size);
-int        is_bnet_stop          (BSOCK *bsock);
+bool       is_bnet_stop          (BSOCK *bsock);
 int        is_bnet_error         (BSOCK *bsock);
 void       bnet_suppress_error_messages(BSOCK *bsock, bool flag);
 
index 8f261f458591a7606324fbe60cc0aab71d8ee55a..fb03a8b3751c839f80fb0f504f2fc2297c14bdf9 100755 (executable)
@@ -31,9 +31,9 @@
 #include "jcr.h"
 
 /* Exported globals */
-time_t watchdog_time = 0;             /* this has granularity of SLEEP_TIME */
+time_t watchdog_time = 0;            /* this has granularity of SLEEP_TIME */
+time_t watchdog_sleep_time = 1;       /* examine things every second */
 
-#define SLEEP_TIME 1                  /* examine things every second */
 
 /* Forward referenced functions */
 extern "C" void *watchdog_thread(void *arg);
@@ -44,7 +44,7 @@ static void wd_unlock();
 /* Static globals */
 static bool quit = false;;
 static bool wd_is_init = false;
-static brwlock_t lock;                /* watchdog lock */
+static brwlock_t lock;               /* watchdog lock */
 
 static pthread_t wd_tid;
 static dlist *wd_queue;
@@ -54,7 +54,7 @@ static dlist *wd_inactive;
  * Start watchdog thread
  *
  *  Returns: 0 on success
- *           errno on failure
+ *          errno on failure
  */
 int start_watchdog(void)
 {
@@ -70,7 +70,7 @@ int start_watchdog(void)
 
    if ((errstat=rwl_init(&lock)) != 0) {
       Emsg1(M_ABORT, 0, _("Unable to initialize watchdog lock. ERR=%s\n"), 
-            strerror(errstat));
+           strerror(errstat));
    }
    wd_queue = new dlist(wd_queue, &dummy->link);
    wd_inactive = new dlist(wd_inactive, &dummy->link);
@@ -86,7 +86,7 @@ int start_watchdog(void)
  * Terminate the watchdog thread
  *
  * Returns: 0 on success
- *          errno on failure
+ *         errno on failure
  */
 int stop_watchdog(void)
 {
@@ -97,7 +97,7 @@ int stop_watchdog(void)
       return 0;
    }
 
-   quit = true;                       /* notify watchdog thread to stop */
+   quit = true;                      /* notify watchdog thread to stop */
    wd_is_init = false;
 
    stat = pthread_join(wd_tid, NULL);
@@ -107,7 +107,7 @@ int stop_watchdog(void)
       wd_queue->remove(item);
       p = (watchdog_t *)item;
       if (p->destructor != NULL) {
-         p->destructor(p);
+        p->destructor(p);
       }
       free(p);
    }
@@ -119,7 +119,7 @@ int stop_watchdog(void)
       wd_inactive->remove(item);
       p = (watchdog_t *)item;
       if (p->destructor != NULL) {
-         p->destructor(p);
+        p->destructor(p);
       }
       free(p);
    }
@@ -182,17 +182,17 @@ bool unregister_watchdog_unlocked(watchdog_t *wd)
 
    foreach_dlist(p, wd_queue) {
       if (wd == p) {
-         wd_queue->remove(wd);
+        wd_queue->remove(wd);
          Dmsg1(400, "Unregistered watchdog %p\n", wd);
-         return true;
+        return true;
       }
    }
 
    foreach_dlist(p, wd_inactive) {
       if (wd == p) {
-         wd_inactive->remove(wd);
+        wd_inactive->remove(wd);
          Dmsg1(400, "Unregistered inactive watchdog %p\n", wd);
-         return true;
+        return true;
       }
    }
 
@@ -236,31 +236,31 @@ extern "C" void *watchdog_thread(void *arg)
       watchdog_time = time(NULL);
 
       foreach_dlist(p, wd_queue) {
-         if (p->next_fire < watchdog_time) {
-            /* Run the callback */
-            p->callback(p);
+        if (p->next_fire < watchdog_time) {
+           /* Run the callback */
+           p->callback(p);
 
             /* Reschedule (or move to inactive list if it's a one-shot timer) */
-            if (p->one_shot) {
-               /* 
-                * Note, when removing an item while walking the list
-                *  we must get the previous pointer (q) and set the
-                *  current pointer (p) to this previous pointer after
+           if (p->one_shot) {
+              /* 
+               * Note, when removing an item while walking the list
+               *  we must get the previous pointer (q) and set the
+               *  current pointer (p) to this previous pointer after
                 *  removing the current pointer, otherwise, we won't
-                *  walk the rest of the list.
-                */
-               q = (watchdog_t *)wd_queue->prev(p);
-               wd_queue->remove(p);
-               wd_inactive->append(p);
-               p = q;
-            } else {
-               p->next_fire = watchdog_time + p->interval;
-            }
-         }
+               *  walk the rest of the list.
+               */
+              q = (watchdog_t *)wd_queue->prev(p);
+              wd_queue->remove(p);
+              wd_inactive->append(p);
+              p = q;
+           } else {
+              p->next_fire = watchdog_time + p->interval;
+           }
+        }
       }
       wd_unlock();
       unlock_jcr_chain();
-      bmicrosleep(SLEEP_TIME, 0);
+      bmicrosleep(watchdog_sleep_time, 0);
    }
 
    Dmsg0(400, "NicB-reworked watchdog thread exited\n");
@@ -277,7 +277,7 @@ static void wd_lock()
    int errstat;
    if ((errstat=rwl_writelock(&lock)) != 0) {
       Emsg1(M_ABORT, 0, "rwl_writelock failure. ERR=%s\n",
-           strerror(errstat));
+          strerror(errstat));
    }
 }    
 
@@ -291,6 +291,6 @@ static void wd_unlock()
    int errstat;
    if ((errstat=rwl_writeunlock(&lock)) != 0) {
       Emsg1(M_ABORT, 0, "rwl_writeunlock failure. ERR=%s\n",
-           strerror(errstat));
+          strerror(errstat));
    }
 }    
index c4e6bd8c2f3bc89d385cae38c53c6100c7a40f14..a083e3b5f35a551939d7135a31533a76611cc74a 100644 (file)
@@ -15,6 +15,7 @@ Storage {                             # definition of myself
   SDPort = @sd_port@                  # Director's port      
   WorkingDirectory = "@working_dir@"
   Pid Directory = "@piddir@"
+  Maximum Concurrent Jobs = 1
 }
 
 #
index 1a34ee8832a268033e7dff31f285298729c53ab4..f8028ba913a9837c43eb8b317310f83bb472324f 100644 (file)
@@ -2,8 +2,8 @@
 #undef  VERSION
 #define VERSION "1.35.0"
 #define VSTRING "1"
-#define BDATE   "27 June 2004"
-#define LSMDATE "27Jun04"
+#define BDATE   "01 July 2004"
+#define LSMDATE "01Jul04"
 
 /* Debug flags */
 #undef  DEBUG