mirror of
https://github.com/postgres/postgres.git
synced 2025-05-05 09:19:17 +03:00
Save errno across LWLockRelease() calls
Fixup for "Drop slot's LWLock before returning from SaveSlotToPath()" Reported-by: Michael Paquier <michael@paquier.xyz>
This commit is contained in:
parent
49b0d13d76
commit
3dcaea4b00
@ -1065,9 +1065,13 @@ SaveSlotToPath(ReplicationSlot *slot, const char *dir, int elevel)
|
|||||||
/*
|
/*
|
||||||
* If not an ERROR, then release the lock before returning. In case
|
* If not an ERROR, then release the lock before returning. In case
|
||||||
* of an ERROR, the error recovery path automatically releases the
|
* 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);
|
LWLockRelease(&slot->io_in_progress_lock);
|
||||||
|
errno = save_errno;
|
||||||
ereport(elevel,
|
ereport(elevel,
|
||||||
(errcode_for_file_access(),
|
(errcode_for_file_access(),
|
||||||
errmsg("could not create file \"%s\": %m",
|
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 */
|
/* rename to permanent file, fsync file and directory */
|
||||||
if (rename(tmppath, path) != 0)
|
if (rename(tmppath, path) != 0)
|
||||||
{
|
{
|
||||||
|
int save_errno = errno;
|
||||||
|
|
||||||
LWLockRelease(&slot->io_in_progress_lock);
|
LWLockRelease(&slot->io_in_progress_lock);
|
||||||
|
errno = save_errno;
|
||||||
ereport(elevel,
|
ereport(elevel,
|
||||||
(errcode_for_file_access(),
|
(errcode_for_file_access(),
|
||||||
errmsg("could not rename file \"%s\" to \"%s\": %m",
|
errmsg("could not rename file \"%s\" to \"%s\": %m",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user