]> git.sur5r.net Git - bacula/bacula/commitdiff
Fix verify
authorKern Sibbald <kern@sibbald.com>
Wed, 22 May 2002 11:33:50 +0000 (11:33 +0000)
committerKern Sibbald <kern@sibbald.com>
Wed, 22 May 2002 11:33:50 +0000 (11:33 +0000)
git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@27 91ce42f0-d328-0410-95d8-f526ca767f89

13 files changed:
bacula/src/cats/bdb.c
bacula/src/cats/cats.h
bacula/src/cats/mysql.c
bacula/src/cats/sql_create.c
bacula/src/cats/sql_get.c
bacula/src/cats/sqlite.c
bacula/src/dird/autoprune.c
bacula/src/dird/fd_cmds.c
bacula/src/dird/job.c
bacula/src/dird/ua_prune.c
bacula/src/dird/verify.c
bacula/src/jcr.h
bacula/src/version.h

index 7e3a3da6cc141ec779ab71f4128c36191f5250ae..7fc9e208c4c002cd2f015cbac05e014b72d48c3a 100644 (file)
@@ -122,6 +122,8 @@ db_init_database(char *db_name, char *db_user, char *db_password)
    *mdb->errmsg = 0;
    mdb->cmd = get_pool_memory(PM_EMSG);  /* command buffer */
    mdb->ref_count = 1;
+   mdb->cached_path = get_pool_memory(PM_FNAME);
+   mdb->cached_path_id = 0;
    qinsert(&db_list, &mdb->bq);       /* put db in list */
    Dmsg0(200, "Done db_open_database()\n");
    mdb->cfd = -1;
@@ -270,6 +272,7 @@ void db_close_database(B_DB *mdb)
       rwl_destroy(&mdb->lock);      
       free_pool_memory(mdb->errmsg);
       free_pool_memory(mdb->cmd);
+      free_pool_memory(mdb->cached_path);
       free(mdb);
    }
    V(mutex);
index 392bbc24ba7490f74bb9c31356f5feba918d358a..1dd5f08424eca7acff1af2a433b06919ade45b11 100644 (file)
@@ -113,6 +113,8 @@ typedef struct s_db {
    char *sqlite_errmsg;               /* error message returned by sqlite */
    POOLMEM *errmsg;                   /* nicely edited error message */
    POOLMEM *cmd;                      /* SQL command string */
+   POOLMEM *cached_path;
+   uint32_t cached_path_id;
 } B_DB;
 
 
@@ -174,6 +176,8 @@ typedef struct s_db {
    int connected;
    POOLMEM *errmsg;                   /* nicely edited error message */
    POOLMEM *cmd;                      /* SQL command string */
+   POOLMEM *cached_path;
+   uint32_t cached_path_id;
 } B_DB;
 
 
@@ -234,6 +238,8 @@ typedef struct s_db {
    char *db_name;                     /* name of database */
    POOLMEM *errmsg;                   /* nicely edited error message */
    POOLMEM *cmd;                      /* Command string */
+   POOLMEM *cached_path;
+   uint32_t cached_path_id;
 } B_DB;
 
 #endif /* HAVE_MYSQL */
index a35e21d6c8c73d9d95489481bdf870be8645473a..3dd0d6780709e61b4d07ab1d33be97a467768e37 100644 (file)
@@ -80,6 +80,8 @@ db_init_database(char *db_name, char *db_user, char *db_password)
    mdb->errmsg = get_pool_memory(PM_EMSG); /* get error message buffer */
    *mdb->errmsg = 0;
    mdb->cmd = get_pool_memory(PM_EMSG);    /* get command buffer */
+   mdb->cached_path = get_pool_memory(PM_FNAME);
+   mdb->cached_path_id = 0;
    mdb->ref_count = 1;
    qinsert(&db_list, &mdb->bq);           /* put db in list */
    V(mutex);
@@ -176,6 +178,7 @@ db_close_database(B_DB *mdb)
       rwl_destroy(&mdb->lock);      
       free_pool_memory(mdb->errmsg);
       free_pool_memory(mdb->cmd);
+      free_pool_memory(mdb->cached_path);
       if (mdb->db_name) {
         free(mdb->db_name);
       }
index 77dfa27a0b9ed176135ad1cfc98c0bb6252a4251..6b08a73898618913671f0141e39324e071f07468 100644 (file)
@@ -510,6 +510,10 @@ static int db_create_file_record(B_DB *mdb, ATTR_DBR *ar)
 {
    int stat;
 
+   ASSERT(ar->JobId);
+   ASSERT(ar->PathId);
+   ASSERT(ar->FilenameId);
+
    db_lock(mdb);
    /* Must create it */
    Mmsg(&mdb->cmd,
@@ -535,8 +539,6 @@ LStat, MD5) VALUES (%d, %d, %d, %d, \"%s\", \"0\")",
 static int db_create_path_record(B_DB *mdb, ATTR_DBR *ar, char *path)
 {
    SQL_ROW row;
-   static uint32_t cached_id = 0;
-   static char cached_path[MAXSTRING];
    int stat;
 
    if (*path == 0) {
@@ -547,11 +549,11 @@ static int db_create_path_record(B_DB *mdb, ATTR_DBR *ar, char *path)
 
    db_lock(mdb);
 
-   if (cached_id != 0 && strcmp(cached_path, path) == 0) {
-      ar->PathId = cached_id;
+   if (mdb->cached_path_id != 0 && strcmp(mdb->cached_path, path) == 0) {
+      ar->PathId = mdb->cached_path_id;
       db_unlock(mdb);
       return 1;
-   }
+   }         
 
    Mmsg(&mdb->cmd, "SELECT PathId FROM Path WHERE Path=\"%s\"", path);
 
@@ -576,10 +578,12 @@ static int db_create_path_record(B_DB *mdb, ATTR_DBR *ar, char *path)
         }
         sql_free_result(mdb);
         ar->PathId = atoi(row[0]);
-        if (ar->PathId != cached_id) {
-           cached_id = ar->PathId;
-           strncpy(cached_path, path, sizeof(cached_path));
-           cached_path[sizeof(cached_path)-1] = 0;
+        /* Cache path */
+        if (ar->PathId != mdb->cached_path_id) {
+           mdb->cached_path_id = ar->PathId;
+           mdb->cached_path = check_pool_memory_size(mdb->cached_path,
+              strlen(path)+1);
+           strcpy(mdb->cached_path, path);
         }
         db_unlock(mdb);
         return 1;
@@ -600,10 +604,12 @@ static int db_create_path_record(B_DB *mdb, ATTR_DBR *ar, char *path)
       stat = 1;
    }
 
-   if (ar->PathId != cached_id) {
-      cached_id = ar->PathId;
-      strncpy(cached_path, path, sizeof(cached_path));
-      cached_path[sizeof(cached_path)-1] = 0;
+   /* Cache path */
+   if (ar->PathId != mdb->cached_path_id) {
+      mdb->cached_path_id = ar->PathId;
+      mdb->cached_path = check_pool_memory_size(mdb->cached_path,
+        strlen(path)+1);
+      strcpy(mdb->cached_path, path);
    }
    db_unlock(mdb);
    return stat;
@@ -613,7 +619,6 @@ static int db_create_path_record(B_DB *mdb, ATTR_DBR *ar, char *path)
 static int db_create_filename_record(B_DB *mdb, ATTR_DBR *ar, char *fname) 
 {
    SQL_ROW row;
-   int stat;
 
    db_lock(mdb);
    Mmsg(&mdb->cmd, "SELECT FilenameId FROM Filename WHERE Name=\"%s\"", fname);
@@ -630,15 +635,13 @@ static int db_create_filename_record(B_DB *mdb, ATTR_DBR *ar, char *fname)
         if ((row = sql_fetch_row(mdb)) == NULL) {
             Mmsg2(&mdb->errmsg, _("error fetching row for file=%s: ERR=%s\n"), 
                fname, sql_strerror(mdb));
-           sql_free_result(mdb);
-           db_unlock(mdb);
            ar->FilenameId = 0;
-           return 0;
+        } else {
+           ar->FilenameId = atoi(row[0]);
         }
         sql_free_result(mdb);
-        ar->FilenameId = atoi(row[0]);
         db_unlock(mdb);
-        return 1;
+        return ar->FilenameId > 0;
       }
       sql_free_result(mdb);
    }
@@ -650,14 +653,12 @@ VALUES (\"%s\")", fname);
       Mmsg2(&mdb->errmsg, _("Create db Filename record %s failed. ERR=%s\n"), 
            mdb->cmd, sql_strerror(mdb));
       ar->FilenameId = 0;
-      stat = 0;
    } else {
       ar->FilenameId = sql_insert_id(mdb);
-      stat = 1;
    }
 
    db_unlock(mdb);
-   return stat;
+   return ar->FilenameId > 0;
 }
 
 #endif /* HAVE_MYSQL || HAVE_SQLITE */
index f1c1a69220a6155b48611eb1be167361e9dc642e..ad5b9b314d7dfc3dbae329f8289497e8d2374aa2 100644 (file)
@@ -74,7 +74,7 @@ int db_get_file_attributes_record(B_DB *mdb, char *fname, FILE_DBR *fdbr)
    char file[MAXSTRING];
    char spath[MAXSTRING];
    char buf[MAXSTRING];
-   Dmsg0(20, "get_file_from_catalog\n");
+   Dmsg1(20, "Enter get_file_from_catalog fname=%s \n", fname);
 
    /* Find path without the filename */
    for (p=l=fname; *p; p++) {
@@ -109,7 +109,7 @@ int db_get_file_attributes_record(B_DB *mdb, char *fname, FILE_DBR *fdbr)
 
    db_escape_string(buf, spath, pnl);
    fdbr->PathId = db_get_path_record(mdb, buf);
-   Dmsg1(50, "db_get_path_record PathId=%d\n", fdbr->PathId);
+   Dmsg2(50, "db_get_path_record PathId=%d path=%s\n", fdbr->PathId, buf);
 
    id = db_get_file_record(mdb, fdbr);
 
@@ -133,9 +133,15 @@ int db_get_file_record(B_DB *mdb, FILE_DBR *fdbr)
 "SELECT FileId, LStat, MD5 from File where File.JobId=%d and File.PathId=%d and \
 File.FilenameId=%d", fdbr->JobId, fdbr->PathId, fdbr->FilenameId);
 
+   Dmsg3(050, "Get_file_record JobId=%d FilenameId=%d PathId=%d\n",
+      fdbr->JobId, fdbr->FilenameId, fdbr->PathId);
+      
+   Dmsg1(100, "Query=%s\n", mdb->cmd);
+
    if (QUERY_DB(mdb, mdb->cmd)) {
 
       mdb->num_rows = sql_num_rows(mdb);
+      Dmsg1(050, "get_file_record num_rows=%d\n", (int)mdb->num_rows);
 
       /* 
        * Note, we can find more than one File record with the same
@@ -143,7 +149,7 @@ File.FilenameId=%d", fdbr->JobId, fdbr->PathId, fdbr->FilenameId);
        */
       if (mdb->num_rows > 1) {
          Emsg1(M_WARNING, 0, _("get_file_record want 1 got rows=%d\n"), mdb->num_rows);
-         Emsg1(M_ERROR, 0, "%s\n", mdb->cmd);
+         Emsg1(M_ERROR, 0, "%s", mdb->cmd);
       }
       if (mdb->num_rows >= 1) {
         if ((row = sql_fetch_row(mdb)) == NULL) {
@@ -171,7 +177,7 @@ File.FilenameId=%d", fdbr->JobId, fdbr->PathId, fdbr->FilenameId);
 static int db_get_filename_record(B_DB *mdb, char *fname) 
 {
    SQL_ROW row;
-   int FilenameId;
+   int FilenameId = 0;
 
    if (*fname == 0) {
       Mmsg0(&mdb->errmsg, _("Null name given to db_get_filename_record\n"));
@@ -186,25 +192,27 @@ static int db_get_filename_record(B_DB *mdb, char *fname)
 
       if (mdb->num_rows > 1) {
          Mmsg1(&mdb->errmsg, _("More than one Filename!: %d\n"), (int)(mdb->num_rows));
-      } else if (mdb->num_rows == 1) {
+         Emsg1(M_WARNING, 0, _("get_filename_record want 1 got rows=%d\n"), mdb->num_rows);
+         Emsg1(M_ERROR, 0, "%s", mdb->errmsg);
+      }
+      if (mdb->num_rows >= 1) {
         if ((row = sql_fetch_row(mdb)) == NULL) {
             Mmsg1(&mdb->errmsg, _("error fetching row: %s\n"), sql_strerror(mdb));
-           FilenameId = 0;
+            Emsg1(M_ERROR, 0, "%s", mdb->errmsg);
         } else {
            FilenameId = atoi(row[0]);
            if (FilenameId <= 0) {
-               Mmsg2(&mdb->errmsg, _("Create db Filename record %s found bad record: %d\n"),
+               Mmsg2(&mdb->errmsg, _("Get DB Filename record %s found bad record: %d\n"),
                  mdb->cmd, FilenameId); 
+               Emsg1(M_ERROR, 0, "%s", mdb->errmsg);
+              FilenameId = 0;
            }
         }
-        sql_free_result(mdb);
-        db_unlock(mdb);
-        return FilenameId;
       }
       sql_free_result(mdb);
    }
    db_unlock(mdb);
-   return 0;                         /* failed */
+   return FilenameId;
 }
 
 /* Get path record   
@@ -215,18 +223,18 @@ static int db_get_path_record(B_DB *mdb, char *path)
 {
    SQL_ROW row;
    uint32_t PathId = 0;
-   /*******FIXME***** move into mdb record and allocate */
-   static uint32_t cached_id = 0;
-   static char cached_path[MAXSTRING];
 
    if (*path == 0) {
       Emsg0(M_ABORT, 0, _("Null path given to db_get_path_record\n"));
    }
-   if (cached_id != 0 && strcmp(cached_path, path) == 0) {
-      return cached_id;
-   }         
 
    db_lock(mdb);
+
+   if (mdb->cached_path_id != 0 && strcmp(mdb->cached_path, path) == 0) {
+      db_unlock(mdb);
+      return mdb->cached_path_id;
+   }         
+
    Mmsg(&mdb->cmd, "SELECT PathId FROM Path WHERE Path=\"%s\"", path);
 
    if (QUERY_DB(mdb, mdb->cmd)) {
@@ -241,17 +249,25 @@ static int db_get_path_record(B_DB *mdb, char *path)
             Mmsg1(&mdb->errmsg, _("error fetching row: %s\n"), sql_strerror(mdb));
         } else {
            PathId = atoi(row[0]);
-           /* Cache path if it will fit in our static buffer */
-           if (PathId != cached_id && strlen(path) < sizeof(cached_path)+2) {
-              cached_id = PathId;
-              strcpy(cached_path, path);
+           if (PathId <= 0) {
+               Mmsg2(&mdb->errmsg, _("Get DB path record %s found bad record: %d\n"),
+                 mdb->cmd, PathId); 
+              PathId = 0;
+           } else {
+              /* Cache path */
+              if (PathId != mdb->cached_path_id) {
+                 mdb->cached_path_id = PathId;
+                 mdb->cached_path = check_pool_memory_size(mdb->cached_path,
+                    strlen(path)+1);
+                 strcpy(mdb->cached_path, path);
+              }
            }
         }
       }
       sql_free_result(mdb);
    }
    db_unlock(mdb);
-   return 0;                         /* failed */
+   return PathId;
 }
 
 
index b9a33905c518de4e490b141fe18ce37410b537d9..e4969aad7cff4d6cf2bf5da3be21f50c7fc5bcf9 100644 (file)
@@ -81,6 +81,8 @@ db_init_database(char *db_name, char *db_user, char *db_password)
    mdb->errmsg = get_pool_memory(PM_EMSG); /* get error message buffer */
    *mdb->errmsg = 0;
    mdb->cmd = get_pool_memory(PM_EMSG);    /* get command buffer */
+   mdb->cached_path = get_pool_memory(PM_FNAME);
+   mdb->cached_path_id = 0;
    mdb->ref_count = 1;
    qinsert(&db_list, &mdb->bq);           /* put db in list */
    V(mutex);
@@ -171,6 +173,7 @@ db_close_database(B_DB *mdb)
       rwl_destroy(&mdb->lock);      
       free_pool_memory(mdb->errmsg);
       free_pool_memory(mdb->cmd);
+      free_pool_memory(mdb->cached_path);
       if (mdb->db_name) {
         free(mdb->db_name);
       }
index a925a9530e7eff40f2703fb578adab822cef55e5..4422e9fa85ed97cb003da0607710dcfe61bb33d5 100644 (file)
@@ -122,7 +122,7 @@ int prune_volumes(JCR *jcr)
    pr.PoolId = jcr->PoolId;
    if (!db_get_pool_record(jcr->db, &pr) || !db_get_media_ids(jcr->db, &num_ids, &ids)) {
       Jmsg(jcr, M_ERROR, 0, "%s", db_strerror(jcr->db));
-      goto rtn;
+      goto bail_out;
    }
 
 
@@ -144,7 +144,8 @@ int prune_volumes(JCR *jcr)
       stat += prune_volume(&ua, &pr, &mr); 
       Dmsg1(200, "Num pruned = %d\n", stat);
    }   
-rtn:
+
+bail_out:
    db_unlock(jcr->db);
    free_ua_context(&ua);
    if (ids) {
index c61cbb800ef2dfdbba924000300ba55b94c13805..6783d5eed17d8e67b4a8e71d5dd9dc78a8a74a80 100644 (file)
@@ -212,6 +212,7 @@ msglen=%d msg=%s\n"), len, fd->msglen, fd->msg);
        }
 
        if (stream == STREAM_UNIX_ATTRIBUTES) {
+         jcr->jr.JobFiles++;
          len = strlen(fd->msg);      /* length before attributes */
          ar.attr = &fd->msg[len+1];
          ar.fname = jcr->fname;
index 9813b16525af118cceb12966eac8e3eda2cc7dcd..c6c55e0dc264481dd0bfbd1eaa3d3c0c969c34b1 100644 (file)
@@ -158,11 +158,11 @@ static void job_thread(void *arg)
            break;
         case JT_VERIFY:
            do_verify(jcr);
-           do_autoprune(jcr);
+//         do_autoprune(jcr);
            break;
         case JT_RESTORE:
            do_restore(jcr);
-           do_autoprune(jcr);
+//         do_autoprune(jcr);
            break;
         case JT_ADMIN:
            /* No actual job */
index 3f94de08fdde537715d1d6e74f9838b6356c45bf..13c4bf5abfb6af8f322ca5d4688f9e19a10096ac 100644 (file)
@@ -523,7 +523,7 @@ int prune_volume(UAContext *ua, POOL_DBR *pr, MEDIA_DBR *mr)
    if (!db_sql_query(ua->db, query, count_handler, (void *)&cnt)) {
       bsendmsg(ua, "%s", db_strerror(ua->db));
       Dmsg0(050, "Count failed\n");
-      goto rtn;
+      goto bail_out;
    }
       
    if (cnt.count == 0) {
@@ -532,7 +532,7 @@ int prune_volume(UAContext *ua, POOL_DBR *pr, MEDIA_DBR *mr)
            mr->VolumeName);
       }
       stat = mark_media_purged(ua, mr);
-      goto rtn;
+      goto bail_out;
    }
 
    if (cnt.count < MAX_DEL_LIST_LEN) {
@@ -550,7 +550,7 @@ int prune_volume(UAContext *ua, POOL_DBR *pr, MEDIA_DBR *mr)
          bsendmsg(ua, "%s", db_strerror(ua->db));
       }
       Dmsg0(050, "Count failed\n");
-      goto rtn;
+      goto bail_out;
    }
 
    /* Use Volume Retention to prune Jobs and Files */
@@ -592,7 +592,7 @@ int prune_volume(UAContext *ua, POOL_DBR *pr, MEDIA_DBR *mr)
       stat = mark_media_purged(ua, mr);
    }
 
-rtn:
+bail_out:
    db_unlock(ua->db);
    free_pool_memory(query);
    return stat;
index 8287baa50ffb3ffa21a345b5d2eb31cb53a11313..e4b9f623903f489a9cd1817627c2df221431866d 100644 (file)
@@ -73,8 +73,7 @@ int do_verify(JCR *jcr)
    int last_full_id;
 
    if (!get_or_create_client_record(jcr)) {
-      verify_cleanup(jcr, JS_ErrorTerminated);                   
-      return 0;
+      goto bail_out;
    }
 
    Dmsg1(9, "bdird: created client %s record\n", jcr->client->hdr.name);
@@ -88,8 +87,7 @@ int do_verify(JCR *jcr)
       if (!db_find_last_full_verify(jcr->db, &jr)) {
          Jmsg(jcr, M_FATAL, 0, _("Unable to find last full verify. %s"),
            db_strerror(jcr->db));
-        verify_cleanup(jcr, JS_ErrorTerminated);                    
-        return 0;
+        goto bail_out;
       }
       last_full_id = jr.JobId;
       Dmsg1(20, "Last full id=%d\n", last_full_id);
@@ -100,8 +98,7 @@ int do_verify(JCR *jcr)
    jcr->jr.Level = jcr->level;
    if (!db_update_job_start_record(jcr->db, &jcr->jr)) {
       Jmsg(jcr, M_ERROR, 0, "%s", db_strerror(jcr->db));
-      verify_cleanup(jcr, JS_ErrorTerminated);                   
-      return 0;
+      goto bail_out;
    }
 
    if (!jcr->fname) {
@@ -119,8 +116,7 @@ int do_verify(JCR *jcr)
       jr.JobId = last_full_id;
       if (!db_get_job_record(jcr->db, &jr)) {
          Jmsg(jcr, M_ERROR, 0, _("Could not get job record. %s"), db_strerror(jcr->db));
-        verify_cleanup(jcr, JS_ErrorTerminated);                    
-        return 0;
+        goto bail_out;
       }
       Jmsg(jcr, M_INFO, 0, _("Verifying against Init JobId %d run %s\n"),
         last_full_id, jr.cStartTime); 
@@ -132,22 +128,19 @@ int do_verify(JCR *jcr)
     */
    jcr->sd_auth_key = bstrdup("dummy");    /* dummy Storage daemon key */
    if (!connect_to_file_daemon(jcr, 10, FDConnectTimeout, 1)) {
-      verify_cleanup(jcr, JS_ErrorTerminated);                   
-      return 0;
+      goto bail_out;
    }
 
    fd = jcr->file_bsock;
 
    Dmsg0(30, ">filed: Send include list\n");
    if (!send_include_list(jcr)) {
-      verify_cleanup(jcr, JS_ErrorTerminated);                   
-      return 0;
+      goto bail_out;
    }
 
    Dmsg0(30, ">filed: Send exclude list\n");
    if (!send_exclude_list(jcr)) {
-      verify_cleanup(jcr, JS_ErrorTerminated);                   
-      return 0;
+      goto bail_out;
    }
 
    /* 
@@ -169,14 +162,12 @@ int do_verify(JCR *jcr)
         break;
       default:
          Jmsg1(jcr, M_FATAL, 0, _("Unimplemented save level %d\n"), jcr->level);
-        verify_cleanup(jcr, JS_ErrorTerminated);                    
-        return 0;
+        goto bail_out;
    }
    Dmsg1(20, ">filed: %s", fd->msg);
    bnet_fsend(fd, levelcmd, level, " ");
    if (!response(fd, OKlevel, "Level")) {
-      verify_cleanup(jcr, JS_ErrorTerminated);                   
-      return 0;
+      goto bail_out;
    }
 
    /* 
@@ -184,8 +175,7 @@ int do_verify(JCR *jcr)
     */
    bnet_fsend(fd, verifycmd);
    if (!response(fd, OKverify, "Verify")) {
-      verify_cleanup(jcr, JS_ErrorTerminated);                   
-      return 0;
+      goto bail_out;
    }
 
    /*
@@ -194,23 +184,29 @@ int do_verify(JCR *jcr)
     *  catalog depending on the run type.
     */
    /* Compare to catalog */
-   if (jcr->level == L_VERIFY_CATALOG) {
+   switch (jcr->level) { 
+   case L_VERIFY_CATALOG:
       Dmsg0(10, "Verify level=catalog\n");
       get_attributes_and_compare_to_catalog(jcr, last_full_id);
+      break;
 
-   /* Build catalog */
-   } else if (jcr->level == L_VERIFY_INIT) {
+   case L_VERIFY_INIT:
+      /* Build catalog */
       Dmsg0(10, "Verify level=init\n");
       get_attributes_and_put_in_catalog(jcr);
+      break;
 
-   } else {
+   default:
       Jmsg1(jcr, M_FATAL, 0, _("Unimplemented save level %d\n"), jcr->level);
-      verify_cleanup(jcr, JS_ErrorTerminated);                   
-      return 0;
+      goto bail_out;
    }
 
    verify_cleanup(jcr, JS_Terminated);
    return 1;
+
+bail_out:
+   verify_cleanup(jcr, JS_Terminated);
+   return 0;
 }
 
 /*
@@ -296,7 +292,7 @@ int get_attributes_and_compare_to_catalog(JCR *jcr, int last_full_id)
    struct stat statc;                /* catalog stat */
    int stat = JS_Terminated;
    char buf[MAXSTRING];
-   char *fname = (char *)get_pool_memory(PM_MESSAGE);
+   POOLMEM *fname = get_pool_memory(PM_MESSAGE);
    int do_MD5 = FALSE;
 
    memset(&fdbr, 0, sizeof(FILE_DBR));
@@ -313,20 +309,20 @@ int get_attributes_and_compare_to_catalog(JCR *jcr, int last_full_id)
       char *attr, *p;
       char Opts_MD5[MAXSTRING];        /* Verify Opts or MD5 signature */
 
-      fname = (char *)check_pool_memory_size(fname, fd->msglen);
-      jcr->fname = (char *)check_pool_memory_size(jcr->fname, fd->msglen);
+      fname = check_pool_memory_size(fname, fd->msglen);
+      jcr->fname = check_pool_memory_size(jcr->fname, fd->msglen);
       Dmsg1(50, "Atts+MD5=%s\n", fd->msg);
       if ((len = sscanf(fd->msg, "%ld %d %100s %s", &file_index, &stream, 
            Opts_MD5, fname)) != 4) {
          Jmsg3(jcr, M_FATAL, 0, _("bird<filed: bad attributes, expected 4 fields got %d\n\
  mslen=%d msg=%s\n"), len, fd->msglen, fd->msg);
-        jcr->JobStatus = JS_ErrorTerminated;
-        return 0;
+        goto bail_out;
       }
       /*
        * Got attributes stream, decode it
        */
       if (stream == STREAM_UNIX_ATTRIBUTES) {
+        jcr->jr.JobFiles++;
         attr_file_index = file_index;    /* remember attribute file_index */
         len = strlen(fd->msg);
         attr = &fd->msg[len+1];
@@ -465,8 +461,7 @@ int get_attributes_and_compare_to_catalog(JCR *jcr, int last_full_id)
         if (attr_file_index != file_index) {
             Jmsg2(jcr, M_FATAL, 0, _("MD5 index %d not same as attributes %d\n"),
               file_index, attr_file_index);
-           jcr->JobStatus = JS_ErrorTerminated;
-           return 0;
+           goto bail_out;
         } 
         if (do_MD5) {
            db_escape_string(buf, Opts_MD5, strlen(Opts_MD5));
@@ -487,8 +482,7 @@ int get_attributes_and_compare_to_catalog(JCR *jcr, int last_full_id)
    if (n < 0) {
       Jmsg2(jcr, M_FATAL, 0, _("bdird<filed: bad attributes from filed n=%d : %s\n"),
                        n, strerror(errno));
-      jcr->JobStatus = JS_ErrorTerminated;
-      return 0;
+      goto bail_out;
    }
 
    /* Now find all the files that are missing -- i.e. all files in
@@ -506,8 +500,14 @@ int get_attributes_and_compare_to_catalog(JCR *jcr, int last_full_id)
    if (jcr->fn_printed) {
       stat = JS_Differences;
    }
+   free_pool_memory(fname);
    jcr->JobStatus = stat;
    return 1;
+    
+bail_out:
+   free_pool_memory(fname);
+   jcr->JobStatus = JS_ErrorTerminated;
+   return 0;
 }
 
 /*
index 48264b2dfa423177245dd277d24012489eda0fef..a0792bf3c2df3df94ae7ea2ac7153badb6af08d5 100644 (file)
@@ -129,7 +129,7 @@ struct s_jcr {
    uint32_t PoolId;                   /* Pool record id */
    FileId_t FileId;                   /* Last file id inserted */
    uint32_t FileIndex;                /* Last FileIndex processed */
-   char *fname;                       /* name to put into catalog */
+   POOLMEM *fname;                    /* name to put into catalog */
    int fn_printed;                    /* printed filename */
    char *stime;                       /* start time for incremental/differential */
    JOB_DBR jr;                        /* Job record in Database */
index 92e4f642eac88adb6f22b963accca9f9df626a80..2295a84b893bf55ba923dfdd7a9dd1232221cd46 100644 (file)
@@ -1,8 +1,8 @@
 /* */
 #define VERSION "1.20"
 #define VSTRING "1"
-#define DATE    "21 May 2002"
-#define LSMDATE "21May02"
+#define DATE    "22 May 2002"
+#define LSMDATE "22May02"
 
 /* Debug flags */
 #define DEBUG 1