convert libpgport's pqsignal() to a void function
Nathan Bossart <nathandbossart@gmail.com>
From: Nathan Bossart <nathandbossart@gmail.com>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Fujii Masao <masao.fujii@oss.nttdata.com>, Andy Fan <zhihuifan1213@163.com>, pgsql-hackers@lists.postgresql.org
Date: 2025-01-15T02:45:12Z
Lists: pgsql-hackers
Attachments
(moving to a new thread) On Mon, Jan 13, 2025 at 10:04:31AM -0600, Nathan Bossart wrote: > On Sat, Jan 11, 2025 at 02:04:13PM -0500, Tom Lane wrote: >> BTW, this decouples legacy-pqsignal.c from pqsignal.c enough >> that we could now do what's contemplated in the comments from >> 3b00fdba9: simplify that version by making it return void, >> or perhaps better just a true/false success report. >> I've not touched that point here, though. > > I think it should just return void since AFAICT nobody checks the return > value. But it would probably be a good idea to add some sort of error > checking within the function. I've attached a draft patch that adds some > new assertions. I originally tried to use elog() where it was available, > but besides making the code even more unreadable, I think it's unnecessary > (since AFAICT any problems are likely coding errors). With commit 9a45a89 in place, this is now possible. I've attached a new version of the patch with a more fleshed-out commit message and a small comment fix. For background, the protections added by commit 3b00fdb introduced race conditions to pqsignal() that could lead to bogus return values. That's of little consequence since nobody seems to look at the return values, but it would have been nice to convert it to a void function to avoid any possibility of a bogus return value. Unfortunately, doing so would have required also modifying legacy-pqsignal.c's version of the function, which would've required an SONAME bump, which didn't seem worth it. Or so I thought... Thanks to commit 9a45a89, legacy-pqsignal.c now has its own dedicated extern for pqsignal(), which decouples it enough that we can follow through with changing libpqport's pqsignal() to a void function. Thoughts? -- nathan
Commits
-
Remove redefinitions of SIG_* macros in win32_port.h.
- 0dc9c7d200e5 18.0 landed
-
Convert libpgport's pqsignal() to a void function.
- d4a43b283751 18.0 landed
-
Avoid calling pqsignal() with invalid signals on Windows frontends.
- 5cda4fdb0beb 18.0 landed
-
Avoid symbol collisions between pqsignal.c and legacy-pqsignal.c.
- 9a45a89c38f3 18.0 cited
-
Check that MyProcPid == getpid() in backend signal handlers.
- 3b00fdba9f20 17.0 cited
-
Further refactoring of c.h and nearby files.
- ed9b3606dadb 11.0 cited
-
Here's the latest win32 signals code, this time in the form of a patch
- 50491963cb6e 8.0.0 cited
-
Add C version of initdb, from Andrew Dunstan.
- 279598bb7138 8.0.0 cited
-
Allow Win32 to compile under MinGW. Major changes are:
- 12c942383296 7.4.1 cited