aboutsummaryrefslogtreecommitdiff
path: root/src/backend/replication/logical/origin.c
diff options
context:
space:
mode:
authorMichael Paquier <michael@paquier.xyz>2018-08-05 05:31:56 +0900
committerMichael Paquier <michael@paquier.xyz>2018-08-05 05:31:56 +0900
commit58673b4a5fdff4d0d327c2d07e0cf8743f86f44c (patch)
tree6b7d85dd527f0e8b85eeb4f34122413749c36c7c /src/backend/replication/logical/origin.c
parent75224ac20e90d2a9ba18ead1af62c74858d48c41 (diff)
downloadpostgresql-58673b4a5fdff4d0d327c2d07e0cf8743f86f44c.tar.gz
postgresql-58673b4a5fdff4d0d327c2d07e0cf8743f86f44c.zip
Reset properly errno before calling write()
6cb3372 enforces errno to ENOSPC when less bytes than what is expected have been written when it is unset, though it forgot to properly reset errno before doing a system call to write(), causing errno to potentially come from a previous system call. Reported-by: Tom Lane Author: Michael Paquier Reviewed-by: Tom Lane Discussion: https://postgr.es/m/31797.1533326676@sss.pgh.pa.us
Diffstat (limited to 'src/backend/replication/logical/origin.c')
-rw-r--r--src/backend/replication/logical/origin.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/backend/replication/logical/origin.c b/src/backend/replication/logical/origin.c
index 595eb252d2a..46156ae6c6f 100644
--- a/src/backend/replication/logical/origin.c
+++ b/src/backend/replication/logical/origin.c
@@ -576,6 +576,7 @@ CheckPointReplicationOrigin(void)
tmppath)));
/* write magic */
+ errno = 0;
if ((write(tmpfd, &magic, sizeof(magic))) != sizeof(magic))
{
int save_errno = errno;
@@ -619,6 +620,7 @@ CheckPointReplicationOrigin(void)
/* make sure we only write out a commit that's persistent */
XLogFlush(local_lsn);
+ errno = 0;
if ((write(tmpfd, &disk_state, sizeof(disk_state))) !=
sizeof(disk_state))
{
@@ -641,6 +643,7 @@ CheckPointReplicationOrigin(void)
/* write out the CRC */
FIN_CRC32C(crc);
+ errno = 0;
if ((write(tmpfd, &crc, sizeof(crc))) != sizeof(crc))
{
int save_errno = errno;