diff options
| author | Robert Haas | 2015-10-23 02:01:11 +0000 |
|---|---|---|
| committer | Robert Haas | 2015-10-23 02:04:05 +0000 |
| commit | 5eca6cf99411bfd47f43fc742552c9a2ae459bc8 (patch) | |
| tree | e9754cdec1c14776b8b5c44ef996797e690a533d | |
| parent | 87abcb4ebd48f5d8f7244236f8839854c1861537 (diff) | |
shm_mq: Repair breakage from previous commit.
If the counterparty writes some data into the queue and then detaches,
it's wrong to return SHM_MQ_DETACHED right away. If we do that, we
fail to read whatever was written.
| -rw-r--r-- | src/backend/storage/ipc/shm_mq.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/backend/storage/ipc/shm_mq.c b/src/backend/storage/ipc/shm_mq.c index 296f0bda40c..c386b2207a1 100644 --- a/src/backend/storage/ipc/shm_mq.c +++ b/src/backend/storage/ipc/shm_mq.c @@ -405,10 +405,12 @@ shm_mq_receive(shm_mq_handle *mqh, Size *nbytesp, void **datap, bool nowait) { if (nowait) { - if (shm_mq_counterparty_gone(mq, mqh->mqh_handle)) - return SHM_MQ_DETACHED; if (shm_mq_get_sender(mq) == NULL) + { + if (shm_mq_counterparty_gone(mq, mqh->mqh_handle)) + return SHM_MQ_DETACHED; return SHM_MQ_WOULD_BLOCK; + } } else if (!shm_mq_wait_internal(mq, &mq->mq_sender, mqh->mqh_handle) && shm_mq_get_sender(mq) == NULL) |
