]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/src/stored/spool.c
Move reservations message lock to lock jcr only this
[bacula/bacula] / bacula / src / stored / spool.c
index 7e9d57e9cf63f9ef4eb34b23f1a24b44fe22517d..62426a0c34c13947a23327364ba5607e808869a4 100644 (file)
@@ -7,8 +7,8 @@
    many others, a complete list can be found in the file AUTHORS.
    This program is Free Software; you can redistribute it and/or
    modify it under the terms of version two of the GNU General Public
-   License as published by the Free Software Foundation plus additions
-   that are listed in the file LICENSE.
+   License as published by the Free Software Foundation and included
+   in the file LICENSE.
 
    This program is distributed in the hope that it will be useful, but
    WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -81,6 +81,8 @@ void list_spool_stats(void sendit(const char *msg, int len, void *sarg), void *a
    POOL_MEM msg(PM_MESSAGE);
    int len;
 
+   len = Mmsg(msg, _("Spooling statistics:\n"));
+
    if (spool_stats.data_jobs || spool_stats.max_data_size) {
       len = Mmsg(msg, _("Data spooling: %u active jobs, %s bytes; %u total jobs, %s max bytes/job.\n"),
          spool_stats.data_jobs, edit_uint64_with_commas(spool_stats.data_size, ed1),
@@ -97,6 +99,8 @@ void list_spool_stats(void sendit(const char *msg, int len, void *sarg), void *a
    
       sendit(msg.c_str(), len, arg);
    }
+   len = Mmsg(msg, "====\n");
+   sendit(msg.c_str(), len, arg);
 }
 
 bool begin_data_spool(DCR *dcr)
@@ -253,9 +257,8 @@ static bool despool_data(DCR *dcr, bool commit)
    rdev->max_block_size = dcr->dev->max_block_size;
    rdev->min_block_size = dcr->dev->min_block_size;
    rdev->device = dcr->dev->device;
-   rdcr = new_dcr(jcr, rdev);
+   rdcr = new_dcr(jcr, NULL, rdev);
    rdcr->spool_fd = dcr->spool_fd;
-   rdcr->jcr = jcr;                   /* set a valid jcr */
    block = dcr->block;                /* save block */
    dcr->block = rdcr->block;          /* make read and write block the same */
 
@@ -554,7 +557,7 @@ static bool write_spool_data(DCR *dcr)
 
 bool are_attributes_spooled(JCR *jcr)
 {
-   return jcr->spool_attributes && jcr->dir_bsock->spool_fd;
+   return jcr->spool_attributes && jcr->dir_bsock->m_spool_fd;
 }
 
 /*
@@ -599,13 +602,13 @@ bool commit_attribute_spool(JCR *jcr)
    char ec1[30];
 
    if (are_attributes_spooled(jcr)) {
-      if (fseeko(jcr->dir_bsock->spool_fd, 0, SEEK_END) != 0) {
+      if (fseeko(jcr->dir_bsock->m_spool_fd, 0, SEEK_END) != 0) {
          berrno be;
          Jmsg(jcr, M_FATAL, 0, _("Fseek on attributes file failed: ERR=%s\n"),
               be.bstrerror());
          goto bail_out;
       }
-      size = ftello(jcr->dir_bsock->spool_fd);
+      size = ftello(jcr->dir_bsock->m_spool_fd);
       if (size < 0) {
          berrno be;
          Jmsg(jcr, M_FATAL, 0, _("Fseek on attributes file failed: ERR=%s\n"),
@@ -641,9 +644,9 @@ bool open_attr_spool_file(JCR *jcr, BSOCK *bs)
 {
    POOLMEM *name  = get_pool_memory(PM_MESSAGE);
 
-   make_unique_spool_filename(jcr, &name, bs->fd);
-   bs->spool_fd = fopen(name, "w+b");
-   if (!bs->spool_fd) {
+   make_unique_spool_filename(jcr, &name, bs->m_fd);
+   bs->m_spool_fd = fopen(name, "w+b");
+   if (!bs->m_spool_fd) {
       berrno be;
       Jmsg(jcr, M_FATAL, 0, _("fopen attr spool file %s failed: ERR=%s\n"), name,
            be.bstrerror());
@@ -661,7 +664,7 @@ bool close_attr_spool_file(JCR *jcr, BSOCK *bs)
 {
    POOLMEM *name;
 
-   if (!bs->spool_fd) {
+   if (!bs->m_spool_fd) {
       return true;
    }
    name = get_pool_memory(PM_MESSAGE);
@@ -669,11 +672,11 @@ bool close_attr_spool_file(JCR *jcr, BSOCK *bs)
    spool_stats.attr_jobs--;
    spool_stats.total_attr_jobs++;
    V(mutex);
-   make_unique_spool_filename(jcr, &name, bs->fd);
-   fclose(bs->spool_fd);
+   make_unique_spool_filename(jcr, &name, bs->m_fd);
+   fclose(bs->m_spool_fd);
    unlink(name);
    free_pool_memory(name);
-   bs->spool_fd = NULL;
-   bs->spool = false;
+   bs->m_spool_fd = NULL;
+   bs->clear_spooling();
    return true;
 }