Skip to content

Commit e747c58

Browse files
committed
Fix for hang after postmaster restart. Add new proc_exit and
shmem_exit to replace exitpg().
1 parent 8fa93b0 commit e747c58

File tree

18 files changed

+130
-123
lines changed

18 files changed

+130
-123
lines changed

src/backend/bootstrap/bootstrap.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* Copyright (c) 1994, Regents of the University of California
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/bootstrap/bootstrap.c,v 1.43 1998/06/15 19:28:04 momjian Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/bootstrap/bootstrap.c,v 1.44 1998/06/27 04:53:29 momjian Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -262,7 +262,7 @@ usage(void)
262262
fprintf(stderr, " O: set BootstrapProcessing mode\n");
263263
fprintf(stderr, " P portno: specify port number\n");
264264

265-
exitpg(1);
265+
proc_exit(1);
266266
}
267267

268268

@@ -360,7 +360,7 @@ BootstrapMain(int argc, char *argv[])
360360
"database system either by specifying the -D invocation "
361361
"option or by setting the PGDATA environment variable.\n\n",
362362
argv[0]);
363-
exitpg(1);
363+
proc_exit(1);
364364
}
365365

366366
if (dbName == NULL)
@@ -370,7 +370,7 @@ BootstrapMain(int argc, char *argv[])
370370
{
371371
fputs("bootstrap backend: failed, no db name specified\n", stderr);
372372
fputs(" and no USER enviroment variable\n", stderr);
373-
exitpg(1);
373+
proc_exit(1);
374374
}
375375
}
376376

@@ -381,7 +381,7 @@ BootstrapMain(int argc, char *argv[])
381381
if (IsUnderPostmaster && portFd < 0)
382382
{
383383
fputs("backend: failed, no -P option with -postmaster opt.\n", stderr);
384-
exitpg(1);
384+
proc_exit(1);
385385
}
386386

387387
/* ----------------
@@ -770,12 +770,12 @@ cleanup()
770770
else
771771
{
772772
elog(FATAL, "Memory manager fault: cleanup called twice.\n", stderr);
773-
exitpg(1);
773+
proc_exit(1);
774774
}
775775
if (reldesc != (Relation) NULL)
776776
heap_close(reldesc);
777777
CommitTransactionCommand();
778-
exitpg(Warnings);
778+
proc_exit(Warnings);
779779
}
780780

781781
/* ----------------

src/backend/commands/async.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/commands/async.c,v 1.33 1998/06/15 19:28:11 momjian Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/commands/async.c,v 1.34 1998/06/27 04:53:29 momjian Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -477,7 +477,7 @@ Async_Listen(char *relname, int pid)
477477
*/
478478
relnamei = malloc(NAMEDATALEN); /* persists to process exit */
479479
StrNCpy(relnamei, relname, NAMEDATALEN);
480-
on_exitpg(Async_UnlistenOnExit, (caddr_t) relnamei);
480+
on_shmem_exit(Async_UnlistenOnExit, (caddr_t) relnamei);
481481
}
482482

483483
/*

src/backend/libpq/pqcomm.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/libpq/pqcomm.c,v 1.46 1998/06/21 16:39:10 momjian Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/libpq/pqcomm.c,v 1.47 1998/06/27 04:53:30 momjian Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -650,7 +650,7 @@ StreamServerPort(char *hostName, short portName, int *fdP)
650650
}
651651

652652
if (family == AF_UNIX)
653-
on_exitpg(StreamDoUnlink, NULL);
653+
on_proc_exit(StreamDoUnlink, NULL);
654654

655655
listen(fd, SOMAXCONN);
656656

src/backend/postmaster/postmaster.c

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
*
1111
*
1212
* IDENTIFICATION
13-
* $Header: /cvsroot/pgsql/src/backend/postmaster/postmaster.c,v 1.89 1998/06/18 03:43:59 momjian Exp $
13+
* $Header: /cvsroot/pgsql/src/backend/postmaster/postmaster.c,v 1.90 1998/06/27 04:53:31 momjian Exp $
1414
*
1515
* NOTES
1616
*
@@ -895,7 +895,7 @@ reset_shared(short port)
895895
static void
896896
pmdie(SIGNAL_ARGS)
897897
{
898-
exitpg(0);
898+
proc_exit(0);
899899
}
900900

901901
/*
@@ -986,9 +986,9 @@ CleanupProc(int pid,
986986
{
987987
bp = (Backend *) DLE_VAL(curr);
988988

989-
/*
990-
* ----------------- SIGUSR1 is the special signal that sez exit
991-
* without exitpg and let the user know what's going on.
989+
/* -----------------
990+
* SIGUSR1 is the special signal that says exit
991+
* without proc_exit and let the user know what's going on.
992992
* ProcSemaphoreKill() cleans up the backends semaphore. If
993993
* SendStop is set (-s on command line), then we send a SIGSTOP so
994994
* that we can core dumps from all backends by hand.
@@ -1020,10 +1020,6 @@ CleanupProc(int pid,
10201020
}
10211021

10221022
/*
1023-
* Quasi_exit means run all of the on_exitpg routines
1024-
* but don't acutally call exit(). The on_exit list of routines to do
1025-
* is also truncated.
1026-
*
10271023
* Nothing up my sleeve here, ActiveBackends means that since the last
10281024
* time we recreated shared memory and sems another frontend has
10291025
* requested and received a connection and I have forked off another
@@ -1036,7 +1032,7 @@ CleanupProc(int pid,
10361032
if (DebugLvl)
10371033
fprintf(stderr, "%s: CleanupProc: reinitializing shared memory and semaphores\n",
10381034
progname);
1039-
quasi_exitpg();
1035+
shmem_exit();
10401036
reset_shared(PostPortName);
10411037
}
10421038
}
@@ -1230,7 +1226,7 @@ DoBackend(Port *port)
12301226
* Let's clean up ourselves as the postmaster child
12311227
*/
12321228

1233-
clear_exitpg(); /* we don't want the postmaster's exitpg() handlers */
1229+
clear_proc_exit(); /* we don't want the postmaster's proc_exit() handlers */
12341230

12351231
/* ----------------
12361232
* register signal handlers.
@@ -1352,7 +1348,7 @@ ExitPostmaster(int status)
13521348
StreamClose(ServerSock_INET);
13531349
if (ServerSock_UNIX != INVALID_SOCK)
13541350
StreamClose(ServerSock_UNIX);
1355-
exitpg(status);
1351+
proc_exit(status);
13561352
}
13571353

13581354
static void

0 commit comments

Comments
 (0)