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

Commitef848f4

Browse files
committed
Use standard SIGTERM signal handler die() in test_shm_mq worker.
Previously test_shm_mq worker used the stripped-down version of die()as the SIGTERM signal handler. This commit makes it use die(), instead,to simplify the code.In terms of the code, the difference between die() and the stripped-downversion previously used is whether the signal handler directly may callProcessInterrupts() or not. But this difference doesn't exist ina background worker because, in bgworker, DoingCommandRead flag willnever be true and die() will never call ProcessInterrupts() directly.Therefore test_shm_mq worker can safely use die(), like other bgworkerproceses (e.g., logical replication apply launcher or autoprewarm worker)currently do.Thanks to Craig Ringer for the report and investigation of the issue.Author: Bharath RupireddyReviewed-by: Fujii MasaoDiscussion:https://postgr.es/m/CAGRY4nxsAe_1k_9g5b47orA0S011iBoHsXHFMH7cg7HV0O1bwQ@mail.gmail.com
1 parent2a08477 commitef848f4

File tree

1 file changed

+3
-25
lines changed

1 file changed

+3
-25
lines changed

‎src/test/modules/test_shm_mq/worker.c

Lines changed: 3 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@
2424
#include"storage/procarray.h"
2525
#include"storage/shm_mq.h"
2626
#include"storage/shm_toc.h"
27+
#include"tcop/tcopprot.h"
2728

2829
#include"test_shm_mq.h"
2930

30-
staticvoidhandle_sigterm(SIGNAL_ARGS);
3131
staticvoidattach_to_queues(dsm_segment*seg,shm_toc*toc,
3232
intmyworkernumber,shm_mq_handle**inqhp,
3333
shm_mq_handle**outqhp);
@@ -58,10 +58,9 @@ test_shm_mq_main(Datum main_arg)
5858
* Establish signal handlers.
5959
*
6060
* We want CHECK_FOR_INTERRUPTS() to kill off this worker process just as
61-
* it would a normal user backend. To make that happen, we establish a
62-
* signal handler that is a stripped-down version of die().
61+
* it would a normal user backend. To make that happen, we use die().
6362
*/
64-
pqsignal(SIGTERM,handle_sigterm);
63+
pqsignal(SIGTERM,die);
6564
BackgroundWorkerUnblockSignals();
6665

6766
/*
@@ -196,24 +195,3 @@ copy_messages(shm_mq_handle *inqh, shm_mq_handle *outqh)
196195
break;
197196
}
198197
}
199-
200-
/*
201-
* When we receive a SIGTERM, we set InterruptPending and ProcDiePending just
202-
* like a normal backend. The next CHECK_FOR_INTERRUPTS() will do the right
203-
* thing.
204-
*/
205-
staticvoid
206-
handle_sigterm(SIGNAL_ARGS)
207-
{
208-
intsave_errno=errno;
209-
210-
SetLatch(MyLatch);
211-
212-
if (!proc_exit_inprogress)
213-
{
214-
InterruptPending= true;
215-
ProcDiePending= true;
216-
}
217-
218-
errno=save_errno;
219-
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp