mirror of
https://github.com/postgres/postgres.git
synced 2025-04-21 12:05:57 +03:00
getpid/pid cleanup
This commit is contained in:
parent
fc75484550
commit
c16ebb0f67
@ -7,7 +7,7 @@
|
|||||||
* Copyright (c) 1994, Regents of the University of California
|
* Copyright (c) 1994, Regents of the University of California
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/bootstrap/bootstrap.c,v 1.32 1998/01/07 21:02:30 momjian Exp $
|
* $Header: /cvsroot/pgsql/src/backend/bootstrap/bootstrap.c,v 1.33 1998/01/25 05:12:47 momjian Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -322,7 +322,7 @@ BootstrapMain(int argc, char *argv[])
|
|||||||
* -------------------
|
* -------------------
|
||||||
*/
|
*/
|
||||||
|
|
||||||
MasterPid = getpid();
|
MyProcPid = getpid();
|
||||||
|
|
||||||
/* ----------------
|
/* ----------------
|
||||||
* process command arguments
|
* process command arguments
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/commands/async.c,v 1.26 1997/12/17 04:44:49 scrappy Exp $
|
* $Header: /cvsroot/pgsql/src/backend/commands/async.c,v 1.27 1998/01/25 05:12:54 momjian Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -67,6 +67,7 @@
|
|||||||
|
|
||||||
#include <postgres.h>
|
#include <postgres.h>
|
||||||
|
|
||||||
|
#include <miscadmin.h>
|
||||||
#include <utils/syscache.h>
|
#include <utils/syscache.h>
|
||||||
#include <access/relscan.h>
|
#include <access/relscan.h>
|
||||||
#include <access/xact.h>
|
#include <access/xact.h>
|
||||||
@ -264,7 +265,6 @@ Async_NotifyAtCommit()
|
|||||||
TupleDesc tdesc;
|
TupleDesc tdesc;
|
||||||
ScanKeyData key;
|
ScanKeyData key;
|
||||||
Datum d;
|
Datum d;
|
||||||
int ourpid;
|
|
||||||
bool isnull;
|
bool isnull;
|
||||||
Buffer b;
|
Buffer b;
|
||||||
extern TransactionState CurrentTransactionState;
|
extern TransactionState CurrentTransactionState;
|
||||||
@ -291,7 +291,6 @@ Async_NotifyAtCommit()
|
|||||||
RelationSetLockForWrite(lRel);
|
RelationSetLockForWrite(lRel);
|
||||||
sRel = heap_beginscan(lRel, 0, false, 1, &key);
|
sRel = heap_beginscan(lRel, 0, false, 1, &key);
|
||||||
tdesc = RelationGetTupleDescriptor(lRel);
|
tdesc = RelationGetTupleDescriptor(lRel);
|
||||||
ourpid = getpid();
|
|
||||||
|
|
||||||
while (HeapTupleIsValid(lTuple = heap_getnext(sRel, 0, &b)))
|
while (HeapTupleIsValid(lTuple = heap_getnext(sRel, 0, &b)))
|
||||||
{
|
{
|
||||||
@ -303,7 +302,7 @@ Async_NotifyAtCommit()
|
|||||||
d = heap_getattr(lTuple, b, Anum_pg_listener_pid,
|
d = heap_getattr(lTuple, b, Anum_pg_listener_pid,
|
||||||
tdesc, &isnull);
|
tdesc, &isnull);
|
||||||
|
|
||||||
if (ourpid == DatumGetInt32(d))
|
if (MyProcPid == DatumGetInt32(d))
|
||||||
{
|
{
|
||||||
#ifdef ASYNC_DEBUG
|
#ifdef ASYNC_DEBUG
|
||||||
elog(DEBUG, "Notifying self, setting notifyFronEndPending to 1");
|
elog(DEBUG, "Notifying self, setting notifyFronEndPending to 1");
|
||||||
@ -420,7 +419,6 @@ Async_Listen(char *relname, int pid)
|
|||||||
int i;
|
int i;
|
||||||
bool isnull;
|
bool isnull;
|
||||||
int alreadyListener = 0;
|
int alreadyListener = 0;
|
||||||
int ourPid = getpid();
|
|
||||||
char *relnamei;
|
char *relnamei;
|
||||||
TupleDesc tupDesc;
|
TupleDesc tupDesc;
|
||||||
|
|
||||||
@ -453,7 +451,7 @@ Async_Listen(char *relname, int pid)
|
|||||||
{
|
{
|
||||||
d = heap_getattr(htup, b, Anum_pg_listener_pid, tdesc, &isnull);
|
d = heap_getattr(htup, b, Anum_pg_listener_pid, tdesc, &isnull);
|
||||||
pid = DatumGetInt32(d);
|
pid = DatumGetInt32(d);
|
||||||
if (pid == ourPid)
|
if (pid == MyProcPid)
|
||||||
{
|
{
|
||||||
alreadyListener = 1;
|
alreadyListener = 1;
|
||||||
}
|
}
|
||||||
@ -537,7 +535,7 @@ static void
|
|||||||
Async_UnlistenOnExit(int code, /* from exitpg */
|
Async_UnlistenOnExit(int code, /* from exitpg */
|
||||||
char *relname)
|
char *relname)
|
||||||
{
|
{
|
||||||
Async_Unlisten((char *) relname, getpid());
|
Async_Unlisten((char *) relname, MyProcPid);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -579,7 +577,6 @@ Async_NotifyFrontEnd()
|
|||||||
char repl[3],
|
char repl[3],
|
||||||
nulls[3];
|
nulls[3];
|
||||||
Buffer b;
|
Buffer b;
|
||||||
int ourpid;
|
|
||||||
bool isnull;
|
bool isnull;
|
||||||
|
|
||||||
notifyFrontEndPending = 0;
|
notifyFrontEndPending = 0;
|
||||||
@ -589,7 +586,6 @@ Async_NotifyFrontEnd()
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
StartTransactionCommand();
|
StartTransactionCommand();
|
||||||
ourpid = getpid();
|
|
||||||
ScanKeyEntryInitialize(&key[0], 0,
|
ScanKeyEntryInitialize(&key[0], 0,
|
||||||
Anum_pg_listener_notify,
|
Anum_pg_listener_notify,
|
||||||
Integer32EqualRegProcedure,
|
Integer32EqualRegProcedure,
|
||||||
@ -597,7 +593,7 @@ Async_NotifyFrontEnd()
|
|||||||
ScanKeyEntryInitialize(&key[1], 0,
|
ScanKeyEntryInitialize(&key[1], 0,
|
||||||
Anum_pg_listener_pid,
|
Anum_pg_listener_pid,
|
||||||
Integer32EqualRegProcedure,
|
Integer32EqualRegProcedure,
|
||||||
Int32GetDatum(ourpid));
|
Int32GetDatum(MyProcPid));
|
||||||
lRel = heap_openr(ListenerRelationName);
|
lRel = heap_openr(ListenerRelationName);
|
||||||
RelationSetLockForWrite(lRel);
|
RelationSetLockForWrite(lRel);
|
||||||
tdesc = RelationGetTupleDescriptor(lRel);
|
tdesc = RelationGetTupleDescriptor(lRel);
|
||||||
@ -621,7 +617,7 @@ Async_NotifyFrontEnd()
|
|||||||
if (whereToSendOutput == Remote)
|
if (whereToSendOutput == Remote)
|
||||||
{
|
{
|
||||||
pq_putnchar("A", 1);
|
pq_putnchar("A", 1);
|
||||||
pq_putint(ourpid, sizeof(ourpid));
|
pq_putint((int32)MyProcPid, sizeof(int32));
|
||||||
pq_putstr(DatumGetName(d)->data);
|
pq_putstr(DatumGetName(d)->data);
|
||||||
pq_flush();
|
pq_flush();
|
||||||
}
|
}
|
||||||
|
@ -51,7 +51,7 @@ void UpdatePgPwdFile(char* sql) {
|
|||||||
*/
|
*/
|
||||||
filename = crypt_getpwdfilename();
|
filename = crypt_getpwdfilename();
|
||||||
tempname = (char*)malloc(strlen(filename) + 12);
|
tempname = (char*)malloc(strlen(filename) + 12);
|
||||||
sprintf(tempname, "%s.%d", filename, getpid());
|
sprintf(tempname, "%s.%d", filename, MyProcPid);
|
||||||
|
|
||||||
/* Copy the contents of pg_user to the pg_pwd ASCII file using a the SEPCHAR
|
/* Copy the contents of pg_user to the pg_pwd ASCII file using a the SEPCHAR
|
||||||
* character as the delimiter between fields. Then rename the file to its
|
* character as the delimiter between fields. Then rename the file to its
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/executor/nodeHash.c,v 1.16 1998/01/13 04:03:53 scrappy Exp $
|
* $Header: /cvsroot/pgsql/src/backend/executor/nodeHash.c,v 1.17 1998/01/25 05:13:03 momjian Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -30,7 +30,7 @@
|
|||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
#include "postgres.h"
|
#include "postgres.h"
|
||||||
|
#include "miscadmin.h"
|
||||||
#include "executor/execdebug.h"
|
#include "executor/execdebug.h"
|
||||||
#include "executor/executor.h"
|
#include "executor/executor.h"
|
||||||
#include "executor/nodeHash.h"
|
#include "executor/nodeHash.h"
|
||||||
@ -887,6 +887,6 @@ static int hjtmpcnt = 0;
|
|||||||
static void
|
static void
|
||||||
mk_hj_temp(char *tempname)
|
mk_hj_temp(char *tempname)
|
||||||
{
|
{
|
||||||
sprintf(tempname, "HJ%d.%d", (int) getpid(), hjtmpcnt);
|
sprintf(tempname, "HJ%d.%d", (int) MyProcPid, hjtmpcnt);
|
||||||
hjtmpcnt = (hjtmpcnt + 1) % 1000;
|
hjtmpcnt = (hjtmpcnt + 1) % 1000;
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/libpq/pqcomm.c,v 1.33 1998/01/07 21:03:21 momjian Exp $
|
* $Header: /cvsroot/pgsql/src/backend/libpq/pqcomm.c,v 1.34 1998/01/25 05:13:18 momjian Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -56,6 +56,7 @@
|
|||||||
|
|
||||||
#include <postgres.h>
|
#include <postgres.h>
|
||||||
|
|
||||||
|
#include <miscadmin.h>
|
||||||
#include <libpq/pqsignal.h>
|
#include <libpq/pqsignal.h>
|
||||||
#include <libpq/auth.h>
|
#include <libpq/auth.h>
|
||||||
#include <libpq/libpq.h> /* where the declarations go */
|
#include <libpq/libpq.h> /* where the declarations go */
|
||||||
@ -515,11 +516,11 @@ pq_regoob(void (*fptr) ())
|
|||||||
int fd = fileno(Pfout);
|
int fd = fileno(Pfout);
|
||||||
|
|
||||||
#if defined(hpux)
|
#if defined(hpux)
|
||||||
ioctl(fd, FIOSSAIOOWN, getpid());
|
ioctl(fd, FIOSSAIOOWN, MyProcPid);
|
||||||
#elif defined(sco)
|
#elif defined(sco)
|
||||||
ioctl(fd, SIOCSPGRP, getpid());
|
ioctl(fd, SIOCSPGRP, MyProcPid);
|
||||||
#else
|
#else
|
||||||
fcntl(fd, F_SETOWN, getpid());
|
fcntl(fd, F_SETOWN, MyProcPid);
|
||||||
#endif /* hpux */
|
#endif /* hpux */
|
||||||
pqsignal(SIGURG, fptr);
|
pqsignal(SIGURG, fptr);
|
||||||
}
|
}
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/postmaster/postmaster.c,v 1.68 1997/12/19 02:06:37 scrappy Exp $
|
* $Header: /cvsroot/pgsql/src/backend/postmaster/postmaster.c,v 1.69 1998/01/25 05:13:35 momjian Exp $
|
||||||
*
|
*
|
||||||
* NOTES
|
* NOTES
|
||||||
*
|
*
|
||||||
@ -1337,7 +1337,7 @@ DoExec(StartupInfo *packet, int portFd)
|
|||||||
if (DebugLvl > 1)
|
if (DebugLvl > 1)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "%s child[%ld]: execv(",
|
fprintf(stderr, "%s child[%ld]: execv(",
|
||||||
progname, (long) getpid());
|
progname, (long) MyProcPid);
|
||||||
for (i = 0; i < ac; ++i)
|
for (i = 0; i < ac; ++i)
|
||||||
fprintf(stderr, "%s, ", av[i]);
|
fprintf(stderr, "%s, ", av[i]);
|
||||||
fprintf(stderr, ")\n");
|
fprintf(stderr, ")\n");
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/storage/buffer/bufmgr.c,v 1.31 1998/01/07 21:04:49 momjian Exp $
|
* $Header: /cvsroot/pgsql/src/backend/storage/buffer/bufmgr.c,v 1.32 1998/01/25 05:13:53 momjian Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -1828,14 +1828,10 @@ refcount = %ld, file: %s, line: %d\n",
|
|||||||
|
|
||||||
_bm_trace(Oid dbId, Oid relId, int blkNo, int bufNo, int allocType)
|
_bm_trace(Oid dbId, Oid relId, int blkNo, int bufNo, int allocType)
|
||||||
{
|
{
|
||||||
static int mypid = 0;
|
|
||||||
long start,
|
long start,
|
||||||
cur;
|
cur;
|
||||||
bmtrace *tb;
|
bmtrace *tb;
|
||||||
|
|
||||||
if (mypid == 0)
|
|
||||||
mypid = getpid();
|
|
||||||
|
|
||||||
start = *CurTraceBuf;
|
start = *CurTraceBuf;
|
||||||
|
|
||||||
if (start > 0)
|
if (start > 0)
|
||||||
@ -1871,7 +1867,7 @@ _bm_trace(Oid dbId, Oid relId, int blkNo, int bufNo, int allocType)
|
|||||||
|
|
||||||
okay:
|
okay:
|
||||||
tb = &TraceBuf[start];
|
tb = &TraceBuf[start];
|
||||||
tb->bmt_pid = mypid;
|
tb->bmt_pid = MyProcPid;
|
||||||
tb->bmt_buf = bufNo;
|
tb->bmt_buf = bufNo;
|
||||||
tb->bmt_dbid = dbId;
|
tb->bmt_dbid = dbId;
|
||||||
tb->bmt_relid = relId;
|
tb->bmt_relid = relId;
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/storage/lmgr/lock.c,v 1.20 1998/01/23 22:16:46 momjian Exp $
|
* $Header: /cvsroot/pgsql/src/backend/storage/lmgr/lock.c,v 1.21 1998/01/25 05:14:02 momjian Exp $
|
||||||
*
|
*
|
||||||
* NOTES
|
* NOTES
|
||||||
* Outside modules can create a lock table and acquire/release
|
* Outside modules can create a lock table and acquire/release
|
||||||
@ -37,6 +37,7 @@
|
|||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
#include "postgres.h"
|
#include "postgres.h"
|
||||||
|
#include "miscadmin.h"
|
||||||
#include "storage/shmem.h"
|
#include "storage/shmem.h"
|
||||||
#include "storage/spin.h"
|
#include "storage/spin.h"
|
||||||
#include "storage/proc.h"
|
#include "storage/proc.h"
|
||||||
@ -77,7 +78,7 @@ static char *lock_types[] = {
|
|||||||
if ((lockDebug >= 1) && (tag->relId >= lock_debug_oid_min)) \
|
if ((lockDebug >= 1) && (tag->relId >= lock_debug_oid_min)) \
|
||||||
elog(DEBUG, \
|
elog(DEBUG, \
|
||||||
"%s: pid (%d) rel (%d) dbid (%d) tid (%d,%d) type (%s)",where, \
|
"%s: pid (%d) rel (%d) dbid (%d) tid (%d,%d) type (%s)",where, \
|
||||||
getpid(),\
|
MyProcPid,\
|
||||||
tag->relId, tag->dbId, \
|
tag->relId, tag->dbId, \
|
||||||
((tag->tupleId.ip_blkid.bi_hi<<16)+\
|
((tag->tupleId.ip_blkid.bi_hi<<16)+\
|
||||||
tag->tupleId.ip_blkid.bi_lo),\
|
tag->tupleId.ip_blkid.bi_lo),\
|
||||||
@ -92,7 +93,7 @@ static char *lock_types[] = {
|
|||||||
elog(DEBUG, \
|
elog(DEBUG, \
|
||||||
"%s: pid (%d) rel (%d) dbid (%d) tid (%d,%d) nHolding (%d) "\
|
"%s: pid (%d) rel (%d) dbid (%d) tid (%d,%d) nHolding (%d) "\
|
||||||
"holders (%d,%d,%d,%d,%d) type (%s)",where, \
|
"holders (%d,%d,%d,%d,%d) type (%s)",where, \
|
||||||
getpid(),\
|
MyProcPid,\
|
||||||
lock->tag.relId, lock->tag.dbId, \
|
lock->tag.relId, lock->tag.dbId, \
|
||||||
((lock->tag.tupleId.ip_blkid.bi_hi<<16)+\
|
((lock->tag.tupleId.ip_blkid.bi_hi<<16)+\
|
||||||
lock->tag.tupleId.ip_blkid.bi_lo),\
|
lock->tag.tupleId.ip_blkid.bi_lo),\
|
||||||
@ -113,7 +114,7 @@ static char *lock_types[] = {
|
|||||||
"%s: pid (%d) xid (%d) pid (%d) lock (%x) nHolding (%d) "\
|
"%s: pid (%d) xid (%d) pid (%d) lock (%x) nHolding (%d) "\
|
||||||
"holders (%d,%d,%d,%d,%d)",\
|
"holders (%d,%d,%d,%d,%d)",\
|
||||||
where,\
|
where,\
|
||||||
getpid(),\
|
MyProcPid,\
|
||||||
xidentP->tag.xid,\
|
xidentP->tag.xid,\
|
||||||
xidentP->tag.pid,\
|
xidentP->tag.pid,\
|
||||||
xidentP->tag.lock,\
|
xidentP->tag.lock,\
|
||||||
@ -550,7 +551,7 @@ LockAcquire(LockTableId tableId, LOCKTAG *lockName, LOCKT lockt)
|
|||||||
#ifdef USER_LOCKS
|
#ifdef USER_LOCKS
|
||||||
if (is_user_lock)
|
if (is_user_lock)
|
||||||
{
|
{
|
||||||
item.tag.pid = getpid();
|
item.tag.pid = MyProcPid;
|
||||||
item.tag.xid = myXid = 0;
|
item.tag.xid = myXid = 0;
|
||||||
#ifdef USER_LOCKS_DEBUG
|
#ifdef USER_LOCKS_DEBUG
|
||||||
elog(NOTICE, "LockAcquire: user lock xid [%d,%d,%d]",
|
elog(NOTICE, "LockAcquire: user lock xid [%d,%d,%d]",
|
||||||
@ -975,7 +976,7 @@ LockRelease(LockTableId tableId, LOCKTAG *lockName, LOCKT lockt)
|
|||||||
#ifdef USER_LOCKS
|
#ifdef USER_LOCKS
|
||||||
if (is_user_lock)
|
if (is_user_lock)
|
||||||
{
|
{
|
||||||
item.tag.pid = getpid();
|
item.tag.pid = MyProcPid;
|
||||||
item.tag.xid = 0;
|
item.tag.xid = 0;
|
||||||
#ifdef USER_LOCKS_DEBUG
|
#ifdef USER_LOCKS_DEBUG
|
||||||
elog(NOTICE, "LockRelease: user lock xid [%d,%d,%d]",
|
elog(NOTICE, "LockRelease: user lock xid [%d,%d,%d]",
|
||||||
@ -1153,14 +1154,12 @@ LockReleaseAll(LockTableId tableId, SHM_QUEUE *lockQueue)
|
|||||||
|
|
||||||
#ifdef USER_LOCKS
|
#ifdef USER_LOCKS
|
||||||
int is_user_lock_table,
|
int is_user_lock_table,
|
||||||
my_pid,
|
|
||||||
count,
|
count,
|
||||||
nskip;
|
nskip;
|
||||||
|
|
||||||
is_user_lock_table = (tableId == 0);
|
is_user_lock_table = (tableId == 0);
|
||||||
my_pid = getpid();
|
|
||||||
#ifdef USER_LOCKS_DEBUG
|
#ifdef USER_LOCKS_DEBUG
|
||||||
elog(NOTICE, "LockReleaseAll: tableId=%d, pid=%d", tableId, my_pid);
|
elog(NOTICE, "LockReleaseAll: tableId=%d, pid=%d", tableId, MyProcPid);
|
||||||
#endif
|
#endif
|
||||||
if (is_user_lock_table)
|
if (is_user_lock_table)
|
||||||
{
|
{
|
||||||
@ -1226,7 +1225,7 @@ LockReleaseAll(LockTableId tableId, SHM_QUEUE *lockQueue)
|
|||||||
nskip++;
|
nskip++;
|
||||||
goto next_item;
|
goto next_item;
|
||||||
}
|
}
|
||||||
if (xidLook->tag.pid != my_pid)
|
if (xidLook->tag.pid != MyProcPid)
|
||||||
{
|
{
|
||||||
/* This should never happen */
|
/* This should never happen */
|
||||||
#ifdef USER_LOCKS_DEBUG
|
#ifdef USER_LOCKS_DEBUG
|
||||||
@ -1433,13 +1432,11 @@ DumpLocks()
|
|||||||
SPINLOCK masterLock;
|
SPINLOCK masterLock;
|
||||||
int nLockTypes;
|
int nLockTypes;
|
||||||
LOCK *lock;
|
LOCK *lock;
|
||||||
int pid,
|
|
||||||
count;
|
count;
|
||||||
int tableId = 1;
|
int tableId = 1;
|
||||||
LOCKTAB *ltable;
|
LOCKTAB *ltable;
|
||||||
|
|
||||||
pid = getpid();
|
ShmemPIDLookup(MyProcPid, &location);
|
||||||
ShmemPIDLookup(pid, &location);
|
|
||||||
if (location == INVALID_OFFSET)
|
if (location == INVALID_OFFSET)
|
||||||
return;
|
return;
|
||||||
proc = (PROC *) MAKE_PTR(location);
|
proc = (PROC *) MAKE_PTR(location);
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/storage/lmgr/proc.c,v 1.27 1998/01/23 22:16:48 momjian Exp $
|
* $Header: /cvsroot/pgsql/src/backend/storage/lmgr/proc.c,v 1.28 1998/01/25 05:14:09 momjian Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -46,7 +46,7 @@
|
|||||||
* This is so that we can support more backends. (system-wide semaphore
|
* This is so that we can support more backends. (system-wide semaphore
|
||||||
* sets run out pretty fast.) -ay 4/95
|
* sets run out pretty fast.) -ay 4/95
|
||||||
*
|
*
|
||||||
* $Header: /cvsroot/pgsql/src/backend/storage/lmgr/proc.c,v 1.27 1998/01/23 22:16:48 momjian Exp $
|
* $Header: /cvsroot/pgsql/src/backend/storage/lmgr/proc.c,v 1.28 1998/01/25 05:14:09 momjian Exp $
|
||||||
*/
|
*/
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
@ -127,7 +127,6 @@ InitProcGlobal(IPCKey key)
|
|||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
ProcGlobal->numProcs = 0;
|
|
||||||
ProcGlobal->freeProcs = INVALID_OFFSET;
|
ProcGlobal->freeProcs = INVALID_OFFSET;
|
||||||
ProcGlobal->currKey = IPCGetProcessSemaphoreInitKey(key);
|
ProcGlobal->currKey = IPCGetProcessSemaphoreInitKey(key);
|
||||||
for (i = 0; i < MAX_PROC_SEMS / PROC_NSEMS_PER_SET; i++)
|
for (i = 0; i < MAX_PROC_SEMS / PROC_NSEMS_PER_SET; i++)
|
||||||
@ -144,7 +143,6 @@ void
|
|||||||
InitProcess(IPCKey key)
|
InitProcess(IPCKey key)
|
||||||
{
|
{
|
||||||
bool found = false;
|
bool found = false;
|
||||||
int pid;
|
|
||||||
int semstat;
|
int semstat;
|
||||||
unsigned long location,
|
unsigned long location,
|
||||||
myOffset;
|
myOffset;
|
||||||
@ -201,8 +199,6 @@ InitProcess(IPCKey key)
|
|||||||
|
|
||||||
/* this cannot be initialized until after the buffer pool */
|
/* this cannot be initialized until after the buffer pool */
|
||||||
SHMQueueInit(&(MyProc->lockQueue));
|
SHMQueueInit(&(MyProc->lockQueue));
|
||||||
MyProc->procId = ProcGlobal->numProcs;
|
|
||||||
ProcGlobal->numProcs++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -253,11 +249,8 @@ InitProcess(IPCKey key)
|
|||||||
*/
|
*/
|
||||||
SpinRelease(ProcStructLock);
|
SpinRelease(ProcStructLock);
|
||||||
|
|
||||||
MyProc->pid = 0;
|
MyProc->pid = MyProcPid;
|
||||||
MyProc->xid = InvalidTransactionId;
|
MyProc->xid = InvalidTransactionId;
|
||||||
#if 0
|
|
||||||
MyProc->pid = MyPid;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* ----------------
|
/* ----------------
|
||||||
* Start keeping spin lock stats from here on. Any botch before
|
* Start keeping spin lock stats from here on. Any botch before
|
||||||
@ -273,9 +266,8 @@ InitProcess(IPCKey key)
|
|||||||
* exit.
|
* exit.
|
||||||
* -------------------------
|
* -------------------------
|
||||||
*/
|
*/
|
||||||
pid = getpid();
|
|
||||||
location = MAKE_OFFSET(MyProc);
|
location = MAKE_OFFSET(MyProc);
|
||||||
if ((!ShmemPIDLookup(pid, &location)) || (location != MAKE_OFFSET(MyProc)))
|
if ((!ShmemPIDLookup(MyProcPid, &location)) || (location != MAKE_OFFSET(MyProc)))
|
||||||
{
|
{
|
||||||
elog(FATAL, "InitProc: ShmemPID table broken");
|
elog(FATAL, "InitProc: ShmemPID table broken");
|
||||||
}
|
}
|
||||||
@ -283,7 +275,7 @@ InitProcess(IPCKey key)
|
|||||||
MyProc->errType = NO_ERROR;
|
MyProc->errType = NO_ERROR;
|
||||||
SHMQueueElemInit(&(MyProc->links));
|
SHMQueueElemInit(&(MyProc->links));
|
||||||
|
|
||||||
on_exitpg(ProcKill, (caddr_t) pid);
|
on_exitpg(ProcKill, (caddr_t) MyProcPid);
|
||||||
|
|
||||||
ProcInitialized = TRUE;
|
ProcInitialized = TRUE;
|
||||||
}
|
}
|
||||||
@ -352,12 +344,7 @@ ProcKill(int exitStatus, int pid)
|
|||||||
if (exitStatus != 0)
|
if (exitStatus != 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (!pid)
|
ShmemPIDLookup(MyProcPid, &location);
|
||||||
{
|
|
||||||
pid = getpid();
|
|
||||||
}
|
|
||||||
|
|
||||||
ShmemPIDLookup(pid, &location);
|
|
||||||
if (location == INVALID_OFFSET)
|
if (location == INVALID_OFFSET)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -365,7 +352,7 @@ ProcKill(int exitStatus, int pid)
|
|||||||
|
|
||||||
if (proc != MyProc)
|
if (proc != MyProc)
|
||||||
{
|
{
|
||||||
Assert(pid != getpid());
|
Assert(pid != MyProcPid);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
MyProc = NULL;
|
MyProc = NULL;
|
||||||
@ -478,7 +465,7 @@ ProcSleep(PROC_QUEUE *queue,
|
|||||||
MyProc->prio = prio;
|
MyProc->prio = prio;
|
||||||
MyProc->token = token;
|
MyProc->token = token;
|
||||||
MyProc->waitLock = lock;
|
MyProc->waitLock = lock;
|
||||||
|
|
||||||
/* -------------------
|
/* -------------------
|
||||||
* currently, we only need this for the ProcWakeup routines
|
* currently, we only need this for the ProcWakeup routines
|
||||||
* -------------------
|
* -------------------
|
||||||
@ -572,19 +559,6 @@ ProcWakeup(PROC *proc, int errType)
|
|||||||
return retProc;
|
return retProc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* ProcGetId --
|
|
||||||
*/
|
|
||||||
#ifdef NOT_USED
|
|
||||||
int
|
|
||||||
ProcGetId()
|
|
||||||
{
|
|
||||||
return (MyProc->procId);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* ProcLockWakeup -- routine for waking up processes when a lock is
|
* ProcLockWakeup -- routine for waking up processes when a lock is
|
||||||
* released.
|
* released.
|
||||||
@ -652,8 +626,7 @@ ProcAddLock(SHM_QUEUE *elem)
|
|||||||
static void
|
static void
|
||||||
HandleDeadLock(int sig)
|
HandleDeadLock(int sig)
|
||||||
{
|
{
|
||||||
LOCK *lock;
|
LOCK *mywaitlock;
|
||||||
int size;
|
|
||||||
|
|
||||||
LockLockTable();
|
LockLockTable();
|
||||||
|
|
||||||
@ -692,8 +665,7 @@ HandleDeadLock(int sig)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
lock = MyProc->waitLock;
|
mywaitlock = MyProc->waitLock;
|
||||||
size = lock->waitProcs.size;/* so we can look at this in the core */
|
|
||||||
|
|
||||||
#ifdef DEADLOCK_DEBUG
|
#ifdef DEADLOCK_DEBUG
|
||||||
DumpLocks();
|
DumpLocks();
|
||||||
@ -703,8 +675,8 @@ HandleDeadLock(int sig)
|
|||||||
* Get this process off the lock's wait queue
|
* Get this process off the lock's wait queue
|
||||||
* ------------------------
|
* ------------------------
|
||||||
*/
|
*/
|
||||||
Assert(lock->waitProcs.size > 0);
|
Assert(mywaitlock->waitProcs.size > 0);
|
||||||
--lock->waitProcs.size;
|
--mywaitlock->waitProcs.size;
|
||||||
SHMQueueDelete(&(MyProc->links));
|
SHMQueueDelete(&(MyProc->links));
|
||||||
SHMQueueElemInit(&(MyProc->links));
|
SHMQueueElemInit(&(MyProc->links));
|
||||||
|
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/tcop/postgres.c,v 1.61 1998/01/13 04:04:36 scrappy Exp $
|
* $Header: /cvsroot/pgsql/src/backend/tcop/postgres.c,v 1.62 1998/01/25 05:14:18 momjian Exp $
|
||||||
*
|
*
|
||||||
* NOTES
|
* NOTES
|
||||||
* this is the "main" module of the postgres backend and
|
* this is the "main" module of the postgres backend and
|
||||||
@ -886,7 +886,7 @@ PostgresMain(int argc, char *argv[])
|
|||||||
* -------------------
|
* -------------------
|
||||||
*/
|
*/
|
||||||
|
|
||||||
MasterPid = getpid();
|
MyProcPid = getpid();
|
||||||
|
|
||||||
/* ----------------
|
/* ----------------
|
||||||
* parse command line arguments
|
* parse command line arguments
|
||||||
@ -1381,7 +1381,7 @@ PostgresMain(int argc, char *argv[])
|
|||||||
if (IsUnderPostmaster == false)
|
if (IsUnderPostmaster == false)
|
||||||
{
|
{
|
||||||
puts("\nPOSTGRES backend interactive interface");
|
puts("\nPOSTGRES backend interactive interface");
|
||||||
puts("$Revision: 1.61 $ $Date: 1998/01/13 04:04:36 $");
|
puts("$Revision: 1.62 $ $Date: 1998/01/25 05:14:18 $");
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ----------------
|
/* ----------------
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/tcop/utility.c,v 1.36 1998/01/05 18:43:09 momjian Exp $
|
* $Header: /cvsroot/pgsql/src/backend/tcop/utility.c,v 1.37 1998/01/25 05:14:27 momjian Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -589,7 +589,7 @@ ProcessUtility(Node * parsetree,
|
|||||||
commandTag = "LISTEN";
|
commandTag = "LISTEN";
|
||||||
CHECK_IF_ABORTED();
|
CHECK_IF_ABORTED();
|
||||||
|
|
||||||
Async_Listen(stmt->relname, MasterPid);
|
Async_Listen(stmt->relname, MyProcPid);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/utils/error/elog.c,v 1.24 1998/01/07 21:06:23 momjian Exp $
|
* $Header: /cvsroot/pgsql/src/backend/utils/error/elog.c,v 1.25 1998/01/25 05:14:35 momjian Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -177,7 +177,7 @@ elog(int lev, const char *fmt,...)
|
|||||||
ProcReleaseSpins(NULL); /* get rid of spinlocks we hold */
|
ProcReleaseSpins(NULL); /* get rid of spinlocks we hold */
|
||||||
if (!InError)
|
if (!InError)
|
||||||
{
|
{
|
||||||
kill(getpid(), 1); /* abort to traffic cop */
|
kill(MyProcPid, 1); /* abort to traffic cop */
|
||||||
pause();
|
pause();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -257,7 +257,7 @@ DebugFileOpen(void)
|
|||||||
if (fcntl(fd, F_GETFD, 0) < 0)
|
if (fcntl(fd, F_GETFD, 0) < 0)
|
||||||
{
|
{
|
||||||
sprintf(OutputFileName, "%s/pg.errors.%d",
|
sprintf(OutputFileName, "%s/pg.errors.%d",
|
||||||
DataDir, (int) getpid());
|
DataDir, (int) MyProcPid);
|
||||||
fd = open(OutputFileName, O_CREAT | O_APPEND | O_WRONLY, 0666);
|
fd = open(OutputFileName, O_CREAT | O_APPEND | O_WRONLY, 0666);
|
||||||
}
|
}
|
||||||
if (fd < 0)
|
if (fd < 0)
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/utils/init/globals.c,v 1.17 1997/11/24 05:09:13 momjian Exp $
|
* $Header: /cvsroot/pgsql/src/backend/utils/init/globals.c,v 1.18 1998/01/25 05:14:42 momjian Exp $
|
||||||
*
|
*
|
||||||
* NOTES
|
* NOTES
|
||||||
* Globals used all over the place should be declared here and not
|
* Globals used all over the place should be declared here and not
|
||||||
@ -39,7 +39,8 @@ int Portfd = -1;
|
|||||||
int Noversion = 0;
|
int Noversion = 0;
|
||||||
int Quiet = 1;
|
int Quiet = 1;
|
||||||
|
|
||||||
int MasterPid;
|
int MyProcPid;
|
||||||
|
|
||||||
char *DataDir;
|
char *DataDir;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/utils/sort/Attic/psort.c,v 1.32 1998/01/15 19:46:10 pgsql Exp $
|
* $Header: /cvsroot/pgsql/src/backend/utils/sort/Attic/psort.c,v 1.33 1998/01/25 05:14:49 momjian Exp $
|
||||||
*
|
*
|
||||||
* NOTES
|
* NOTES
|
||||||
* Sorts the first relation into the second relation.
|
* Sorts the first relation into the second relation.
|
||||||
@ -988,7 +988,7 @@ gettape()
|
|||||||
|
|
||||||
tp = (struct tapelst *) palloc((unsigned) sizeof(struct tapelst));
|
tp = (struct tapelst *) palloc((unsigned) sizeof(struct tapelst));
|
||||||
|
|
||||||
sprintf(uniqueName, "%spg_psort.%d.%d", TEMPDIR, (int) getpid(), uniqueFileId);
|
sprintf(uniqueName, "%spg_psort.%d.%d", TEMPDIR, (int) MyProcPid, uniqueFileId);
|
||||||
uniqueFileId++;
|
uniqueFileId++;
|
||||||
|
|
||||||
tapeinit = 1;
|
tapeinit = 1;
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
*
|
*
|
||||||
* Copyright (c) 1994, Regents of the University of California
|
* Copyright (c) 1994, Regents of the University of California
|
||||||
*
|
*
|
||||||
* $Id: miscadmin.h,v 1.18 1997/12/04 23:58:01 thomas Exp $
|
* $Id: miscadmin.h,v 1.19 1998/01/25 05:15:01 momjian Exp $
|
||||||
*
|
*
|
||||||
* NOTES
|
* NOTES
|
||||||
* some of the information in this file will be moved to
|
* some of the information in this file will be moved to
|
||||||
@ -36,10 +36,11 @@ extern int PostmasterMain(int argc, char *argv[]);
|
|||||||
*/
|
*/
|
||||||
extern int Portfd;
|
extern int Portfd;
|
||||||
extern int Noversion;
|
extern int Noversion;
|
||||||
extern int MasterPid;
|
|
||||||
extern int Quiet;
|
extern int Quiet;
|
||||||
extern char *DataDir;
|
extern char *DataDir;
|
||||||
|
|
||||||
|
extern int MyProcPid;
|
||||||
|
|
||||||
extern char OutputFileName[];
|
extern char OutputFileName[];
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
*
|
*
|
||||||
* Copyright (c) 1994, Regents of the University of California
|
* Copyright (c) 1994, Regents of the University of California
|
||||||
*
|
*
|
||||||
* $Id: proc.h,v 1.9 1998/01/23 06:01:25 momjian Exp $
|
* $Id: proc.h,v 1.10 1998/01/25 05:15:15 momjian Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -35,10 +35,6 @@ typedef struct proc
|
|||||||
SEMA sem; /* ONE semaphore to sleep on */
|
SEMA sem; /* ONE semaphore to sleep on */
|
||||||
int errType; /* error code tells why we woke up */
|
int errType; /* error code tells why we woke up */
|
||||||
|
|
||||||
int procId; /* unique number for this structure NOT
|
|
||||||
* unique per backend, these things are
|
|
||||||
* reused after the backend dies. */
|
|
||||||
|
|
||||||
int critSects; /* If critSects > 0, we are in sensitive
|
int critSects; /* If critSects > 0, we are in sensitive
|
||||||
* routines that cannot be recovered when
|
* routines that cannot be recovered when
|
||||||
* the process fails. */
|
* the process fails. */
|
||||||
@ -69,7 +65,6 @@ typedef struct proc
|
|||||||
typedef struct procglobal
|
typedef struct procglobal
|
||||||
{
|
{
|
||||||
SHMEM_OFFSET freeProcs;
|
SHMEM_OFFSET freeProcs;
|
||||||
int numProcs;
|
|
||||||
IPCKey currKey;
|
IPCKey currKey;
|
||||||
int32 freeSemMap[MAX_PROC_SEMS / PROC_NSEMS_PER_SET];
|
int32 freeSemMap[MAX_PROC_SEMS / PROC_NSEMS_PER_SET];
|
||||||
} PROC_HDR;
|
} PROC_HDR;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user