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

Commit4d9a498

Browse files
committed
Repalce pid_t wirth pthread_t
1 parentc730d65 commit4d9a498

File tree

52 files changed

+425
-453
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+425
-453
lines changed

‎contrib/pg_prewarm/autoprewarm.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,8 @@ typedef struct BlockInfoRecord
6767
typedefstructAutoPrewarmSharedState
6868
{
6969
LWLocklock;/* mutual exclusion */
70-
pid_tbgworker_pid;/* for main bgworker */
71-
pid_tpid_using_dumpfile;/* for autoprewarm or block dump */
70+
pthread_tbgworker_pid;/* for main bgworker */
71+
pthread_tpid_using_dumpfile;/* for autoprewarm or block dump */
7272

7373
/* Following items are for communication with per-database worker */
7474
dsm_handleblock_info_handle;
@@ -568,7 +568,7 @@ apw_dump_now(bool is_bgworker, bool dump_unlogged)
568568
BufferDesc*bufHdr;
569569
FILE*file;
570570
chartransient_dump_file_path[MAXPGPATH];
571-
pid_tpid;
571+
pthread_tpid;
572572

573573
LWLockAcquire(&apw_state->lock,LW_EXCLUSIVE);
574574
pid=apw_state->pid_using_dumpfile;
@@ -702,7 +702,7 @@ apw_dump_now(bool is_bgworker, bool dump_unlogged)
702702
Datum
703703
autoprewarm_start_worker(PG_FUNCTION_ARGS)
704704
{
705-
pid_tpid;
705+
pthread_tpid;
706706

707707
if (!autoprewarm)
708708
ereport(ERROR,
@@ -793,7 +793,7 @@ apw_start_master_worker(void)
793793
BackgroundWorkerworker;
794794
BackgroundWorkerHandle*handle;
795795
BgwHandleStatusstatus;
796-
pid_tpid;
796+
pthread_tpid;
797797

798798
MemSet(&worker,0,sizeof(BackgroundWorker));
799799
worker.bgw_flags=BGWORKER_SHMEM_ACCESS;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ typedef struct FixedParallelState
8181
intsec_context;
8282
boolis_superuser;
8383
PGPROC*parallel_master_pgproc;
84-
pid_tparallel_master_pid;
84+
pthread_tparallel_master_pid;
8585
BackendIdparallel_master_backend_id;
8686

8787
/* Mutex protects remaining fields. */

‎src/backend/commands/async.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -638,7 +638,7 @@ void
638638
Async_Listen(constchar*channel)
639639
{
640640
if (Trace_notify)
641-
elog(DEBUG1,"Async_Listen(%s,%d)",channel,MyProcPid);
641+
elog(DEBUG1,"Async_Listen(%s,%ld)",channel,MyProcPid);
642642

643643
queue_listen(LISTEN_LISTEN,channel);
644644
}
@@ -652,7 +652,7 @@ void
652652
Async_Unlisten(constchar*channel)
653653
{
654654
if (Trace_notify)
655-
elog(DEBUG1,"Async_Unlisten(%s,%d)",channel,MyProcPid);
655+
elog(DEBUG1,"Async_Unlisten(%s,%ld)",channel,MyProcPid);
656656

657657
/* If we couldn't possibly be listening, no need to queue anything */
658658
if (pendingActions==NIL&& !unlistenExitRegistered)
@@ -670,7 +670,7 @@ void
670670
Async_UnlistenAll(void)
671671
{
672672
if (Trace_notify)
673-
elog(DEBUG1,"Async_UnlistenAll(%d)",MyProcPid);
673+
elog(DEBUG1,"Async_UnlistenAll(%ld)",MyProcPid);
674674

675675
/* If we couldn't possibly be listening, no need to queue anything */
676676
if (pendingActions==NIL&& !unlistenExitRegistered)
@@ -932,7 +932,7 @@ Exec_ListenPreCommit(void)
932932
return;
933933

934934
if (Trace_notify)
935-
elog(DEBUG1,"Exec_ListenPreCommit(%d)",MyProcPid);
935+
elog(DEBUG1,"Exec_ListenPreCommit(%ld)",MyProcPid);
936936

937937
/*
938938
* Before registering, make sure we will unlisten before dying. (Note:
@@ -1039,7 +1039,7 @@ Exec_UnlistenCommit(const char *channel)
10391039
ListCell*prev;
10401040

10411041
if (Trace_notify)
1042-
elog(DEBUG1,"Exec_UnlistenCommit(%s,%d)",channel,MyProcPid);
1042+
elog(DEBUG1,"Exec_UnlistenCommit(%s,%ld)",channel,MyProcPid);
10431043

10441044
prev=NULL;
10451045
foreach(q,listenChannels)
@@ -1070,7 +1070,7 @@ static void
10701070
Exec_UnlistenAllCommit(void)
10711071
{
10721072
if (Trace_notify)
1073-
elog(DEBUG1,"Exec_UnlistenAllCommit(%d)",MyProcPid);
1073+
elog(DEBUG1,"Exec_UnlistenAllCommit(%ld)",MyProcPid);
10741074

10751075
list_free_deep(listenChannels);
10761076
listenChannels=NIL;

‎src/backend/libpq/pqmq.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@
2323

2424
staticsession_localshm_mq_handle*pq_mq_handle;
2525
staticsession_localboolpq_mq_busy= false;
26-
staticsession_localpid_tpq_mq_parallel_master_pid=0;
27-
staticsession_localpid_tpq_mq_parallel_master_backend_id=InvalidBackendId;
26+
staticsession_localpthread_tpq_mq_parallel_master_pid=0;
27+
staticsession_localpthread_tpq_mq_parallel_master_backend_id=InvalidBackendId;
2828

2929
staticvoidpq_cleanup_redirect_to_shm_mq(dsm_segment*seg,Datumarg);
3030
staticvoidmq_comm_reset(void);
@@ -77,7 +77,7 @@ pq_cleanup_redirect_to_shm_mq(dsm_segment *seg, Datum arg)
7777
* message data via the shm_mq.
7878
*/
7979
void
80-
pq_set_parallel_master(pid_tpid,BackendIdbackend_id)
80+
pq_set_parallel_master(pthread_tpid,BackendIdbackend_id)
8181
{
8282
Assert(PqCommMethods==&PqCommMqMethods);
8383
pq_mq_parallel_master_pid=pid;

‎src/backend/port/atomics.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ pg_spinlock_barrier(void)
3636
* systems old enough to require fallback barrier support will include an
3737
* appropriate barrier while checking the existence of the postmaster pid.
3838
*/
39-
(void)kill(PostmasterPid,0);
39+
(void)pthread_kill(PostmasterPid,0);
4040
}
4141
#endif
4242

‎src/backend/port/sysv_sema.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ static void IpcSemaphoreInitialize(IpcSemaphoreId semId, int semNum,
7777
intvalue);
7878
staticvoidIpcSemaphoreKill(IpcSemaphoreIdsemId);
7979
staticintIpcSemaphoreGetValue(IpcSemaphoreIdsemId,intsemNum);
80-
staticpid_tIpcSemaphoreGetLastPID(IpcSemaphoreIdsemId,intsemNum);
80+
staticpthread_tIpcSemaphoreGetLastPID(IpcSemaphoreIdsemId,intsemNum);
8181
staticIpcSemaphoreIdIpcSemaphoreCreate(intnumSems);
8282
staticvoidReleaseSemaphores(intstatus,Datumarg);
8383

@@ -187,7 +187,7 @@ IpcSemaphoreGetValue(IpcSemaphoreId semId, int semNum)
187187
}
188188

189189
/* Get the PID of the last process to do semop() on the semaphore */
190-
staticpid_t
190+
staticpthread_t
191191
IpcSemaphoreGetLastPID(IpcSemaphoreIdsemId,intsemNum)
192192
{
193193
unionsemundummy;/* for Solaris */
@@ -217,7 +217,7 @@ IpcSemaphoreCreate(int numSems)
217217
/* Loop till we find a free IPC key */
218218
for (nextSemaKey++;;nextSemaKey++)
219219
{
220-
pid_tcreatorPID;
220+
pthread_tcreatorPID;
221221

222222
/* Try to create new semaphore set */
223223
semId=InternalIpcSemaphoreCreate(nextSemaKey,numSems+1);
@@ -238,12 +238,13 @@ IpcSemaphoreCreate(int numSems)
238238
creatorPID=IpcSemaphoreGetLastPID(semId,numSems);
239239
if (creatorPID <=0)
240240
continue;/* oops, GETPID failed */
241+
#if0
241242
if (creatorPID!=getpid())
242243
{
243-
if (kill(creatorPID,0)==0||errno!=ESRCH)
244+
if (pthread_kill(creatorPID,0)==0||errno!=ESRCH)
244245
continue;/* sema belongs to a live process */
245246
}
246-
247+
#endif
247248
/*
248249
* The sema set appears to be from a dead Postgres process, or from a
249250
* previous cycle of life in this same process. Zap it, if possible.

‎src/backend/port/sysv_shmem.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -615,15 +615,16 @@ PGSharedMemoryCreate(Size size, bool makePrivate, int port,
615615
* continue.
616616
*/
617617
hdr= (PGShmemHeader*)memAddress;
618+
#if0
618619
if (hdr->creatorPID!=getpid())
619620
{
620-
if (kill(hdr->creatorPID,0)==0||errno!=ESRCH)
621+
if (pthread_kill(hdr->creatorPID,0)==0||errno!=ESRCH)
621622
{
622623
shmdt(memAddress);
623624
continue;/* segment belongs to a live process */
624625
}
625626
}
626-
627+
#endif
627628
/*
628629
* The segment appears to be from a dead Postgres process, or from a
629630
* previous cycle of life in this same process. Zap it, if possible,

‎src/backend/port/win32/signal.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ pqsignal(int signum, pqsigfunc handler)
178178

179179
/* Create the signal listener pipe for specified PID */
180180
HANDLE
181-
pgwin32_create_signal_listener(pid_tpid)
181+
pgwin32_create_signal_listener(pthread_tpid)
182182
{
183183
charpipename[128];
184184
HANDLEpipe;

‎src/backend/postmaster/autovacuum.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ typedef struct AutoVacuumWorkItem
283283
typedefstruct
284284
{
285285
sig_atomic_tav_signal[AutoVacNumSignals];
286-
pid_tav_launcherpid;
286+
pthread_tav_launcherpid;
287287
dlist_headav_freeWorkers;
288288
dlist_headav_runningWorkers;
289289
WorkerInfoav_startingWorker;
@@ -306,8 +306,8 @@ static session_local WorkerInfo MyWorkerInfo = NULL;
306306
session_localintAutovacuumLauncherPid=0;
307307

308308
#ifdefEXEC_BACKEND
309-
staticsession_localpid_tavlauncher_forkexec(void);
310-
staticsession_localpid_tavworker_forkexec(void);
309+
staticsession_localpthread_tavlauncher_forkexec(void);
310+
staticsession_localpthread_tavworker_forkexec(void);
311311
#endif
312312
NON_EXEC_STATICvoidAutoVacWorkerMain(intargc,char*argv[])pg_attribute_noreturn();
313313
NON_EXEC_STATICvoidAutoVacLauncherMain(intargc,char*argv[])pg_attribute_noreturn();
@@ -361,7 +361,7 @@ static void autovac_refresh_stats(void);
361361
*
362362
* Format up the arglist, then fork and exec.
363363
*/
364-
staticpid_t
364+
staticpthread_t
365365
avlauncher_forkexec(void)
366366
{
367367
char*av[10];
@@ -394,7 +394,7 @@ AutovacuumLauncherIAm(void)
394394
int
395395
StartAutoVacLauncher(void)
396396
{
397-
pid_tAutoVacPID;
397+
pthread_tAutoVacPID;
398398

399399
#ifdefEXEC_BACKEND
400400
switch ((AutoVacPID=avlauncher_forkexec()))
@@ -1442,7 +1442,7 @@ avl_sigterm_handler(SIGNAL_ARGS)
14421442
*
14431443
* Format up the arglist, then fork and exec.
14441444
*/
1445-
staticpid_t
1445+
staticpthread_t
14461446
avworker_forkexec(void)
14471447
{
14481448
char*av[10];
@@ -1476,7 +1476,7 @@ AutovacuumWorkerIAm(void)
14761476
int
14771477
StartAutoVacWorker(void)
14781478
{
1479-
pid_tworker_pid;
1479+
pthread_tworker_pid;
14801480

14811481
#ifdefEXEC_BACKEND
14821482
switch ((worker_pid=avworker_forkexec()))
@@ -1650,7 +1650,7 @@ AutoVacWorkerMain(int argc, char *argv[])
16501650

16511651
/* wake up the launcher */
16521652
if (AutoVacuumShmem->av_launcherpid!=0)
1653-
kill(AutoVacuumShmem->av_launcherpid,SIGUSR2);
1653+
pthread_kill(AutoVacuumShmem->av_launcherpid,SIGUSR2);
16541654
}
16551655
else
16561656
{

‎src/backend/postmaster/bgworker.c

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ typedef struct BackgroundWorkerSlot
7878
{
7979
boolin_use;
8080
boolterminate;
81-
pid_tpid;/* InvalidPid = not started yet; 0 = dead */
81+
pthread_tpid;/* InvalidPid = not started yet; 0 = dead */
8282
uint64generation;/* incremented when slot is recycled */
8383
BackgroundWorkerworker;
8484
}BackgroundWorkerSlot;
@@ -288,7 +288,7 @@ BackgroundWorkerStateChange(void)
288288
{
289289
rw->rw_terminate= true;
290290
if (rw->rw_pid!=0)
291-
kill(rw->rw_pid,SIGTERM);
291+
pthread_kill(rw->rw_pid,SIGTERM);
292292
else
293293
{
294294
/* Report never-started, now-terminated worker as dead. */
@@ -321,7 +321,7 @@ BackgroundWorkerStateChange(void)
321321
slot->pid=0;
322322
slot->in_use= false;
323323
if (notify_pid!=0)
324-
kill(notify_pid,SIGUSR1);
324+
pthread_kill(notify_pid,SIGUSR1);
325325

326326
continue;
327327
}
@@ -446,7 +446,7 @@ ReportBackgroundWorkerPID(RegisteredBgWorker *rw)
446446
slot->pid=rw->rw_pid;
447447

448448
if (rw->rw_worker.bgw_notify_pid!=0)
449-
kill(rw->rw_worker.bgw_notify_pid,SIGUSR1);
449+
pthread_kill(rw->rw_worker.bgw_notify_pid,SIGUSR1);
450450
}
451451

452452
/*
@@ -481,7 +481,7 @@ ReportBackgroundWorkerExit(slist_mutable_iter *cur)
481481
ForgetBackgroundWorker(cur);
482482

483483
if (notify_pid!=0)
484-
kill(notify_pid,SIGUSR1);
484+
pthread_kill(notify_pid,SIGUSR1);
485485
}
486486

487487
/*
@@ -490,7 +490,7 @@ ReportBackgroundWorkerExit(slist_mutable_iter *cur)
490490
* This function should only be called from the postmaster.
491491
*/
492492
void
493-
BackgroundWorkerStopNotifications(pid_tpid)
493+
BackgroundWorkerStopNotifications(pthread_tpid)
494494
{
495495
slist_itersiter;
496496

@@ -1044,10 +1044,10 @@ RegisterDynamicBackgroundWorker(BackgroundWorker *worker,
10441044
* good (if it exited with code 0 or if it is configured not to restart).
10451045
*/
10461046
BgwHandleStatus
1047-
GetBackgroundWorkerPid(BackgroundWorkerHandle*handle,pid_t*pidp)
1047+
GetBackgroundWorkerPid(BackgroundWorkerHandle*handle,pthread_t*pidp)
10481048
{
10491049
BackgroundWorkerSlot*slot;
1050-
pid_tpid;
1050+
pthread_tpid;
10511051

10521052
Assert(handle->slot<max_worker_processes);
10531053
slot=&BackgroundWorkerData->slot[handle->slot];
@@ -1093,14 +1093,14 @@ GetBackgroundWorkerPid(BackgroundWorkerHandle *handle, pid_t *pidp)
10931093
* take place.
10941094
*/
10951095
BgwHandleStatus
1096-
WaitForBackgroundWorkerStartup(BackgroundWorkerHandle*handle,pid_t*pidp)
1096+
WaitForBackgroundWorkerStartup(BackgroundWorkerHandle*handle,pthread_t*pidp)
10971097
{
10981098
BgwHandleStatusstatus;
10991099
intrc;
11001100

11011101
for (;;)
11021102
{
1103-
pid_tpid;
1103+
pthread_tpid;
11041104

11051105
CHECK_FOR_INTERRUPTS();
11061106

@@ -1142,7 +1142,7 @@ WaitForBackgroundWorkerShutdown(BackgroundWorkerHandle *handle)
11421142

11431143
for (;;)
11441144
{
1145-
pid_tpid;
1145+
pthread_tpid;
11461146

11471147
CHECK_FOR_INTERRUPTS();
11481148

@@ -1249,7 +1249,7 @@ LookupBackgroundWorkerFunction(const char *libraryname, const char *funcname)
12491249
* doesn't have to worry about the background worker locking protocol.
12501250
*/
12511251
constchar*
1252-
GetBackgroundWorkerTypeByPid(pid_tpid)
1252+
GetBackgroundWorkerTypeByPid(pthread_tpid)
12531253
{
12541254
intslotno;
12551255
boolfound= false;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp