Skip to content
Snippets Groups Projects
Commit a1480ec1 authored by Robert Haas's avatar Robert Haas
Browse files

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.
parent 872101be
No related branches found
No related tags found
No related merge requests found
...@@ -501,10 +501,12 @@ shm_mq_receive(shm_mq_handle *mqh, Size *nbytesp, void **datap, bool nowait) ...@@ -501,10 +501,12 @@ shm_mq_receive(shm_mq_handle *mqh, Size *nbytesp, void **datap, bool nowait)
{ {
if (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_get_sender(mq) == NULL)
{
if (shm_mq_counterparty_gone(mq, mqh->mqh_handle))
return SHM_MQ_DETACHED;
return SHM_MQ_WOULD_BLOCK; 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) && shm_mq_get_sender(mq) == NULL)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment