git.postgresql.org Git - postgresql.git/commitdiff

git projects / postgresql.git / commitdiff
? search:
summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 0912fb3)
Save errno across LWLockRelease() calls
Sun, 5 Apr 2020 08:02:00 +0000 (10:02 +0200)
Sun, 5 Apr 2020 08:03:41 +0000 (10:03 +0200)
Fixup for "Drop slot's LWLock before returning from SaveSlotToPath()"

Reported-by: Michael Paquier <michael@paquier.xyz>

diff --git a/src/backend/replication/slot.c b/src/backend/replication/slot.c
index 6499162f3772b2a842302d64128e2afc9fc6103c..1317522fbb69c5604dcabe708013ab5c3ebffa4c 100644 (file)
--- 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",
This is the main PostgreSQL git repository.
RSS Atom

AltStyle によって変換されたページ (->オリジナル) /