diff options
author | Magnus Hagander <magnus@hagander.net> | 2018-04-03 13:57:49 +0200 |
---|---|---|
committer | Magnus Hagander <magnus@hagander.net> | 2018-04-03 13:57:49 +0200 |
commit | a08dc711952081d63577fc182fcf955958f70add (patch) | |
tree | 1326d19d3396f0cec1356d37eefb57c624de8cd0 /src | |
parent | 4eb77d50c21ddd35b77421c27e0d7853eb4f9202 (diff) | |
download | postgresql-a08dc711952081d63577fc182fcf955958f70add.tar.gz postgresql-a08dc711952081d63577fc182fcf955958f70add.zip |
Fix for checksum validation patch
Reorder the check for non-BLCKSZ size reads to make sure we don't abort
sending the file in this case.
Missed in the previous commit.
Diffstat (limited to 'src')
-rw-r--r-- | src/backend/replication/basebackup.c | 36 |
1 files changed, 18 insertions, 18 deletions
diff --git a/src/backend/replication/basebackup.c b/src/backend/replication/basebackup.c index 300dbfbcd6a..c5b83232fdf 100644 --- a/src/backend/replication/basebackup.c +++ b/src/backend/replication/basebackup.c @@ -1410,26 +1410,26 @@ sendFile(const char *readfilename, const char *tarfilename, struct stat *statbuf while ((cnt = fread(buf, 1, Min(sizeof(buf), statbuf->st_size - len), fp)) > 0) { - if (verify_checksum) + /* + * The checksums are verified at block level, so we iterate over + * the buffer in chunks of BLCKSZ, after making sure that + * TAR_SEND_SIZE/buf is divisible by BLCKSZ and we read a multiple + * of BLCKSZ bytes. + */ + Assert(TAR_SEND_SIZE % BLCKSZ == 0); + + if (verify_checksum && (cnt % BLCKSZ != 0)) { - /* - * The checksums are verified at block level, so we iterate over - * the buffer in chunks of BLCKSZ, after making sure that - * TAR_SEND_SIZE/buf is divisible by BLCKSZ and we read a multiple - * of BLCKSZ bytes. - */ - Assert(TAR_SEND_SIZE % BLCKSZ == 0); + ereport(WARNING, + (errmsg("cannot verify checksum in file \"%s\", block " + "%d: read buffer size %d and page size %d " + "differ", + readfilename, blkno, (int) cnt, BLCKSZ))); + verify_checksum = false; + } - if (cnt % BLCKSZ != 0) - { - ereport(WARNING, - (errmsg("cannot verify checksum in file \"%s\", block " - "%d: read buffer size %d and page size %d " - "differ", - readfilename, blkno, (int) cnt, BLCKSZ))); - verify_checksum = false; - continue; - } + if (verify_checksum) + { for (i = 0; i < cnt / BLCKSZ; i++) { page = buf + BLCKSZ * i; |