]> git.ipfire.org Git - thirdparty/bacula.git/commitdiff
Fix issue with data spooling introduced in 16.0
authorEric Bollengier <eric@baculasystems.com>
Thu, 25 May 2023 12:42:44 +0000 (14:42 +0200)
committerEric Bollengier <eric@baculasystems.com>
Thu, 14 Sep 2023 11:57:01 +0000 (13:57 +0200)
bacula/src/stored/spool.c

index fe5b8eed2bc3941db303c635018c4c2f504959d4..f5f47fb247dd88396cc07a1f999222cffb1f1545 100644 (file)
@@ -2,6 +2,7 @@
    Bacula(R) - The Network Backup Solution
 
    Copyright (C) 2000-2023 Kern Sibbald
+   All rights reserved.
 
    The original author of Bacula is Kern Sibbald, with contributions
    from many others, a complete list can be found in the file AUTHORS.
@@ -238,8 +239,8 @@ static bool despool_data(DCR *dcr, bool commit)
    rdev->device = dcr->dev->device;
    rdcr = new_dcr(jcr, NULL, rdev, SD_READ);
    rdcr->spool_fd = dcr->spool_fd;
-   block = rdcr->block;                /* save block */
-   rdcr->block = dcr->block;          /* make read and write block the same */
+   block = dcr->block;                /* save block */
+   dcr->block = rdcr->block;          /* make read and write block the same */
 
    Dmsg1(800, "read/write block size = %d\n", block->buf_len);
    lseek(rdcr->spool_fd, 0, SEEK_SET); /* rewind */
@@ -302,7 +303,7 @@ static bool despool_data(DCR *dcr, bool commit)
          despool_elapsed / 3600, despool_elapsed % 3600 / 60, despool_elapsed % 60,
          edit_uint64_with_suffix(jcr->dcr->job_spool_size / despool_elapsed, ec1));
 
-   rdcr->block = block;                /* reset block */
+   dcr->block = block;                /* reset block */
 
 #if defined(HAVE_POSIX_FADVISE) && defined(POSIX_FADV_DONTNEED)
    posix_fadvise(rdcr->spool_fd, 0, 0, POSIX_FADV_DONTNEED);
@@ -437,6 +438,7 @@ bool write_block_to_spool_file(DCR *dcr)
    if (block->binbuf <= WRITE_BLKHDR_LENGTH) {  /* Does block have data in it? */
       return true;
    }
+
    hlen = sizeof(spool_hdr);
    wlen = block->binbuf;
    P(dcr->dev->spool_mutex);