aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Haas <rhaas@postgresql.org>2014-04-30 17:38:18 -0400
committerRobert Haas <rhaas@postgresql.org>2014-04-30 17:38:18 -0400
commit5ec45bb7fa0a1495a360165a12ba5d6b4587bb4a (patch)
tree2020270baa6310357d165252ee189f85b27845ae
parent2d00190495b22e0d0ba351b2cda9c95fb2e3d083 (diff)
downloadpostgresql-5ec45bb7fa0a1495a360165a12ba5d6b4587bb4a.tar.gz
postgresql-5ec45bb7fa0a1495a360165a12ba5d6b4587bb4a.zip
Consistently allow reading of messages from a detached shm_mq.
This was intended to work always, but the previous code only allowed it if at least one message was successfully read by the receiver before the sender detached the queue. Report by Petr Jelinek. Patch by me.
-rw-r--r--src/backend/storage/ipc/shm_mq.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/backend/storage/ipc/shm_mq.c b/src/backend/storage/ipc/shm_mq.c
index c70f3bfb458..4f7dd9c4ef1 100644
--- a/src/backend/storage/ipc/shm_mq.c
+++ b/src/backend/storage/ipc/shm_mq.c
@@ -406,7 +406,8 @@ shm_mq_receive(shm_mq_handle *mqh, Size *nbytesp, void **datap, bool nowait)
if (shm_mq_get_sender(mq) == NULL)
return SHM_MQ_WOULD_BLOCK;
}
- else if (!shm_mq_wait_internal(mq, &mq->mq_sender, mqh->mqh_handle))
+ else if (!shm_mq_wait_internal(mq, &mq->mq_sender, mqh->mqh_handle)
+ && shm_mq_get_sender(mq) == NULL)
{
mq->mq_detached = true;
return SHM_MQ_DETACHED;