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

Commit6173cf9

Browse files
committed
Fix non-reentrant function calls
1 parent49a6ef0 commit6173cf9

File tree

27 files changed

+201
-267
lines changed

27 files changed

+201
-267
lines changed

‎configure

Lines changed: 3 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -13481,16 +13481,11 @@ fi
1348113481
ac_fn_c_check_func"$LINENO""getopt""ac_cv_func_getopt"
1348213482
iftest"x$ac_cv_func_getopt" = xyes;then:
1348313483
$as_echo"#define HAVE_GETOPT 1">>confdefs.h
13484-
13485-
else
13486-
case"$LIBOBJS"in
13487-
*" getopt.$ac_objext"* ) ;;
13488-
*) LIBOBJS="$LIBOBJS getopt.$ac_objext"
13489-
;;
13490-
esac
13491-
1349213484
fi
1349313485

13486+
# Always link our thread-safe versoin of getopt
13487+
LIBOBJS="$LIBOBJS getopt.$ac_objext getopt_long.$ac_objext"
13488+
1349413489
ac_fn_c_check_func"$LINENO""getrusage""ac_cv_func_getrusage"
1349513490
iftest"x$ac_cv_func_getrusage" = xyes;then:
1349613491
$as_echo"#define HAVE_GETRUSAGE 1">>confdefs.h
@@ -13701,52 +13696,7 @@ if test x"$ac_cv_type_struct_option" = xyes ; then
1370113696
ac_fn_c_check_func"$LINENO""getopt_long""ac_cv_func_getopt_long"
1370213697
iftest"x$ac_cv_func_getopt_long" = xyes;then:
1370313698
$as_echo"#define HAVE_GETOPT_LONG 1">>confdefs.h
13704-
13705-
else
13706-
case"$LIBOBJS"in
13707-
*" getopt_long.$ac_objext"* ) ;;
13708-
*) LIBOBJS="$LIBOBJS getopt_long.$ac_objext"
13709-
;;
13710-
esac
13711-
1371213699
fi
13713-
13714-
13715-
else
13716-
case"$LIBOBJS"in
13717-
*" getopt_long.$ac_objext"* ) ;;
13718-
*) LIBOBJS="$LIBOBJS getopt_long.$ac_objext"
13719-
;;
13720-
esac
13721-
13722-
fi
13723-
13724-
# Solaris' getopt() doesn't do what we want for long options, so always use
13725-
# our version on that platform.
13726-
iftest"$PORTNAME" ="solaris";then
13727-
case"$LIBOBJS"in
13728-
*" getopt.$ac_objext"* ) ;;
13729-
*) LIBOBJS="$LIBOBJS getopt.$ac_objext"
13730-
;;
13731-
esac
13732-
13733-
fi
13734-
13735-
# mingw has adopted a GNU-centric interpretation of optind/optreset,
13736-
# so always use our version on Windows.
13737-
iftest"$PORTNAME" ="win32";then
13738-
case"$LIBOBJS"in
13739-
*" getopt.$ac_objext"* ) ;;
13740-
*) LIBOBJS="$LIBOBJS getopt.$ac_objext"
13741-
;;
13742-
esac
13743-
13744-
case"$LIBOBJS"in
13745-
*" getopt_long.$ac_objext"* ) ;;
13746-
*) LIBOBJS="$LIBOBJS getopt_long.$ac_objext"
13747-
;;
13748-
esac
13749-
1375013700
fi
1375113701

1375213702
# Win32 (really MinGW) support

‎contrib/spi/refint.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@ typedef struct
2323
SPIPlanPtr*splan;
2424
}EPlan;
2525

26-
staticEPlan*FPlans=NULL;
27-
staticintnFPlans=0;
28-
staticEPlan*PPlans=NULL;
29-
staticintnPPlans=0;
26+
staticsession_localEPlan*FPlans=NULL;
27+
staticsession_localintnFPlans=0;
28+
staticsession_localEPlan*PPlans=NULL;
29+
staticsession_localintnPPlans=0;
3030

3131
staticEPlan*find_plan(char*ident,EPlan**eplan,int*nplans);
3232

‎contrib/spi/timetravel.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,16 +30,16 @@ typedef struct
3030
SPIPlanPtrsplan;
3131
}EPlan;
3232

33-
staticEPlan*Plans=NULL;/* for UPDATE/DELETE */
34-
staticintnPlans=0;
33+
staticsession_localEPlan*Plans=NULL;/* for UPDATE/DELETE */
34+
staticsession_localintnPlans=0;
3535

