diff options
author | Peter Eisentraut <peter@eisentraut.org> | 2020-04-05 10:02:00 +0200 |
---|---|---|
committer | Peter Eisentraut <peter@eisentraut.org> | 2020-04-05 10:04:26 +0200 |
commit | 3dcaea4b007afb326616855824f32f54bfc1fe5d (patch) | |
tree | dcbd1e1befe2db3197bf0f5c94d59427b44f6fad /src | |
parent | 49b0d13d7646bc3c5af2e98772ddca493b4b86ea (diff) |
Save errno across LWLockRelease() calls
Fixup for "Drop slot's LWLock before returning from SaveSlotToPath()"
Reported-by: Michael Paquier <michael@paquier.xyz>
Diffstat (limited to 'src')
-rw-r--r-- | src/backend/replication/slot.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/src/backend/replication/slot.c b/src/backend/replication/slot.c index ce08f90695e..f58ad41eacb 100644 --- a/src/backend/replication/slot.c +++ b/src/backend/replication/slot.c @@ -1065,9 +1065,13 @@ SaveSlotToPath(ReplicationSlot *slot, const char *dir, int elevel) /* * If not an ERROR, then release the lock before returning. In case * of an ERROR, the error recovery path automatically releases the - * lock, but no harm in explicitly releasing even in that case. + * lock, but no harm in explicitly releasing even in that case. Note + * that LWLockRelease() could affect errno. */ + int save_errno = errno; + LWLockRelease(&slot->io_in_progress_lock); + errno = save_errno; ereport(elevel, (errcode_for_file_access(), errmsg("could not create file \"%s\": %m", @@ -1128,7 +1132,10 @@ SaveSlotToPath(ReplicationSlot *slot, const char *dir, int elevel) /* rename to permanent file, fsync file and directory */ if (rename(tmppath, path) != 0) { + int save_errno = errno; + LWLockRelease(&slot->io_in_progress_lock); + errno = save_errno; ereport(elevel, (errcode_for_file_access(), errmsg("could not rename file \"%s\" to \"%s\": %m", |