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:03:41 +0200 |
commit | 250041a561a8cf34d981b2adbcf4b3b8030e24fd (patch) | |
tree | 6dbfb761b43b3ed4a9e250abfff12f674665c4f8 | |
parent | 0912fb39cab35913907ce0eaa11e0504203153c5 (diff) | |
download | postgresql-250041a561a8cf34d981b2adbcf4b3b8030e24fd.tar.gz postgresql-250041a561a8cf34d981b2adbcf4b3b8030e24fd.zip |
Save errno across LWLockRelease() calls
Fixup for "Drop slot's LWLock before returning from SaveSlotToPath()"
Reported-by: Michael Paquier <michael@paquier.xyz>
-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 6499162f377..1317522fbb6 100644 --- a/src/backend/replication/slot.c +++ b/src/backend/replication/slot.c @@ -1260,9 +1260,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", @@ -1329,7 +1333,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", |