Commit eec08b95 authored by Bruce Momjian's avatar Bruce Momjian

[all] Removed call to getppid in SendPostmasterSignal, replacing with a

PostmasterPid variable, which gets set (early) in PostmasterMain
getppid would not be the postmaster?

[fork/exec] Implements processCancelRequest by keeping an array of

pid/cancel_key structs in shared mem

[fork/exec] Moves AttachSharedMemoryAndSemaphores call for backends into
SubPostmasterMain

[win32] Implements reaper/waitpid by keeping an arrays of children
pids,handles in postmaster local mem
      - this item is largely untested, for reasons which should be
obvious, but appears sound

[win32/all] Added extern for pgpipe in Win32 case, and changed the second
pipe call (which seems to have been missed earlier) to pgpipe

[win32] #define'd ftruncate to chsize in the Win32 case

[win32] PG_USLEEP for Win32 has a misplaced paren. Fixed.

[win32] DLLIMPORT handling for MingW case


Claudio Natoli
parent ede3b762
......@@ -13,7 +13,7 @@
*
* Copyright (c) 2001-2003, PostgreSQL Global Development Group
*
* $PostgreSQL: pgsql/src/backend/postmaster/pgstat.c,v 1.55 2004/01/26 22:54:56 momjian Exp $
* $PostgreSQL: pgsql/src/backend/postmaster/pgstat.c,v 1.56 2004/01/26 22:59:53 momjian Exp $
* ----------
*/
#include "postgres.h"
......@@ -147,7 +147,7 @@ static void pgstat_recv_resetcounter(PgStat_MsgResetcounter *msg, int len);
#define piperead(a,b,c) read(a,b,c)
#define pipewrite(a,b,c) write(a,b,c)
#else
/* pgpipe() is in /src/port */
extern int pgpipe(int handles[2]); /* pgpipe() is in /src/port */
#define piperead(a,b,c) recv(a,b,c,0)
#define pipewrite(a,b,c) send(a,b,c,0)
#endif
......@@ -322,7 +322,7 @@ pgstat_init(void)
/*
* Create the pipe that controls the statistics collector shutdown
*/
if (pipe(pgStatPmPipe) < 0)
if (pgpipe(pgStatPmPipe) < 0)
{
ereport(LOG,
(errcode_for_socket_access(),
......
This diff is collapsed.
......@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/storage/ipc/ipci.c,v 1.62 2004/01/26 22:54:57 momjian Exp $
* $PostgreSQL: pgsql/src/backend/storage/ipc/ipci.c,v 1.63 2004/01/26 22:59:53 momjian Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -63,6 +63,9 @@ CreateSharedMemoryAndSemaphores(bool makePrivate,
size += LWLockShmemSize();
size += SInvalShmemSize(maxBackends);
size += FreeSpaceShmemSize();
#ifdef EXEC_BACKEND
size += ShmemBackendArraySize();
#endif
#ifdef STABLE_MEMORY_STORAGE
size += MMShmemSize();
#endif
......@@ -132,6 +135,13 @@ CreateSharedMemoryAndSemaphores(bool makePrivate,
* Set up child-to-postmaster signaling mechanism
*/
PMSignalInit();
#ifdef EXEC_BACKEND
/*
* Alloc the win32 shared backend array
*/
ShmemBackendArrayAllocation();
#endif
}
......
......@@ -8,7 +8,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/storage/ipc/pmsignal.c,v 1.10 2004/01/26 22:54:57 momjian Exp $
* $PostgreSQL: pgsql/src/backend/storage/ipc/pmsignal.c,v 1.11 2004/01/26 22:59:53 momjian Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -63,8 +63,8 @@ SendPostmasterSignal(PMSignalReason reason)
return;
/* Atomically set the proper flag */
PMSignalFlags[reason] = true;
/* Send signal to postmaster (assume it is our direct parent) */
kill(getppid(), SIGUSR1);
/* Send signal to postmaster */
kill(PostmasterPid, SIGUSR1);
}
/*
......
......@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/tcop/postgres.c,v 1.385 2004/01/26 22:54:57 momjian Exp $
* $PostgreSQL: pgsql/src/backend/tcop/postgres.c,v 1.386 2004/01/26 22:59:53 momjian Exp $
*
* NOTES
* this is the "main" module of the postgres backend and
......@@ -2535,9 +2535,7 @@ PostgresMain(int argc, char *argv[], const char *username)
errmsg("invalid command-line arguments for server process"),
errhint("Try \"%s --help\" for more information.", argv[0])));
}
#ifdef EXEC_BACKEND
AttachSharedMemoryAndSemaphores();
#endif
XLOGPathInit();
BaseInit();
......
......@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/utils/init/globals.c,v 1.79 2004/01/26 22:54:57 momjian Exp $
* $PostgreSQL: pgsql/src/backend/utils/init/globals.c,v 1.80 2004/01/26 22:59:53 momjian Exp $
*
* NOTES
* Globals used all over the place should be declared here and not
......@@ -53,6 +53,8 @@ BackendId MyBackendId;
char *DatabasePath = NULL;
Oid MyDatabaseId = InvalidOid;
pid_t PostmasterPid = 0;
/* these are initialized for the bootstrap/standalone case: */
bool IsPostmasterEnvironment = false;
bool IsUnderPostmaster = false;
......
......@@ -12,7 +12,7 @@
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* $PostgreSQL: pgsql/src/include/miscadmin.h,v 1.147 2004/01/26 22:54:57 momjian Exp $
* $PostgreSQL: pgsql/src/include/miscadmin.h,v 1.148 2004/01/26 22:59:53 momjian Exp $
*
* NOTES
* some of the information in this file should be moved to
......@@ -109,10 +109,14 @@ do { \
#else
#define PG_USLEEP(_usec) \
do { \
Sleep(_usec < 500) ? 1 : (_usec+500)/ 1000); \
Sleep((_usec) < 500 ? 1 : ((_usec)+500)/ 1000); \
} while(0)
#endif
#ifdef WIN32
#define ftruncate(a,b) chsize(a,b)
#endif
/*****************************************************************************
* globals.h -- *
*****************************************************************************/
......@@ -132,6 +136,7 @@ extern void ClosePostmasterPorts(bool pgstat_too);
/*
* from utils/init/globals.c
*/
extern pid_t PostmasterPid;
extern bool IsPostmasterEnvironment;
extern bool IsUnderPostmaster;
......
/* $PostgreSQL: pgsql/src/include/port/win32.h,v 1.15 2004/01/26 22:54:58 momjian Exp $ */
/* $PostgreSQL: pgsql/src/include/port/win32.h,v 1.16 2004/01/26 22:59:54 momjian Exp $ */
/* undefine and redefine after #include */
#undef mkdir
......@@ -15,7 +15,7 @@
#define NOFILE 100
/* defines for dynamic linking on Win32 platform */
#ifdef __CYGWIN__
#if defined(__CYGWIN__) || defined(__MINGW32__)
#if __GNUC__ && ! defined (__declspec)
#error You need egcs 1.1 or newer for compiling!
......@@ -27,7 +27,7 @@
#define DLLIMPORT __declspec (dllimport)
#endif
#elif defined(WIN32) && defined(_MSC_VER) /* not CYGWIN */
#elif defined(WIN32) && defined(_MSC_VER) /* not CYGWIN or MingW */
#if defined(_DLL)
#define DLLIMPORT __declspec (dllexport)
......@@ -35,7 +35,7 @@
#define DLLIMPORT __declspec (dllimport)
#endif
#else /* not CYGWIN, not MSVC */
#else /* not CYGWIN, not MSVC, not MingW */
#define DLLIMPORT
#endif
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment