Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit c16ebb0

Browse files
committed
getpid/pid cleanup
1 parent fc75484 commit c16ebb0

File tree

16 files changed

+61
-102
lines changed

16 files changed

+61
-102
lines changed

src/backend/bootstrap/bootstrap.c

Lines changed: 2 additions & 2 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.32 1998/01/07 21:02:30 momjian Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/bootstrap/bootstrap.c,v 1.33 1998/01/25 05:12:47 momjian Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -322,7 +322,7 @@ BootstrapMain(int argc, char *argv[])
322322
* -------------------
323323
*/
324324

325-
MasterPid = getpid();
325+
MyProcPid = getpid();
326326

327327
/* ----------------
328328
* process command arguments

src/backend/commands/async.c

Lines changed: 7 additions & 11 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.26 1997/12/17 04:44:49 scrappy Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/commands/async.c,v 1.27 1998/01/25 05:12:54 momjian Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -67,6 +67,7 @@
6767

6868
#include <postgres.h>
6969

70+
#include <miscadmin.h>
7071
#include <utils/syscache.h>
7172
#include <access/relscan.h>
7273
#include <access/xact.h>
@@ -264,7 +265,6 @@ Async_NotifyAtCommit()
264265
TupleDesc tdesc;
265266
ScanKeyData key;
266267
Datum d;
267-
int ourpid;
268268
bool isnull;
269269
Buffer b;
270270
extern TransactionState CurrentTransactionState;
@@ -291,7 +291,6 @@ Async_NotifyAtCommit()
291291
RelationSetLockForWrite(lRel);
292292
sRel = heap_beginscan(lRel, 0, false, 1, &key);
293293
tdesc = RelationGetTupleDescriptor(lRel);
294-
ourpid = getpid();
295294

296295
while (HeapTupleIsValid(lTuple = heap_getnext(sRel, 0, &b)))
297296
{
@@ -303,7 +302,7 @@ Async_NotifyAtCommit()
303302
d = heap_getattr(lTuple, b, Anum_pg_listener_pid,
304303
tdesc, &isnull);
305304

306-
if (ourpid == DatumGetInt32(d))
305+
if (MyProcPid == DatumGetInt32(d))
307306
{
308307
#ifdef ASYNC_DEBUG
309308
elog(DEBUG, "Notifying self, setting notifyFronEndPending to 1");
@@ -420,7 +419,6 @@ Async_Listen(char *relname, int pid)
420419
int i;
421420
bool isnull;
422421
int alreadyListener = 0;
423-
int ourPid = getpid();
424422
char *relnamei;
425423
TupleDesc tupDesc;
426424

@@ -453,7 +451,7 @@ Async_Listen(char *relname, int pid)
453451
{
454452
d = heap_getattr(htup, b, Anum_pg_listener_pid, tdesc, &isnull);
455453
pid = DatumGetInt32(d);
456-
if (pid == ourPid)
454+
if (pid == MyProcPid)
457455
{
458456
alreadyListener = 1;
459457
}
@@ -537,7 +535,7 @@ static void
537535
Async_UnlistenOnExit(int code, /* from exitpg */
538536
char *relname)
539537
{
540-
Async_Unlisten((char *) relname, getpid());
538+
Async_Unlisten((char *) relname, MyProcPid);
541539
}
542540

543541
/*
@@ -579,7 +577,6 @@ Async_NotifyFrontEnd()
579577
char repl[3],
580578
nulls[3];
581579
Buffer b;
582-
int ourpid;
583580
bool isnull;
584581

585582
notifyFrontEndPending = 0;
@@ -589,15 +586,14 @@ Async_NotifyFrontEnd()
589586
#endif
590587

591588
StartTransactionCommand();
592-
ourpid = getpid();
593589
ScanKeyEntryInitialize(&key[0], 0,
594590
Anum_pg_listener_notify,
595591
Integer32EqualRegProcedure,
596592
Int32GetDatum(1));
597593
ScanKeyEntryInitialize(&key[1], 0,
598594
Anum_pg_listener_pid,
599595
Integer32EqualRegProcedure,
600-
Int32GetDatum(ourpid));
596+
Int32GetDatum(MyProcPid));
601597
lRel = heap_openr(ListenerRelationName);
602598
RelationSetLockForWrite(lRel);
603599
tdesc = RelationGetTupleDescriptor(lRel);
@@ -621,7 +617,7 @@ Async_NotifyFrontEnd()
621617
if (whereToSendOutput == Remote)
622618
{
623619
pq_putnchar("A", 1);
624-
pq_putint(ourpid, sizeof(ourpid));
620+
pq_putint((int32)MyProcPid, sizeof(int32));
625621
pq_putstr(DatumGetName(d)->data);
626622
pq_flush();
627623
}

src/backend/commands/user.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ void UpdatePgPwdFile(char* sql) {
5151
*/
5252
filename = crypt_getpwdfilename();
5353
tempname = (char*)malloc(strlen(filename) + 12);
54-
sprintf(tempname, "%s.%d", filename, getpid());
54+
sprintf(tempname, "%s.%d", filename, MyProcPid);
5555

5656
/* Copy the contents of pg_user to the pg_pwd ASCII file using a the SEPCHAR
5757
* character as the delimiter between fields. Then rename the file to its

src/backend/executor/nodeHash.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/executor/nodeHash.c,v 1.16 1998/01/13 04:03:53 scrappy Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/executor/nodeHash.c,v 1.17 1998/01/25 05:13:03 momjian Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -30,7 +30,7 @@
3030
#include <unistd.h>
3131

3232
#include "postgres.h"
33-
33+
#include "miscadmin.h"
3434
#include "executor/execdebug.h"
3535
#include "executor/executor.h"
3636
#include "executor/nodeHash.h"
@@ -887,6 +887,6 @@ static int hjtmpcnt = 0;
887887
static void
888888
mk_hj_temp(char *tempname)
889889
{
890-
sprintf(tempname, "HJ%d.%d", (int) getpid(), hjtmpcnt);
890+
sprintf(tempname, "HJ%d.%d", (int) MyProcPid, hjtmpcnt);
891891
hjtmpcnt = (hjtmpcnt + 1) % 1000;
892892
}

src/backend/libpq/pqcomm.c

Lines changed: 5 additions & 4 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.33 1998/01/07 21:03:21 momjian Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/libpq/pqcomm.c,v 1.34 1998/01/25 05:13:18 momjian Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -56,6 +56,7 @@
5656

5757
#include <postgres.h>
5858

59+
#include <miscadmin.h>
5960
#include <libpq/pqsignal.h>
6061
#include <libpq/auth.h>
6162
#include <libpq/libpq.h> /* where the declarations go */
@@ -515,11 +516,11 @@ pq_regoob(void (*fptr) ())
515516
int fd = fileno(Pfout);
516517

517518
#if defined(hpux)
518-
ioctl(fd, FIOSSAIOOWN, getpid());
519+
ioctl(fd, FIOSSAIOOWN, MyProcPid);
519520
#elif defined(sco)
520-
ioctl(fd, SIOCSPGRP, getpid());
521+
ioctl(fd, SIOCSPGRP, MyProcPid);
521522
#else
522-
fcntl(fd, F_SETOWN, getpid());
523+
fcntl(fd, F_SETOWN, MyProcPid);
523524
#endif /* hpux */
524525
pqsignal(SIGURG, fptr);
525526
}

src/backend/postmaster/postmaster.c

Lines changed: 2 additions & 2 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.68 1997/12/19 02:06:37 scrappy Exp $
13+
* $Header: /cvsroot/pgsql/src/backend/postmaster/postmaster.c,v 1.69 1998/01/25 05:13:35 momjian Exp $
1414
*
1515
* NOTES
1616
*
@@ -1337,7 +1337,7 @@ DoExec(StartupInfo *packet, int portFd)
13371337
if (DebugLvl > 1)
13381338
{
13391339
fprintf(stderr, "%s child[%ld]: execv(",
1340-
progname, (long) getpid());
1340+
progname, (long) MyProcPid);
13411341
for (i = 0; i < ac; ++i)
13421342
fprintf(stderr, "%s, ", av[i]);
13431343
fprintf(stderr, ")\n");

src/backend/storage/buffer/bufmgr.c

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/storage/buffer/bufmgr.c,v 1.31 1998/01/07 21:04:49 momjian Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/storage/buffer/bufmgr.c,v 1.32 1998/01/25 05:13:53 momjian Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -1828,14 +1828,10 @@ refcount = %ld, file: %s, line: %d\n",
18281828

18291829
_bm_trace(Oid dbId, Oid relId, int blkNo, int bufNo, int allocType)
18301830
{
1831-
static int mypid = 0;
18321831
long start,
18331832
cur;
18341833
bmtrace *tb;
18351834

1836-
if (mypid == 0)
1837-
mypid = getpid();
1838-
18391835
start = *CurTraceBuf;
18401836

18411837
if (start > 0)
@@ -1871,7 +1867,7 @@ _bm_trace(Oid dbId, Oid relId, int blkNo, int bufNo, int allocType)
18711867

18721868
okay:
18731869
tb = &TraceBuf[start];
1874-
tb->bmt_pid = mypid;
1870+
tb->bmt_pid = MyProcPid;
18751871
tb->bmt_buf = bufNo;
18761872
tb->bmt_dbid = dbId;
18771873
tb->bmt_relid = relId;

src/backend/storage/lmgr/lock.c

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/storage/lmgr/lock.c,v 1.20 1998/01/23 22:16:46 momjian Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/storage/lmgr/lock.c,v 1.21 1998/01/25 05:14:02 momjian Exp $
1111
*
1212
* NOTES
1313
* Outside modules can create a lock table and acquire/release
@@ -37,6 +37,7 @@
3737
#include <unistd.h>
3838

3939
#include "postgres.h"
40+
#include "miscadmin.h"
4041
#include "storage/shmem.h"
4142
#include "storage/spin.h"
4243
#include "storage/proc.h"
@@ -77,7 +78,7 @@ static char *lock_types[] = {
7778
if ((lockDebug >= 1) && (tag->relId >= lock_debug_oid_min)) \
7879
elog(DEBUG, \
7980
"%s: pid (%d) rel (%d) dbid (%d) tid (%d,%d) type (%s)",where, \
80-
getpid(),\
81+
MyProcPid,\
8182
tag->relId, tag->dbId, \
8283
((tag->tupleId.ip_blkid.bi_hi<<16)+\
8384
tag->tupleId.ip_blkid.bi_lo),\
@@ -92,7 +93,7 @@ static char *lock_types[] = {
9293
elog(DEBUG, \
9394
"%s: pid (%d) rel (%d) dbid (%d) tid (%d,%d) nHolding (%d) "\
9495
"holders (%d,%d,%d,%d,%d) type (%s)",where, \
95-
getpid(),\
96+
MyProcPid,\
9697
lock->tag.relId, lock->tag.dbId, \
9798
((lock->tag.tupleId.ip_blkid.bi_hi<<16)+\
9899
lock->tag.tupleId.ip_blkid.bi_lo),\
@@ -113,7 +114,7 @@ static char *lock_types[] = {
113114
"%s: pid (%d) xid (%d) pid (%d) lock (%x) nHolding (%d) "\
114115
"holders (%d,%d,%d,%d,%d)",\
115116
where,\
116-
getpid(),\
117+
MyProcPid,\
117118
xidentP->tag.xid,\
118119
xidentP->tag.pid,\
119120
xidentP->tag.lock,\
@@ -550,7 +551,7 @@ LockAcquire(LockTableId tableId, LOCKTAG *lockName, LOCKT lockt)
550551
#ifdef USER_LOCKS
551552
if (is_user_lock)
552553
{
553-
item.tag.pid = getpid();
554+
item.tag.pid = MyProcPid;
554555
item.tag.xid = myXid = 0;
555556
#ifdef USER_LOCKS_DEBUG
556557
elog(NOTICE, "LockAcquire: user lock xid [%d,%d,%d]",
@@ -975,7 +976,7 @@ LockRelease(LockTableId tableId, LOCKTAG *lockName, LOCKT lockt)
975976
#ifdef USER_LOCKS
976977
if (is_user_lock)
977978
{
978-
item.tag.pid = getpid();
979+
item.tag.pid = MyProcPid;
979980
item.tag.xid = 0;
980981
#ifdef USER_LOCKS_DEBUG
981982
elog(NOTICE, "LockRelease: user lock xid [%d,%d,%d]",
@@ -1153,14 +1154,12 @@ LockReleaseAll(LockTableId tableId, SHM_QUEUE *lockQueue)
11531154

11541155
#ifdef USER_LOCKS
11551156
int is_user_lock_table,
1156-
my_pid,
11571157
count,
11581158
nskip;
11591159

11601160
is_user_lock_table = (tableId == 0);
1161-
my_pid = getpid();
11621161
#ifdef USER_LOCKS_DEBUG
1163-
elog(NOTICE, "LockReleaseAll: tableId=%d, pid=%d", tableId, my_pid);
1162+
elog(NOTICE, "LockReleaseAll: tableId=%d, pid=%d", tableId, MyProcPid);
11641163
#endif
11651164
if (is_user_lock_table)
11661165
{
@@ -1226,7 +1225,7 @@ LockReleaseAll(LockTableId tableId, SHM_QUEUE *lockQueue)
12261225
nskip++;
12271226
goto next_item;
12281227
}
1229-
if (xidLook->tag.pid != my_pid)
1228+
if (xidLook->tag.pid != MyProcPid)
12301229
{
12311230
/* This should never happen */
12321231
#ifdef USER_LOCKS_DEBUG
@@ -1433,13 +1432,11 @@ DumpLocks()
14331432
SPINLOCK masterLock;
14341433
int nLockTypes;
14351434
LOCK *lock;
1436-
int pid,
14371435
count;
14381436
int tableId = 1;
14391437
LOCKTAB *ltable;
14401438

1441-
pid = getpid();
1442-
ShmemPIDLookup(pid, &location);
1439+
ShmemPIDLookup(MyProcPid, &location);
14431440
if (location == INVALID_OFFSET)
14441441
return;
14451442
proc = (PROC *) MAKE_PTR(location);

0 commit comments

Comments
 (0)