3636
typedefstruct_TTOffList
3737
{
3838
struct_TTOffList*next;
3939
charname[FLEXIBLE_ARRAY_MEMBER];
4040
}TTOffList;
4141

42-
staticTTOffList*TTOff=NULL;
42+
staticsession_localTTOffList*TTOff=NULL;
4343

4444
staticintfindTTStatus(char*name);
4545
staticEPlan*find_plan(char*ident,EPlan**eplan,int*nplans);

‎src/backend/access/transam/varsup.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
#defineVAR_OID_PREFETCH8192
3232

3333
/* pointer to "variable cache" in shared memory (set up by shmem.c) */
34-
session_localVariableCacheShmemVariableCache=NULL;
34+
VariableCacheShmemVariableCache=NULL;
3535

3636

3737
/*

‎src/backend/bootstrap/bootstrap.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -228,8 +228,9 @@ AuxiliaryProcessMain(int argc, char *argv[])
228228
/* If no -x argument, we are a CheckerProcess */
229229
MyAuxProcType=CheckerProcess;
230230

231-
while ((flag=getopt(argc,argv,"B:c:d:D:Fkr:x:X:-:"))!=-1)
231+
while ((flag=pg_getopt(argc,argv,"B:c:d:D:Fkr:x:X:-:"))!=-1)
232232
{
233+
char*optarg=pg_optarg;
233234
switch (flag)
234235
{
235236
case'B':
@@ -297,9 +298,8 @@ AuxiliaryProcessMain(int argc, char *argv[])
297298
}
298299

299300
SetConfigOption(name,value,PGC_POSTMASTER,PGC_S_ARGV);
300-
free(name);
301-
if (value)
302-
free(value);
301+
top_free(name);
302+
top_free(value);
303303
break;
304304
}
305305
default:
@@ -310,7 +310,7 @@ AuxiliaryProcessMain(int argc, char *argv[])
310310
}
311311
}
312312

