Skip to content

Commit 737f25c

Browse files
committed
Register atexit hook only once in pg_upgrade.
start_postmaster() registered stop_postmaster_atexit as an atexit(3) callback each time through, although the obvious intention was to do so only once per program run. The extra registrations were harmless, so long as we didn't exceed ATEXIT_MAX, but still it's a bug. Artur Zakirov, with bikeshedding by Kyotaro Horiguchi and me Discussion: <d279e817-02b5-caa6-215f-cfb05dce109a@postgrespro.ru>
1 parent 5e50a67 commit 737f25c

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

contrib/pg_upgrade/server.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,10 +175,11 @@ start_postmaster(ClusterInfo *cluster)
175175
{
176176
char cmd[MAXPGPATH * 4 + 1000];
177177
PGconn *conn;
178-
bool exit_hook_registered = false;
179178
bool pg_ctl_return = false;
180179
char socket_string[MAXPGPATH + 200];
181180

181+
static bool exit_hook_registered = false;
182+
182183
if (!exit_hook_registered)
183184
{
184185
atexit(stop_postmaster_atexit);

0 commit comments

Comments
 (0)