agora inbox for [email protected]
help / color / mirror / Atom feedFrom: Kyotaro Horiguchi <[email protected]>
Subject: [PATCH] Protect dsm_impl from EINTR
Date: Thu, 2 Apr 2020 17:09:35 +0900
dsm_impl functions should not error-out by EINTR.
---
src/backend/storage/ipc/dsm_impl.c | 16 ++++++++++++++--
1 file changed, 14 insertions(+), 2 deletions(-)
diff --git a/src/backend/storage/ipc/dsm_impl.c b/src/backend/storage/ipc/dsm_impl.c
index 1972aecbed..f4e7350a5e 100644
--- a/src/backend/storage/ipc/dsm_impl.c
+++ b/src/backend/storage/ipc/dsm_impl.c
@@ -360,7 +360,11 @@ dsm_impl_posix_resize(int fd, off_t size)
int rc;
/* Truncate (or extend) the file to the requested size. */
- rc = ftruncate(fd, size);
+ do
+ {
+ rc = ftruncate(fd, size);
+ } while (rc < 0 && errno == EINTR &&
+ !(ProcDiePending || QueryCancelPending));
/*
* On Linux, a shm_open fd is backed by a tmpfs file. After resizing with
@@ -874,11 +878,19 @@ dsm_impl_mmap(dsm_op op, dsm_handle handle, Size request_size,
while (success && remaining > 0)
{
Size goal = remaining;
+ Size rc;
if (goal > ZBUFFER_SIZE)
goal = ZBUFFER_SIZE;
pgstat_report_wait_start(WAIT_EVENT_DSM_FILL_ZERO_WRITE);
- if (write(fd, zbuffer, goal) == goal)
+
+ do
+ {
+ rc = write(fd, zbuffer, goal);
+ } while (rc < 0 && errno == EINTR &&
+ !(ProcDiePending || QueryCancelPending));
+
+ if (rc == goal)
remaining -= goal;
else
success = false;
--
2.18.2
----Next_Part(Thu_Apr__2_17_25_40_2020_920)----
view thread (2+ messages) latest in thread
reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: [email protected]
Cc: [email protected]
Subject: Re: [PATCH] Protect dsm_impl from EINTR
In-Reply-To: <no-message-id-194425@localhost>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox