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

Commit55c3eef

Browse files
committed
Do not call setlocale in threads
1 parent6173cf9 commit55c3eef

File tree

13 files changed

+33
-48
lines changed

13 files changed

+33
-48
lines changed

‎src/backend/parser/gram.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
# defineYYDEBUG 0
3838
#endif
3939
#ifYYDEBUG
40-
externsession_localintbase_yydebug;
40+
externintbase_yydebug;
4141
#endif
4242

4343
/* Token type. */

‎src/backend/postmaster/bgworker.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#include"postgres.h"
1414

1515
#include<unistd.h>
16+
#include<pthread.h>
1617

1718
#include"libpq/pqsignal.h"
1819
#include"access/parallel.h"
@@ -665,7 +666,7 @@ bgworker_quickdie(SIGNAL_ARGS)
665666
* should ensure the postmaster sees this as a crash, too, but no harm in
666667
* being doubly sure.)
667668
*/
668-
exit(2);
669+
pthread_exit((void*)2);
669670
}
670671

671672
/*

‎src/backend/postmaster/bgwriter.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
#include<signal.h>
3838
#include<sys/time.h>
3939
#include<unistd.h>
40+
#include<pthread.h>
4041

4142
#include"access/xlog.h"
4243
#include"access/xlog_internal.h"
@@ -388,7 +389,7 @@ BackgroundWriterMain(void)
388389
* necessity for manual cleanup of all postmaster children.
389390
*/
390391
if (rc&WL_POSTMASTER_DEATH)
391-
exit(1);
392+
pthread_exit((void*)1);
392393

393394
prev_hibernate=can_hibernate;
394395
}
@@ -429,7 +430,7 @@ bg_quickdie(SIGNAL_ARGS)
429430
* should ensure the postmaster sees this as a crash, too, but no harm in
430431
* being doubly sure.)
431432
*/
432-
exit(2);
433+
pthread_exit((void*)2);
433434
}
434435

435436
/* SIGHUP: set flag to re-read config file at next convenient time */

‎src/backend/postmaster/checkpointer.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
#include<sys/time.h>
4141
#include<time.h>
4242
#include<unistd.h>
43+
#include<pthread.h>
4344

4445
#include"access/xlog.h"
4546
#include"access/xlog_internal.h"
@@ -565,7 +566,7 @@ CheckpointerMain(void)
565566
* necessity for manual cleanup of all postmaster children.
566567
*/
567568
if (rc&WL_POSTMASTER_DEATH)
568-
exit(1);
569+
pthread_exit((void*)1);
569570
}
570571
}
571572

@@ -843,7 +844,7 @@ chkpt_quickdie(SIGNAL_ARGS)
843844
* should ensure the postmaster sees this as a crash, too, but no harm in
844845
* being doubly sure.)
845846
*/
846-
exit(2);
847+
pthread_exit((void*)2);
847848
}
848849

849850
/* SIGHUP: set flag to re-read config file at next convenient time */

‎src/backend/postmaster/pgarch.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
#include<sys/time.h>
3232
#include<sys/wait.h>
3333
#include<unistd.h>
34+
#include<pthread.h>
3435

3536
#include"access/xlog.h"
3637
#include"access/xlog_internal.h"
@@ -240,15 +241,15 @@ PgArchiverMain(int argc, char *argv[])
240241

241242
pgarch_MainLoop();
242243

243-
exit(0);
244+
pthread_exit(0);
244245
}
245246

246247
/* SIGQUIT signal handler for archiver process */
247248
staticvoid
248249
pgarch_exit(SIGNAL_ARGS)
249250
{
250251
/* SIGQUIT means curl up and die ... */
251-
exit(1);
252+
pthread_exit((void*)1);
252253
}
253254

254255
/* SIGHUP signal handler for archiver process */

‎src/backend/postmaster/pgstat.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4425,7 +4425,7 @@ PgstatCollectorMain(int argc, char *argv[])
44254425
*/
44264426
pgstat_write_statsfiles(true, true);
44274427

4428-
exit(0);
4428+
pthread_exit(0);
44294429
}
44304430

44314431

‎src/backend/postmaster/postmaster.c

Lines changed: 8 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -394,7 +394,7 @@ typedef size_t thread_status_t;
394394
* postmaster.c - function prototypes
395395
*/
396396
staticvoidCloseServerPorts(intstatus,Datumarg);
397-
staticvoidunlink_external_pid_file(intstatus,Datumarg);
397+
staticvoidunlink_external_pid_file(void);
398398
staticvoidgetInstallationPaths(constchar*argv0);
399399
staticvoidcheckDataDir(void);
400400
staticPort*ConnCreate(intserverFd);
@@ -494,8 +494,8 @@ static void restore_backend_variables(ThreadContext* ctx);
494494

495495
/* Macros to check exit status of a child process */
496496
#defineEXIT_STATUS_0(st) ((st) == 0)
497-
#defineEXIT_STATUS_1(st) (WIFEXITED(st) && WEXITSTATUS(st) == 1)
498-
#defineEXIT_STATUS_3(st) (WIFEXITED(st) && WEXITSTATUS(st) == 3)
497+
#defineEXIT_STATUS_1(st) ((st) == 1)
498+
#defineEXIT_STATUS_3(st) ((st) == 3)
499499

500500
#ifndefWIN32
501501
/*
@@ -1167,7 +1167,7 @@ PostmasterMain(int argc, char *argv[])
11671167
write_stderr("%s: could not write external PID file \"%s\": %s\n",
11681168
progname,external_pid_file,strerror(errno));
11691169

1170-
on_proc_exit(unlink_external_pid_file,0);
1170+
atexit(unlink_external_pid_file);
11711171
}
11721172

11731173
/*
@@ -1355,7 +1355,7 @@ CloseServerPorts(int status, Datum arg)
13551355
* on_proc_exit callback to delete external_pid_file
13561356
*/
13571357
staticvoid
1358-
unlink_external_pid_file(intstatus,Datumarg)
1358+
unlink_external_pid_file(void)
13591359
{
13601360
if (external_pid_file)
13611361
unlink(external_pid_file);
@@ -1697,13 +1697,6 @@ ServerLoop(void)
16971697
if (port)
16981698
{
16991699
BackendStartup(port);
1700-
#if0
1701-
/*
1702-
* We no longer need the open socket or port structure
1703-
* in this process
1704-
*/
1705-
StreamClose(port->sock);
1706-
#endif
17071700
ConnFree(port);
17081701
}
17091702
}
@@ -3554,14 +3547,14 @@ LogChildExit(int lev, const char *procname, pthread_t pid, thread_status_t exits
35543547
activity_buffer,
35553548
sizeof(activity_buffer));
35563549

3557-
if (WIFEXITED(exitstatus))
3550+
if (1/*WIFEXITED(exitstatus)*/)
35583551
ereport(lev,
35593552

35603553
/*------
35613554
translator: %s is a noun phrase describing a child process, such as
35623555
"server process" */
3563-
(errmsg("%s (PID %ld) exited with exit code %d",
3564-
procname,pid,WEXITSTATUS(exitstatus)),
3556+
(errmsg("%s (PID %ld) exited with exit code %ld",
3557+
procname,pid,exitstatus),
35653558
activity ?errdetail("Failed process was running: %s",activity) :0));
35663559
elseif (WIFSIGNALED(exitstatus))
35673560
#if defined(WIN32)
@@ -4764,21 +4757,6 @@ SubPostmasterMain(int argc, char *argv[])
47644757
staticvoid
47654758
ExitPostmaster(intstatus)
47664759
{
4767-
#ifdefHAVE_PTHREAD_IS_THREADED_NP
4768-
4769-
/*
4770-
* There is no known cause for a postmaster to become multithreaded after
4771-
* startup. Recheck to account for the possibility of unknown causes.
4772-
* This message uses LOG level, because an unclean shutdown at this point
4773-
* would usually not look much different from a clean shutdown.
4774-
*/
4775-
if (pthread_is_threaded_np()!=0)
4776-
ereport(LOG,
4777-
(errcode(ERRCODE_INTERNAL_ERROR),
4778-
errmsg_internal("postmaster became multithreaded"),
4779-
errdetail("Please report this to <pgsql-bugs@postgresql.org>.")));
4780-
#endif
4781-
47824760
/* should cleanup shared memory and kill all backends */
47834761

47844762
/*

‎src/backend/postmaster/walwriter.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343

4444
#include<signal.h>
4545
#include<unistd.h>
46+
#include<pthread.h>
4647

4748
#include"access/xlog.h"
4849
#include"libpq/pqsignal.h"
@@ -300,7 +301,7 @@ WalWriterMain(void)
300301
* necessity for manual cleanup of all postmaster children.
301302
*/
302303
if (rc&WL_POSTMASTER_DEATH)
303-
exit(1);
304+
pthread_exit((void*)1);
304305
}
305306
}
306307

@@ -339,7 +340,7 @@ wal_quickdie(SIGNAL_ARGS)
339340
* should ensure the postmaster sees this as a crash, too, but no harm in
340341
* being doubly sure.)
341342
*/
342-
exit(2);
343+
pthread_exit((void*)2);
343344
}
344345

345346
/* SIGHUP: set flag to re-read config file at next convenient time */

‎src/backend/storage/ipc/ipc.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ session_local boolproc_exit_inprogress = false;
4444
* This flag tracks whether we've called atexit() in the current process
4545
* (or in the parent postmaster).
4646
*/
47-
staticsession_localboolatexit_callback_setup=false;
47+
staticboolatexit_callback_setup=true;/* do not perform at exit cleanup */
4848

4949
/* local functions */
5050
staticvoidproc_exit_prepare(intcode);
@@ -301,7 +301,6 @@ on_proc_exit(pg_on_exit_callback function, Datum arg)
301301
on_proc_exit_list[on_proc_exit_index].arg=arg;
302302

303303
++on_proc_exit_index;
304-
305304
if (!atexit_callback_setup)
306305
{
307306
atexit(atexit_callback);

‎src/backend/utils/adt/float.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -468,7 +468,6 @@ float8in_internal(char *num, char **endptr_p,
468468
if (endptr==num||errno!=0)
469469
{
470470
intsave_errno=errno;
471-
472471
/*
473472
* C99 requires that strtod() accept NaN, [+-]Infinity, and [+-]Inf,
474473
* but not all platforms support all of these (and some accept them

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp