Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitf5bfba5

Browse files
committed
shm_mq_sendv: Fix flushing bug when receiver not yet attached.
With the old logic, when the reciever had not yet attached, we wouldnever call shm_mq_inc_bytes_written(), even if force_flush = truewas specified. That could result in a situation where data that thesender believes it has sent is never received.Along the way, remove a useless function prototype for a nonexistentfunction from shm_mq.h.Commit4684643 introduced theseproblems.Pavan Deolasee, with a few changes by me.Discussion:https://postgr.es/m/CABOikdPkwtLLCTnzzmpSMXo3QZa2yXq0J7Q61ssdLFAJYrOVvQ@mail.gmail.com
1 parent0a050ee commitf5bfba5

File tree

2 files changed

+5
-7
lines changed

2 files changed

+5
-7
lines changed

‎src/backend/storage/ipc/shm_mq.c

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -518,8 +518,7 @@ shm_mq_sendv(shm_mq_handle *mqh, shm_mq_iovec *iov, int iovcnt, bool nowait,
518518

519519
/*
520520
* If the counterparty is known to have attached, we can read mq_receiver
521-
* without acquiring the spinlock and assume it isn't NULL. Otherwise,
522-
* more caution is needed.
521+
* without acquiring the spinlock. Otherwise, more caution is needed.
523522
*/
524523
if (mqh->mqh_counterparty_attached)
525524
receiver=mq->mq_receiver;
@@ -528,9 +527,8 @@ shm_mq_sendv(shm_mq_handle *mqh, shm_mq_iovec *iov, int iovcnt, bool nowait,
528527
SpinLockAcquire(&mq->mq_mutex);
529528
receiver=mq->mq_receiver;
530529
SpinLockRelease(&mq->mq_mutex);
531-
if (receiver==NULL)
532-
returnSHM_MQ_SUCCESS;
533-
mqh->mqh_counterparty_attached= true;
530+
if (receiver!=NULL)
531+
mqh->mqh_counterparty_attached= true;
534532
}
535533

536534
/*
@@ -541,7 +539,8 @@ shm_mq_sendv(shm_mq_handle *mqh, shm_mq_iovec *iov, int iovcnt, bool nowait,
541539
if (force_flush||mqh->mqh_send_pending> (mq->mq_ring_size >>2))
542540
{
543541
shm_mq_inc_bytes_written(mq,mqh->mqh_send_pending);
544-
SetLatch(&receiver->procLatch);
542+
if (receiver!=NULL)
543+
SetLatch(&receiver->procLatch);
545544
mqh->mqh_send_pending=0;
546545
}
547546

‎src/include/storage/shm_mq.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,6 @@ extern shm_mq_result shm_mq_sendv(shm_mq_handle *mqh, shm_mq_iovec *iov,
7676
intiovcnt,boolnowait,boolforce_flush);
7777
externshm_mq_resultshm_mq_receive(shm_mq_handle*mqh,
7878
Size*nbytesp,void**datap,boolnowait);
79-
externvoidshm_mq_flush(shm_mq_handle*mqh);
8079

8180
/* Wait for our counterparty to attach to the queue. */
8281
externshm_mq_resultshm_mq_wait_for_attach(shm_mq_handle*mqh);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp