From: Robert Haas Date: Wed, 30 Apr 2014 21:38:18 +0000 (-0400) Subject: Consistently allow reading of messages from a detached shm_mq. X-Git-Tag: REL9_4_BETA1~87 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=5ec45bb7fa0a1495a360165a12ba5d6b4587bb4a;p=postgresql 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. --- diff --git a/src/backend/storage/ipc/shm_mq.c b/src/backend/storage/ipc/shm_mq.c index c70f3bfb45..4f7dd9c4ef 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;