313-
if (argc!=optind)
313+
if (argc!=pg_optind)
314314
{
315315
write_stderr("%s: invalid command-line arguments\n",progname);
316316
proc_exit(1);

‎src/backend/postmaster/bgworker.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,7 @@ BackgroundWorkerStateChange(void)
307307
*/
308308
if (slot->terminate)
309309
{
310-
intnotify_pid;
310+
pthread_tnotify_pid;
311311

312312
/*
313313
* We need a memory barrier here to make sure that the load of
@@ -460,7 +460,7 @@ ReportBackgroundWorkerExit(slist_mutable_iter *cur)
460460
{
461461
RegisteredBgWorker*rw;
462462
BackgroundWorkerSlot*slot;
463-
intnotify_pid;
463+
pthread_tnotify_pid;
464464

465465
rw=slist_container(RegisteredBgWorker,rw_lnode,cur->cur);
466466

@@ -726,12 +726,13 @@ StartBackgroundWorker(void)
726726
* so we'd better make sure that we don't mess anything up that would
727727
* require that sort of cleanup.
728728
*/
729+
#if0
729730
if ((worker->bgw_flags&BGWORKER_SHMEM_ACCESS)==0)
730731
{
731732
dsm_detach_all();
732733
PGSharedMemoryDetach();
733734
}
734-
735+
#endif
735736
SetProcessingMode(InitProcessing);
736737

737738
/* Apply PostAuthDelay */
@@ -791,7 +792,7 @@ StartBackgroundWorker(void)
791792
*/
792793

793794
/* and go away */
794-
proc_exit(1);
795+
proc_exit(0);
795796
}
796797

797798
/* We can now handle ereport(ERROR) */

‎src/backend/postmaster/postmaster.c

Lines changed: 11 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -468,19 +468,6 @@ typedef struct ThreadContext
468468
intMyPMChildSlot;
469469
unsigned longUsedShmemSegID;
470470
void*UsedShmemSegAddr;
471-
slock_t*ShmemLock;
472-
VariableCacheShmemVariableCache;
473-
#ifndefHAVE_SPINLOCKS
474-
PGSemaphore*SpinlockSemaArray;
475-
#endif
476-
intNamedLWLockTrancheRequests;
477-
NamedLWLockTranche*NamedLWLockTrancheArray;
478-
LWLockPadded*MainLWLockArray;
479-
slock_t*ProcStructLock;
480-
PROC_HDR*ProcGlobal;
481-
PGPROC*AuxiliaryProcs;
482-
PGPROC*PreparedXactProcs;
483-
PMSignalData*PMSignalState;
484471
pthread_tPostmasterPid;
485472
TimestampTzPgStartTime;
486473
TimestampTzPgReloadTime;
@@ -616,15 +603,16 @@ PostmasterMain(int argc, char *argv[])
616603
*/
617604
InitializeGUCOptions();
618605

619-
opterr=1;
606+
pg_opterr=1;
620607

621608
/*
622609
* Parse command-line options. CAUTION: keep this in sync with
623610
* tcop/postgres.c (the option sets should not conflict) and with the
624611
* common help() function in main/main.c.
625612
*/
626-
while ((opt=getopt(argc,argv,"B:bc:C:D:d:EeFf:h:ijk:lN:nOo:Pp:r:S:sTt:W:-:"))!=-1)
613+
while ((opt=pg_getopt(argc,argv,"B:bc:C:D:d:EeFf:h:ijk:lN:nOo:Pp:r:S:sTt:W:-:"))!=-1)
627614
{
615+
char*optarg=pg_optarg;
628616
switch (opt)
629617
{
630618
case'B':
@@ -782,9 +770,8 @@ PostmasterMain(int argc, char *argv[])
782770
}
783771

784772
SetConfigOption(name,value,PGC_POSTMASTER,PGC_S_ARGV);
785-
free(name);
786-
if (value)
787-
free(value);
773+
top_free(name);
774+
top_free(value);
788775
break;
789776
}
790777

@@ -798,10 +785,10 @@ PostmasterMain(int argc, char *argv[])
798785
/*
799786
* Postmaster accepts no non-option switch arguments.
800787
*/
801-
if (optind<argc)
788+
if (pg_optind<argc)
802789
{
803790
write_stderr("%s: invalid argument: \"%s\"\n",
804-
progname,argv[optind]);
791+
progname,argv[pg_optind]);
805792
write_stderr("Try \"%s --help\" for more information.\n",
806793
progname);
807794
ExitPostmaster(1);
@@ -868,7 +855,7 @@ PostmasterMain(int argc, char *argv[])
868855
* Now that we are done processing the postmaster arguments, reset
869856
* getopt(3) library so that it will work correctly in subprocesses.
870857
*/
871-
optind=1;
858+
pg_optind=1;
872859
#ifdefHAVE_INT_OPTRESET
873860
optreset=1;/* some systems need this too */
874861
#endif
@@ -1842,7 +1829,7 @@ ServerLoop(void)
18421829
{
18431830
ereport(LOG,
18441831
(errmsg("performing immediate shutdown because data directory lock file is invalid")));
1845-
pthread_kill(MyProcPid,SIGQUIT);
1832+
exit(1);
18461833
}
18471834
last_lockfile_recheck_time=now;
18481835
}
@@ -3604,7 +3591,7 @@ LogChildExit(int lev, const char *procname, pthread_t pid, thread_status_t exits
36043591
/*------
36053592
translator: %s is a noun phrase describing a child process, such as
36063593
"server process" */
3607-
(errmsg("%s (PID %d) was terminated by signal %d",
3594+
(errmsg("%s (PID %d) was terminated by signal %ld",
36083595
procname,pid,WTERMSIG(exitstatus)),
36093596
activity ?errdetail("Failed process was running: %s",activity) :0));
36103597
#endif
@@ -3998,6 +3985,7 @@ static void thread_cleanup(void* arg)
39983985
pq_finalize();
39993986

40003987
/* Release memory context for this thread */
3988+
CurrentMemoryContext=NULL;
40013989
MemoryContextReset(TopMemoryContext);
40023990
free(TopMemoryContext);
40033991

@@ -5709,21 +5697,6 @@ save_backend_variables(ThreadContext *param)
57095697
param->UsedShmemSegID=UsedShmemSegID;
57105698
param->UsedShmemSegAddr=UsedShmemSegAddr;
57115699

5712-
param->ShmemLock=ShmemLock;
5713-
param->ShmemVariableCache=ShmemVariableCache;
5714-
5715-
#ifndefHAVE_SPINLOCKS
5716-
param->SpinlockSemaArray=SpinlockSemaArray;
5717-
#endif
5718-
param->NamedLWLockTrancheRequests=NamedLWLockTrancheRequests;
5719-
param->NamedLWLockTrancheArray=NamedLWLockTrancheArray;
5720-
param->MainLWLockArray=MainLWLockArray;
5721-
param->ProcStructLock=ProcStructLock;
5722-
param->ProcGlobal=ProcGlobal;
5723-
param->AuxiliaryProcs=AuxiliaryProcs;
5724-
param->PreparedXactProcs=PreparedXactProcs;
5725-
param->PMSignalState=PMSignalState;
5726-
57275700
param->PostmasterPid=PostmasterPid;
57285701
param->PgStartTime=PgStartTime;
57295702
param->PgReloadTime=PgReloadTime;
@@ -5776,21 +5749,6 @@ restore_backend_variables(ThreadContext *param)
57765749
UsedShmemSegID=param->UsedShmemSegID;
57775750
UsedShmemSegAddr=param->UsedShmemSegAddr;
57785751

5779-
ShmemLock=param->ShmemLock;
5780-
ShmemVariableCache=param->ShmemVariableCache;
5781-
5782-
#ifndefHAVE_SPINLOCKS
5783-
SpinlockSemaArray=param->SpinlockSemaArray;
5784-
#endif
5785-
NamedLWLockTrancheRequests=param->NamedLWLockTrancheRequests;
5786-
NamedLWLockTrancheArray=param->NamedLWLockTrancheArray;
5787-
MainLWLockArray=param->MainLWLockArray;
5788-
ProcStructLock=param->ProcStructLock;
5789-
ProcGlobal=param->ProcGlobal;
5790-
AuxiliaryProcs=param->AuxiliaryProcs;
5791-
PreparedXactProcs=param->PreparedXactProcs;
5792-
PMSignalState=param->PMSignalState;
5793-
57945752
PostmasterPid=param->PostmasterPid;
57955753
PgStartTime=param->PgStartTime;
57965754
PgReloadTime=param->PgReloadTime;

‎src/backend/storage/lmgr/lwlock.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ static session_local intLWLockTranchesAllocated = 0;
122122
* the pointer by fork from the postmaster (except in the EXEC_BACKEND case,
123123
* where we have special measures to pass it down).
124124
*/
125-
session_localLWLockPadded*MainLWLockArray=NULL;
125+
LWLockPadded*MainLWLockArray=NULL;
126126

127127
/*
128128
* We use this structure to keep track of locked LWLocks for release
@@ -149,13 +149,13 @@ typedef struct NamedLWLockTrancheRequest
149149
intnum_lwlocks;
150150
}NamedLWLockTrancheRequest;
151151

152-
session_localNamedLWLockTrancheRequest*NamedLWLockTrancheRequestArray=NULL;
153-
staticsession_localintNamedLWLockTrancheRequestsAllocated=0;
154-
session_localintNamedLWLockTrancheRequests=0;
152+
NamedLWLockTrancheRequest*NamedLWLockTrancheRequestArray=NULL;
153+
staticintNamedLWLockTrancheRequestsAllocated=0;
154+
intNamedLWLockTrancheRequests=0;
155155

156-
session_localNamedLWLockTranche*NamedLWLockTrancheArray=NULL;
156+
NamedLWLockTranche*NamedLWLockTrancheArray=NULL;
157157

158-
staticsession_localboollock_named_request_allowed= true;
158+
staticboollock_named_request_allowed= true;
159159

160160
staticvoidInitializeLWLocks(void);
161161
staticvoidRegisterLWLockTranches(void);

‎src/backend/storage/lmgr/predicate.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,7 @@ static OldSerXidControl oldSerXidControl;
351351
* collapsing duplicate targets. When a duplicate is found, the later
352352
* commitSeqNo is used.
353353
*/
354-
staticsession_localSERIALIZABLEXACT*OldCommittedSxact;
354+
staticSERIALIZABLEXACT*OldCommittedSxact;
355355

356356

357357
/*
@@ -395,9 +395,9 @@ static SHM_QUEUE *FinishedSerializableTransactions;
395395
* this entry, you can ensure that there's enough scratch space available for
396396
* inserting one entry in the hash table. This is an otherwise-invalid tag.
397397
*/
398-
staticsession_localconstPREDICATELOCKTARGETTAGScratchTargetTag= {0,0,0,0};
399-
staticsession_localuint32ScratchTargetTagHash;
400-
staticsession_localLWLock*ScratchPartitionLock;
398+
staticconstPREDICATELOCKTARGETTAGScratchTargetTag= {0,0,0,0};
399+
staticuint32ScratchTargetTagHash;
400+
staticLWLock*ScratchPartitionLock;
401401

402402
/*
403403
* The local hash table used to determine when to combine multiple fine-

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp