Skip to content

Commit 3338a98

Browse files
committed
test_shm_mq: Replace WAIT_EVENT_EXTENSION with custom wait events
Two custom wait events are added here: - "TestShmMqBgWorkerStartup", when setting up a set of bgworkers in wait_for_workers_to_become_ready(). - "TestShmMqMessageQueue", when waiting for a queued message in test_shm_mq_pipelined(). Author: Masahiro Ikeda Discussion: https://postgr.es/m/197bce267fa691a0ac62c86c4ab904c4@oss.nttdata.com
1 parent c8e318b commit 3338a98

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

src/test/modules/test_shm_mq/setup.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@ static void wait_for_workers_to_become_ready(worker_state *wstate,
4040
volatile test_shm_mq_header *hdr);
4141
static bool check_worker_status(worker_state *wstate);
4242

43+
/* value cached, fetched from shared memory */
44+
static uint32 we_bgworker_startup = 0;
45+
4346
/*
4447
* Set up a dynamic shared memory segment and zero or more background workers
4548
* for a test run.
@@ -278,9 +281,13 @@ wait_for_workers_to_become_ready(worker_state *wstate,
278281
break;
279282
}
280283

284+
/* first time, allocate or get the custom wait event */
285+
if (we_bgworker_startup == 0)
286+
we_bgworker_startup = WaitEventExtensionNew("TestShmMqBgWorkerStartup");
287+
281288
/* Wait to be signaled. */
282289
(void) WaitLatch(MyLatch, WL_LATCH_SET | WL_EXIT_ON_PM_DEATH, 0,
283-
WAIT_EVENT_EXTENSION);
290+
we_bgworker_startup);
284291

285292
/* Reset the latch so we don't spin. */
286293
ResetLatch(MyLatch);

src/test/modules/test_shm_mq/test.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ PG_FUNCTION_INFO_V1(test_shm_mq_pipelined);
2828
static void verify_message(Size origlen, char *origdata, Size newlen,
2929
char *newdata);
3030

31+
/* value cached, fetched from shared memory */
32+
static uint32 we_message_queue = 0;
33+
3134
/*
3235
* Simple test of the shared memory message queue infrastructure.
3336
*
@@ -225,14 +228,18 @@ test_shm_mq_pipelined(PG_FUNCTION_ARGS)
225228

226229
if (wait)
227230
{
231+
/* first time, allocate or get the custom wait event */
232+
if (we_message_queue == 0)
233+
we_message_queue = WaitEventExtensionNew("TestShmMqMessageQueue");
234+
228235
/*
229236
* If we made no progress, wait for one of the other processes to
230237
* which we are connected to set our latch, indicating that they
231238
* have read or written data and therefore there may now be work
232239
* for us to do.
233240
*/
234241
(void) WaitLatch(MyLatch, WL_LATCH_SET | WL_EXIT_ON_PM_DEATH, 0,
235-
WAIT_EVENT_EXTENSION);
242+
we_message_queue);
236243
ResetLatch(MyLatch);
237244
CHECK_FOR_INTERRUPTS();
238245
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy