本文整理汇总了C++中PG_SETMASK函数的典型用法代码示例。如果您正苦于以下问题:C++ PG_SETMASK函数的具体用法?C++ PG_SETMASK怎么用?C++ PG_SETMASK使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了PG_SETMASK函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: PgArchiverMain
/*
* PgArchiverMain
*
* The argc/argv parameters are valid only in EXEC_BACKEND case. However,
* since we don't use 'em, it hardly matters...
*/
NON_EXEC_STATIC void
PgArchiverMain(int argc, char *argv[])
{
/*
* Ignore all signals usually bound to some action in the postmaster,
* except for SIGHUP, SIGTERM, SIGUSR1, SIGUSR2, and SIGQUIT.
*/
pqsignal(SIGHUP, ArchSigHupHandler);
pqsignal(SIGINT, SIG_IGN);
pqsignal(SIGTERM, ArchSigTermHandler);
pqsignal(SIGQUIT, pgarch_exit);
pqsignal(SIGALRM, SIG_IGN);
pqsignal(SIGPIPE, SIG_IGN);
pqsignal(SIGUSR1, pgarch_waken);
pqsignal(SIGUSR2, pgarch_waken_stop);
pqsignal(SIGCHLD, SIG_DFL);
pqsignal(SIGTTIN, SIG_DFL);
pqsignal(SIGTTOU, SIG_DFL);
pqsignal(SIGCONT, SIG_DFL);
pqsignal(SIGWINCH, SIG_DFL);
PG_SETMASK(&UnBlockSig);
/*
* Identify myself via ps
*/
init_ps_display("archiver process", "", "", "");
pgarch_MainLoop();
exit(0);
}
开发者ID:ArgenBarbie,项目名称:postgresql-9.5.0,代码行数:37,代码来源:pgarch.c
示例2: WalSndQuickDieHandler
/*
* WalSndQuickDieHandler() occurs when signalled SIGQUIT by the postmaster.
*
* Some backend has bought the farm,
* so we need to stop what we're doing and exit.
*/
static void
WalSndQuickDieHandler(SIGNAL_ARGS)
{
PG_SETMASK(&BlockSig);
/*
* We DO NOT want to run proc_exit() callbacks -- we're here because
* shared memory may be corrupted, so we don't want to try to clean up our
* transaction. Just nail the windows shut and get out of town. Now that
* there's an atexit callback to prevent third-party code from breaking
* things by calling exit() directly, we have to reset the callbacks
* explicitly to make this work as intended.
*/
on_exit_reset();
/*
* Note we do exit(2) not exit(0). This is to force the postmaster into a
* system reset cycle if some idiot DBA sends a manual SIGQUIT to a random
* backend. This is necessary precisely because we don't clean up our
* shared memory state. (The "dead man switch" mechanism in pmsignal.c
* should ensure the postmaster sees this as a crash, too, but no harm in
* being doubly sure.)
*/
exit(2);
}
开发者ID:ibejoeb,项目名称:postgres,代码行数:31,代码来源:walsender.c
示例3: WalSenderMain
/* Main entry point for walsender process */
int
WalSenderMain(void)
{
MemoryContext walsnd_context;
am_cascading_walsender = RecoveryInProgress();
/* Create a per-walsender data structure in shared memory */
InitWalSnd();
/*
* Create a memory context that we will do all our work in. We do this so
* that we can reset the context during error recovery and thereby avoid
* possible memory leaks. Formerly this code just ran in
* TopMemoryContext, but resetting that would be a really bad idea.
*
* XXX: we don't actually attempt error recovery in walsender, we just
* close the connection and exit.
*/
walsnd_context = AllocSetContextCreate(TopMemoryContext,
"Wal Sender",
ALLOCSET_DEFAULT_MINSIZE,
ALLOCSET_DEFAULT_INITSIZE,
ALLOCSET_DEFAULT_MAXSIZE);
MemoryContextSwitchTo(walsnd_context);
/* Set up resource owner */
CurrentResourceOwner = ResourceOwnerCreate(NULL, "walsender top-level resource owner");
/* Unblock signals (they were blocked when the postmaster forked us) */
PG_SETMASK(&UnBlockSig);
/*
* Use the recovery target timeline ID during recovery
*/
if (am_cascading_walsender)
ThisTimeLineID = GetRecoveryTargetTLI();
/* Tell the standby that walsender is ready for receiving commands */
ReadyForQuery(DestRemote);
/* Handle handshake messages before streaming */
WalSndHandshake();
/* Initialize shared memory status */
{
/* use volatile pointer to prevent code rearrangement */
volatile WalSnd *walsnd = MyWalSnd;
SpinLockAcquire(&walsnd->mutex);
walsnd->sentPtr = sentPtr;
SpinLockRelease(&walsnd->mutex);
}
SyncRepInitConfig();
/* Main loop of walsender */
return WalSndLoop();
}
开发者ID:ibejoeb,项目名称:postgres,代码行数:60,代码来源:walsender.c
示例4: StartupProcessMain
/* ----------------------------------
* Startup Process main entry point
* ----------------------------------
*/
void
StartupProcessMain(void)
{
/*
* If possible, make this process a group leader, so that the postmaster
* can signal any child processes too.
*/
#ifdef HAVE_SETSID
if (setsid() < 0)
elog(FATAL, "setsid() failed: %m");
#endif
/*
* Properly accept or ignore signals the postmaster might send us.
*/
pqsignal(SIGHUP, StartupProcSigHupHandler); /* reload config file */
pqsignal(SIGINT, SIG_IGN); /* ignore query cancel */
pqsignal(SIGTERM, StartupProcShutdownHandler); /* request shutdown */
pqsignal(SIGQUIT, startupproc_quickdie); /* hard crash time */
InitializeTimeouts(); /* establishes SIGALRM handler */
pqsignal(SIGPIPE, SIG_IGN);
pqsignal(SIGUSR1, StartupProcSigUsr1Handler);
pqsignal(SIGUSR2, StartupProcTriggerHandler);
/*
* Reset some signals that are accepted by postmaster but not here
*/
pqsignal(SIGCHLD, SIG_DFL);
pqsignal(SIGTTIN, SIG_DFL);
pqsignal(SIGTTOU, SIG_DFL);
pqsignal(SIGCONT, SIG_DFL);
pqsignal(SIGWINCH, SIG_DFL);
/*
* Register timeouts needed for standby mode
*/
RegisterTimeout(STANDBY_DEADLOCK_TIMEOUT, StandbyDeadLockHandler);
RegisterTimeout(STANDBY_TIMEOUT, StandbyTimeoutHandler);
/*
* Unblock signals (they were blocked when the postmaster forked us)
*/
PG_SETMASK(&UnBlockSig);
/*
* Do what we came for.
*/
StartupXLOG();
/*
* Exit normally. Exit code 0 tells postmaster that we completed recovery
* successfully.
*/
proc_exit(0);
}
开发者ID:fdr,项目名称:postgres,代码行数:59,代码来源:startup.c
示例5: resetTimers
/*
* resetTimers - disable process interval timers
*
* Testing has shown that fork on some systems doesn't clear timers as it should and
* exec is subjected to *fatal* interruption by timers so the timers are disabled
* before the fork is done. Before resetting the interval timers, the all signals
* are blocked. After resetting the interval timers, the signal mask is restored.
*
* otimers: a pointer to an itmers struct to contain the old timer values. If
* NULL, the old timer valuess are not preserved.
*
* Errors from setitimer are not expected and are handled using Assert (as in
* PGSempahoreLockTimed).
*/
void
resetTimers(struct itimers *otimers)
{
int err;
struct itimerval xtimer; /* Zero timer for disabling */
struct itimerval *p_rtimer = NULL; /* ITIMER_REAL */
struct itimerval *p_vtimer = NULL; /* ITIMER_VIRTUAL */
struct itimerval *p_ptimer = NULL; /* ITIMER_PROF */
if (otimers != NULL)
{
p_rtimer = &otimers->rtimer;
p_vtimer = &otimers->vtimer;
p_ptimer = &otimers->ptimer;
}
/*
* Block signals while capturing timers.
*/
PG_SETMASK(&BlockSig);
/*
* Disable all process interval timers preserving the old values if
* requested.
*/
timerclear(&xtimer.it_interval);
timerclear(&xtimer.it_value);
err = setitimer(ITIMER_REAL, &xtimer, p_rtimer);
Assert(err == 0);
err = setitimer(ITIMER_VIRTUAL, &xtimer, p_vtimer);
Assert(err == 0);
err = setitimer(ITIMER_REAL, &xtimer, p_ptimer);
Assert(err == 0);
/*
* Restore signal mask.
*/
PG_SETMASK(&UnBlockSig);
}
开发者ID:PengJi,项目名称:gpdb-comments,代码行数:56,代码来源:cdbtimer.c
示例6: WalSenderMain
/* Main entry point for walsender process */
int
WalSenderMain(void)
{
MemoryContext walsnd_context;
if (RecoveryInProgress())
ereport(FATAL,
(errcode(ERRCODE_CANNOT_CONNECT_NOW),
errmsg("recovery is still in progress, can't accept WAL streaming connections")));
/* Create a per-walsender data structure in shared memory */
InitWalSnd();
/*
* Create a memory context that we will do all our work in. We do this so
* that we can reset the context during error recovery and thereby avoid
* possible memory leaks. Formerly this code just ran in
* TopMemoryContext, but resetting that would be a really bad idea.
*
* XXX: we don't actually attempt error recovery in walsender, we just
* close the connection and exit.
*/
walsnd_context = AllocSetContextCreate(TopMemoryContext,
"Wal Sender",
ALLOCSET_DEFAULT_MINSIZE,
ALLOCSET_DEFAULT_INITSIZE,
ALLOCSET_DEFAULT_MAXSIZE);
MemoryContextSwitchTo(walsnd_context);
/* Unblock signals (they were blocked when the postmaster forked us) */
PG_SETMASK(&UnBlockSig);
/* Tell the standby that walsender is ready for receiving commands */
ReadyForQuery(DestRemote);
/* Handle handshake messages before streaming */
WalSndHandshake();
/* Initialize shared memory status */
{
/* use volatile pointer to prevent code rearrangement */
volatile WalSnd *walsnd = MyWalSnd;
SpinLockAcquire(&walsnd->mutex);
walsnd->sentPtr = sentPtr;
SpinLockRelease(&walsnd->mutex);
}
/* Main loop of walsender */
return WalSndLoop();
}
开发者ID:adunstan,项目名称:pg-cvs-mirror,代码行数:52,代码来源:walsender.c
示例7: PgArchiverMain
/*
* PgArchiverMain
*
* The argc/argv parameters are valid only in EXEC_BACKEND case. However,
* since we don't use 'em, it hardly matters...
*/
NON_EXEC_STATIC void
PgArchiverMain(int argc, char *argv[])
{
IsUnderPostmaster = true; /* we are a postmaster subprocess now */
MyProcPid = getpid(); /* reset MyProcPid */
MyStartTime = time(NULL); /* record Start Time for logging */
/*
* If possible, make this process a group leader, so that the postmaster
* can signal any child processes too.
*/
#ifdef HAVE_SETSID
if (setsid() < 0)
elog(FATAL, "setsid() failed: %m");
#endif
InitializeLatchSupport(); /* needed for latch waits */
InitLatch(&mainloop_latch); /* initialize latch used in main loop */
/*
* Ignore all signals usually bound to some action in the postmaster,
* except for SIGHUP, SIGTERM, SIGUSR1, SIGUSR2, and SIGQUIT.
*/
pqsignal(SIGHUP, ArchSigHupHandler);
pqsignal(SIGINT, SIG_IGN);
pqsignal(SIGTERM, ArchSigTermHandler);
pqsignal(SIGQUIT, pgarch_exit);
pqsignal(SIGALRM, SIG_IGN);
pqsignal(SIGPIPE, SIG_IGN);
pqsignal(SIGUSR1, pgarch_waken);
pqsignal(SIGUSR2, pgarch_waken_stop);
pqsignal(SIGCHLD, SIG_DFL);
pqsignal(SIGTTIN, SIG_DFL);
pqsignal(SIGTTOU, SIG_DFL);
pqsignal(SIGCONT, SIG_DFL);
pqsignal(SIGWINCH, SIG_DFL);
PG_SETMASK(&UnBlockSig);
/*
* Identify myself via ps
*/
init_ps_display("archiver process", "", "", "");
pgarch_MainLoop();
exit(0);
}
开发者ID:42penguins,项目名称:postgres,代码行数:56,代码来源:pgarch.c
示例8: bg_quickdie
/*
* bg_quickdie() occurs when signalled SIGQUIT by the postmaster.
*
* Some backend has bought the farm,
* so we need to stop what we're doing and exit.
*/
static void
bg_quickdie(SIGNAL_ARGS)
{
PG_SETMASK(&BlockSig);
/*
* DO NOT proc_exit() -- we're here because shared memory may be
* corrupted, so we don't want to try to clean up our transaction. Just
* nail the windows shut and get out of town.
*
* Note we do exit(2) not exit(0). This is to force the postmaster into a
* system reset cycle if some idiot DBA sends a manual SIGQUIT to a random
* backend. This is necessary precisely because we don't clean up our
* shared memory state.
*/
exit(2);
}
开发者ID:KMU-embedded,项目名称:mosbench-ext,代码行数:23,代码来源:bgwriter.c
示例9: ServiceQuickDie
/*
* ServiceQuickDie() occurs when signalled SIGQUIT by the postmaster.
*
* Some backend has bought the farm,
* so we need to stop what we're doing and exit.
*/
static void
ServiceQuickDie(SIGNAL_ARGS)
{
PG_SETMASK(&BlockSig);
ereport(LOG,
(errmsg("terminating immediately")));
/* DO ANY SPECIAL SERVICE QUICKDIE HANDLING HERE */
/*
* NOTE: see MPP-9518, MPP-9396, we need to make sure the atexit()
* hooks get cleaned up before calling exit(). quickdie() knows how
* to do that.
*/
quickdie(PASS_SIGNAL_ARGS);
/* not reached */
}
开发者ID:BALDELab,项目名称:incubator-hawq,代码行数:25,代码来源:service.c
示例10: PgArchiverMain
/*
* PgArchiverMain
*
* The argc/argv parameters are valid only in EXEC_BACKEND case. However,
* since we don't use 'em, it hardly matters...
*/
NON_EXEC_STATIC void
PgArchiverMain(int argc, char *argv[])
{
IsUnderPostmaster = true; /* we are a postmaster subprocess now */
MyProcPid = getpid(); /* reset MyProcPid */
/* Lose the postmaster's on-exit routines */
on_exit_reset();
/*
* Ignore all signals usually bound to some action in the postmaster,
* except for SIGHUP, SIGUSR1 and SIGQUIT.
*/
pqsignal(SIGHUP, ArchSigHupHandler);
pqsignal(SIGINT, SIG_IGN);
pqsignal(SIGTERM, SIG_IGN);
pqsignal(SIGQUIT, pgarch_exit);
pqsignal(SIGALRM, SIG_IGN);
pqsignal(SIGPIPE, SIG_IGN);
pqsignal(SIGUSR1, pgarch_waken);
pqsignal(SIGUSR2, SIG_IGN);
pqsignal(SIGCHLD, SIG_DFL);
pqsignal(SIGTTIN, SIG_DFL);
pqsignal(SIGTTOU, SIG_DFL);
pqsignal(SIGCONT, SIG_DFL);
pqsignal(SIGWINCH, SIG_DFL);
PG_SETMASK(&UnBlockSig);
/*
* Identify myself via ps
*/
init_ps_display("archiver process", "", "");
set_ps_display("");
pgarch_MainLoop();
exit(0);
}
开发者ID:alecclarke,项目名称:postgresql-8.1.4,代码行数:45,代码来源:pgarch.c
示例11: SysLoggerMain
//.........这里部分代码省略.........
#endif
InitializeLatchSupport(); /* needed for latch waits */
/* Initialize private latch for use by signal handlers */
InitLatch(&sysLoggerLatch);
/*
* Properly accept or ignore signals the postmaster might send us
*
* Note: we ignore all termination signals, and instead exit only when all
* upstream processes are gone, to ensure we don't miss any dying gasps of
* broken backends...
*/
pqsignal(SIGHUP, sigHupHandler); /* set flag to read config file */
pqsignal(SIGINT, SIG_IGN);
pqsignal(SIGTERM, SIG_IGN);
pqsignal(SIGQUIT, SIG_IGN);
pqsignal(SIGALRM, SIG_IGN);
pqsignal(SIGPIPE, SIG_IGN);
pqsignal(SIGUSR1, sigUsr1Handler); /* request log rotation */
pqsignal(SIGUSR2, SIG_IGN);
/*
* Reset some signals that are accepted by postmaster but not here
*/
pqsignal(SIGCHLD, SIG_DFL);
pqsignal(SIGTTIN, SIG_DFL);
pqsignal(SIGTTOU, SIG_DFL);
pqsignal(SIGCONT, SIG_DFL);
pqsignal(SIGWINCH, SIG_DFL);
PG_SETMASK(&UnBlockSig);
#ifdef WIN32
/* Fire up separate data transfer thread */
InitializeCriticalSection(&sysloggerSection);
EnterCriticalSection(&sysloggerSection);
threadHandle = (HANDLE) _beginthreadex(NULL, 0, pipeThread, NULL, 0, NULL);
if (threadHandle == 0)
elog(FATAL, "could not create syslogger data transfer thread: %m");
#endif /* WIN32 */
/*
* Remember active logfile's name. We recompute this from the reference
* time because passing down just the pg_time_t is a lot cheaper than
* passing a whole file path in the EXEC_BACKEND case.
*/
last_file_name = logfile_getname(first_syslogger_file_time, NULL);
/* remember active logfile parameters */
currentLogDir = pstrdup(Log_directory);
currentLogFilename = pstrdup(Log_filename);
currentLogRotationAge = Log_RotationAge;
/* set next planned rotation time */
set_next_rotation_time();
/* main worker loop */
for (;;)
{
bool time_based_rotation = false;
int size_rotation_for = 0;
long cur_timeout;
int cur_flags;
开发者ID:TesterRandolph,项目名称:postgres-x2,代码行数:67,代码来源:syslogger.c
示例12: BackgroundWriterMain
//.........这里部分代码省略.........
* Now return to normal top-level context and clear ErrorContext for
* next time.
*/
MemoryContextSwitchTo(bgwriter_context);
FlushErrorState();
/* Flush any leaked data in the top-level context */
MemoryContextResetAndDeleteChildren(bgwriter_context);
/* Now we can allow interrupts again */
RESUME_INTERRUPTS();
/*
* Sleep at least 1 second after any error. A write error is likely
* to be repeated, and we don't want to be filling the error logs as
* fast as we can.
*/
pg_usleep(1000000L);
/*
* Close all open files after any error. This is helpful on Windows,
* where holding deleted files open causes various strange errors.
* It's not clear we need it elsewhere, but shouldn't hurt.
*/
smgrcloseall();
}
/* We can now handle ereport(ERROR) */
PG_exception_stack = &local_sigjmp_buf;
/*
* Unblock signals (they were blocked when the postmaster forked us)
*/
PG_SETMASK(&UnBlockSig);
/*
* Loop forever
*/
for (;;)
{
bool do_checkpoint = false;
int flags = 0;
time_t now;
int elapsed_secs;
/*
* Emergency bailout if postmaster has died. This is to avoid the
* necessity for manual cleanup of all postmaster children.
*/
if (!PostmasterIsAlive(true))
exit(1);
/*
* Process any requests or signals received recently.
*/
AbsorbFsyncRequests();
if (got_SIGHUP)
{
got_SIGHUP = false;
ProcessConfigFile(PGC_SIGHUP);
}
if (checkpoint_requested)
{
checkpoint_requested = false;
do_checkpoint = true;
开发者ID:KMU-embedded,项目名称:mosbench-ext,代码行数:67,代码来源:bgwriter.c
示例13: WalWriterMain
//.........这里部分代码省略.........
* AbortTransaction(). We don't have very many resources to worry
* about in walwriter, but we do have LWLocks, and perhaps buffers?
*/
LWLockReleaseAll();
AbortBufferIO();
UnlockBuffers();
/* buffer pins are released here: */
ResourceOwnerRelease(CurrentResourceOwner,
RESOURCE_RELEASE_BEFORE_LOCKS,
false, true);
/* we needn't bother with the other ResourceOwnerRelease phases */
AtEOXact_Buffers(false);
AtEOXact_Files();
AtEOXact_HashTables(false);
/*
* Now return to normal top-level context and clear ErrorContext for
* next time.
*/
MemoryContextSwitchTo(walwriter_context);
FlushErrorState();
/* Flush any leaked data in the top-level context */
MemoryContextResetAndDeleteChildren(walwriter_context);
/* Now we can allow interrupts again */
RESUME_INTERRUPTS();
/*
* Sleep at least 1 second after any error. A write error is likely
* to be repeated, and we don't want to be filling the error logs as
* fast as we can.
*/
pg_usleep(1000000L);
/*
* Close all open files after any error. This is helpful on Windows,
* where holding deleted files open causes various strange errors.
* It's not clear we need it elsewhere, but shouldn't hurt.
*/
smgrcloseall();
}
/* We can now handle ereport(ERROR) */
PG_exception_stack = &local_sigjmp_buf;
/*
* Unblock signals (they were blocked when the postmaster forked us)
*/
PG_SETMASK(&UnBlockSig);
/*
* Loop forever
*/
for (;;)
{
long udelay;
/*
* Emergency bailout if postmaster has died. This is to avoid the
* necessity for manual cleanup of all postmaster children.
*/
if (!PostmasterIsAlive(true))
exit(1);
/*
* Process any requests or signals received recently.
*/
if (got_SIGHUP)
{
got_SIGHUP = false;
ProcessConfigFile(PGC_SIGHUP);
}
if (shutdown_requested)
{
/* Normal exit from the walwriter is here */
proc_exit(0); /* done */
}
/*
* Do what we're here for...
*/
XLogBackgroundFlush();
/*
* Delay until time to do something more, but fall out of delay
* reasonably quickly if signaled.
*/
udelay = WalWriterDelay * 1000L;
while (udelay > 999999L)
{
if (got_SIGHUP || shutdown_requested)
break;
pg_usleep(1000000L);
udelay -= 1000000L;
}
if (!(got_SIGHUP || shutdown_requested))
pg_usleep(udelay);
}
}
开发者ID:GisKook,项目名称:Gis,代码行数:101,代码来源:walwriter.c
示例14: SysLoggerMain
/*
* Main entry point for syslogger process
* argc/argv parameters are valid only in EXEC_BACKEND case.
*/
NON_EXEC_STATIC void
SysLoggerMain(int argc, char *argv[])
{
char *currentLogDir;
char *currentLogFilename;
int currentLogRotationAge;
IsUnderPostmaster = true; /* we are a postmaster subprocess now */
MyProcPid = getpid(); /* reset MyProcPid */
/* Lose the postmaster's on-exit routines */
on_exit_reset();
#ifdef EXEC_BACKEND
syslogger_parseArgs(argc, argv);
#endif /* EXEC_BACKEND */
am_syslogger = true;
init_ps_display("logger process", "", "");
set_ps_display("");
/*
* If we restarted, our stderr is already redirected into our own
* input pipe. This is of course pretty useless, not to mention that
* it interferes with detecting pipe EOF. Point stderr to /dev/null.
* This assumes that all interesting messages generated in the
* syslogger will come through elog.c and will be sent to
* write_syslogger_file.
*/
if (redirection_done)
{
int fd = open(NULL_DEV, O_WRONLY);
/*
* The closes might look redundant, but they are not: we want to
* be darn sure the pipe gets closed even if the open failed. We
* can survive running with stderr pointing nowhere, but we can't
* afford to have extra pipe input descriptors hanging around.
*/
close(fileno(stdout));
close(fileno(stderr));
dup2(fd, fileno(stdout));
dup2(fd, fileno(stderr));
close(fd);
}
/*
* Also close our copy of the write end of the pipe. This is needed
* to ensure we can detect pipe EOF correctly. (But note that in the
* restart case, the postmaster already did this.)
*/
#ifndef WIN32
if (syslogPipe[1] >= 0)
close(syslogPipe[1]);
syslogPipe[1] = -1;
#else
if (syslogPipe[1])
CloseHandle(syslogPipe[1]);
syslogPipe[1] = 0;
#endif
/*
* Properly accept or ignore signals the postmaster might send us
*
* Note: we ignore all termination signals, and instead exit only when
* all upstream processes are gone, to ensure we don't miss any dying
* gasps of broken backends...
*/
pqsignal(SIGHUP, sigHupHandler); /* set flag to read config file */
pqsignal(SIGINT, SIG_IGN);
pqsignal(SIGTERM, SIG_IGN);
pqsignal(SIGQUIT, SIG_IGN);
pqsignal(SIGALRM, SIG_IGN);
pqsignal(SIGPIPE, SIG_IGN);
pqsignal(SIGUSR1, SIG_IGN);
pqsignal(SIGUSR2, SIG_IGN);
/*
* Reset some signals that are accepted by postmaster but not here
*/
pqsignal(SIGCHLD, SIG_DFL);
pqsignal(SIGTTIN, SIG_DFL);
pqsignal(SIGTTOU, SIG_DFL);
pqsignal(SIGCONT, SIG_DFL);
pqsignal(SIGWINCH, SIG_DFL);
PG_SETMASK(&UnBlockSig);
#ifdef WIN32
/* Fire up separate data transfer thread */
InitializeCriticalSection(&sysfileSection);
{
//.........这里部分代码省略.........
开发者ID:berkeley-cs186,项目名称:course-fa07,代码行数:101,代码来源:syslogger.c
示例15: ServiceMain
//.........这里部分代码省略.........
on_exit_reset();
/* Identify myself via ps */
init_ps_display(serviceConfig->psTitle, "", "", "");
if (serviceConfig->ServiceEarlyInit != NULL)
{
serviceConfig->ServiceEarlyInit();
}
else
{
SetProcessingMode(InitProcessing);
}
/*
* Set up signal handlers. We operate on databases much like a regular
* backend, so we use the same signal handling. See equivalent code in
* tcop/postgres.c.
*
* Currently, we don't pay attention to postgresql.conf changes that
* happen during a single daemon iteration, so we can ignore SIGHUP.
*/
pqsignal(SIGHUP, SIG_IGN);
/*
* Presently, SIGINT will lead to autovacuum shutdown, because that's how
* we handle ereport(ERROR). It could be improved however.
*/
pqsignal(SIGINT, StatementCancelHandler);
pqsignal(SIGTERM, ServiceDie);
pqsignal(SIGQUIT, ServiceQuickDie);
pqsignal(SIGALRM, handle_sig_alarm);
pqsignal(SIGPIPE, SIG_IGN);
pqsignal(SIGUSR1, procsignal_sigusr1_handler);
/* We don't listen for async notifies */
pqsignal(SIGUSR2, serviceConfig->ServiceRequestShutdown);
pqsignal(SIGFPE, FloatExceptionHandler);
pqsignal(SIGCHLD, SIG_DFL);
#ifdef SIGBUS
pqsignal(SIGBUS, HandleCrash);
#endif
#ifdef SIGILL
pqsignal(SIGILL, HandleCrash);
#endif
#ifdef SIGSEGV
pqsignal(SIGSEGV, HandleCrash);
#endif
/* Early initialization */
BaseInit();
if (serviceConfig->ServicePostgresInit != NULL)
{
serviceConfig->ServicePostgresInit();
}
SetProcessingMode(NormalProcessing);
/*
* If an exception is encountered, processing resumes here.
*
* See notes in postgres.c about the design of this coding.
*/
if (sigsetjmp(local_sigjmp_buf, 1) != 0)
{
/* Prevents interrupts while cleaning up */
HOLD_INTERRUPTS();
/* Report the error to the server log */
EmitErrorReport();
/*
* We can now go away. Note that because we'll call InitProcess, a
* callback will be registered to do ProcKill, which will clean up
* necessary state.
*/
proc_exit(0);
}
/* We can now handle ereport(ERROR) */
PG_exception_stack = &local_sigjmp_buf;
PG_SETMASK(&UnBlockSig);
/* set up a listener port and put it in shmem*/
serviceCtrl->listenerPort = ServiceListenerSetup(serviceCtrl);
if (serviceConfig->ServiceInit != NULL)
{
serviceConfig->ServiceInit(serviceCtrl->listenerPort);
}
/* listen loop */
ServiceListenLoop(serviceCtrl);
proc_exit(0);
}
开发者ID:BALDELab,项目名称:incubator-hawq,代码行数:101,代码来源:service.c
示例16: CheckpointerMain
//.........这里部分代码省略.........
* Now return to normal top-level context and clear ErrorContext for
* next time.
*/
MemoryContextSwitchTo(checkpointer_context);
FlushErrorState();
/* Flush any leaked data in the top-level context */
MemoryContextResetAndDeleteChildren(checkpointer_context);
/* Now we can allow interrupts again */
RESUME_INTERRUPTS();
/*
* Sleep at least 1 second after any error. A write error is likely
* to be repeated, and we don't want to be filling the error logs as
* fast as we can.
*/
pg_usleep(1000000L);
/*
* Close all open files after any error. This is helpful on Windows,
* where holding deleted files open causes various strange errors.
* It's not clear we need it elsewhere, but shouldn't hurt.
*/
smgrcloseall();
}
/* We can now handle ereport(ERROR) */
PG_exception_stack = &local_sigjmp_buf;
/*
* Unblock signals (they were blocked when the postmaster forked us)
*/
PG_SETMASK(&UnBlockSig);
/*
* Ensure all shared memory values are set correctly for the config. Doing
* this here ensures no race conditions from other concurrent updaters.
*/
UpdateSharedMemoryConfig();
/*
* Advertise our latch that backends can use to wake us up while we're
* sleeping.
*/
ProcGlobal->checkpointerLatch = &MyProc->procLatch;
/*
* Loop forever
*/
for (;;)
{
bool do_checkpoint = false;
int flags = 0;
pg_time_t now;
int elapsed_secs;
int cur_timeout;
int rc;
/* Clear any already-pending wakeups */
ResetLatch(MyLatch);
/*
* Process any requests or signals received recently.
*/
AbsorbFsyncRequests();
开发者ID:Tao-Ma,项目名称:postgres,代码行数:67,代码来源:checkpointer.c
示例17: BackoffSweeperMain
/**
* This method is called after fork of the sweeper process. It sets up signal
* handlers and does initialization that is required by a postgres backend.
*/
NON_EXEC_STATIC void
BackoffSweeperMain(int argc, char *argv[])
{
sigjmp_buf local_sigjmp_buf;
IsUnderPostmaster = true;
isSweeperProcess = true;
/* Stay away from PMChildSlot */
MyPMChildSlot = -1;
/* reset MyProcPid */
MyProcPid = getpid();
/* Lose the postmaster's on-exit routines */
on_exit_reset();
/* Identify myself via ps */
init_ps_display("sweeper process", "", "", "");
SetProcessingMode(InitProcessing);
/*
* Set up signal handlers. We operate on databases much like a regular
* backend, so we use the same signal handling. See equivalent code in
* tcop/postgres.c.
*/
pqsignal(SIGHUP, SIG_IGN);
pqsignal(SIGINT, SIG_IGN);
pqsignal(SIGALRM, SIG_IGN);
pqsignal(SIGPIPE, SIG_IGN);
pqsignal(SIGUSR1, SIG_IGN);
pqsignal(SIGTERM, die);
pqsignal(SIGQUIT, quickdie);
pqsignal(SIGUSR2, BackoffRequestShutdown);
pqsignal(SIGFPE, FloatExceptionHandler);
pqsignal(SIGCHLD, SIG_DFL);
/*
* Copied from bgwriter
*/
CurrentResourceOwner = ResourceOwnerCreate(NULL, "Sweeper process");
/* Early initialization */
BaseInit();
/* See InitPostgres()... */
InitProcess();
SetProcessingMode(NormalProcessing);
/*
* If an exception is encountered, processing resumes here.
*
* See notes in postgres.c about the design of this coding.
*/
if (sigsetjmp(local_sigjmp_buf, 1) != 0)
{
/* Prevents interrupts while cleaning up */
HOLD_INTERRUPTS();
/* Report the error to the server log */
EmitErrorReport();
/*
* We can now go away. Note that because we'll call InitProcess, a
* callback will be registered to do ProcKill, which will clean up
* necessary state.
*/
proc_exit(0);
}
/* We can now handle ereport(ERROR) */
PG_exception_stack = &local_sigjmp_buf;
PG_SETMASK(&UnBlockSig);
MyBackendId = InvalidBackendId;
/* main loop */
BackoffSweeperLoop();
/* One iteration done, go away */
proc_exit(0);
}
开发者ID:adam8157,项目名称:gpdb,代码行数:91,代码来源:backoff.c
示例18: SysLoggerMain
//.........这里部分代码省略.........
* processes do this.)
*/
#ifdef HAVE_SETSID
if (setsid() < 0)
elog(FATAL, "setsid() failed: %m");
#endif
/*
* Properly accept or ignore signals the postmaster might send us
*
* Note: we ignore all termination signals, and instead exit only when all
* upstream processes are gone, to ensure we don't miss any dying gasps of
* broken backends...
*/
pqsignal(SIGHUP, sigHupHandler); /* set flag to read config file */
pqsignal(SIGINT, SIG_IGN);
pqsignal(SIGTERM, SIG_IGN);
pqsignal(SIGQUIT, SIG_IGN);
pqsignal(SIGALRM, SIG_IGN);
pqsignal(SIGPIPE, SIG_IGN);
pqsignal(SIGUSR1, sigUsr1Handler); /* request log rotation */
pqsignal(SIGUSR2, SIG_IGN);
/*
* Reset some signals that are accepted by postmaster but not here
*/
pqsignal(SIGCHLD, SIG_DFL);
pqsignal(SIGTTIN, SIG_DFL);
pqsignal(SIGTTOU, SIG_DFL);
pqsignal(SIGCONT, SIG_DFL);
pqsignal(SIGWINCH, SIG_DFL);
PG_SETMASK(&UnBlockSig);
#ifdef WIN32
/* Fire up separate data transfer thread */
InitializeCriticalSection(&sysloggerSection);
EnterCriticalSection(&sysloggerSection);
threadHandle = (HANDLE) _beginthreadex(NULL, 0, pipeThread, NULL, 0, NULL);
if (threadHandle == 0)
elog(FATAL, "could not create syslogger data transfer thread: %m");
#endif /* WIN32 */
/* remember active logfile parameters */
currentLogDir = pstrdup(Log_directory);
currentLogFilename = pstrdup(Log_filename);
currentLogRotationAge = Log_RotationAge;
/* set next planned rotation time */
set_next_rotation_time();
/* main worker loop */
for (;;)
{
bool time_based_rotation = false;
int size_rotation_for = 0;
#ifndef WIN32
int bytesRead;
int rc;
fd_set rfds;
struct timeval timeout;
#endif
if (got_SIGHUP)
开发者ID:markwkm,项目名称:postgres,代码行数:67,代码来源:syslogger.c
示例19: ContQuerySchedulerMain
//.........这里部分代码省略.........
/* Forget any pending QueryCancel or timeout request */
disable_all_timeouts(false);
QueryCancelPending = false; /* second to avoid race condition */
/* Report the error to the server log */
EmitErrorReport();
/* Abort the current transaction in order to recover */
AbortCurrentTransaction();
/*
* Now return to normal top-level context and clear ErrorContext for
* next time.
*/
MemoryContextSwitchTo(ContQuerySchedulerMemCxt);
FlushErrorState();
/* Flush any leaked data in the top-level context */
MemoryContextResetAndDeleteChildren(ContQuerySchedulerMemCxt);
/* Now we can allow interrupts again */
RESUME_INTERRUPTS();
/*
* Sleep at least 1 second after any error. We don't want to be
* filling the error logs as fast as we can.
*/
pg_usleep(1000000L);
}
/* We can now handle ereport(ERROR) */
PG_exception_stack = &local_sigjmp_buf;
/* must unblock signals before calling rebuild_database_list */
PG_SETMASK(&UnBlockSig);
ContQuerySchedulerShmem->scheduler_pid = MyProcPid;
dbs = get_database_list();
/* Loop forever */
for (;;)
{
ListCell *lc;
int rc;
foreach(lc, dbs)
{
DatabaseEntry *db_entry = lfirst(lc);
bool found;
ContQueryProcGroup *grp = hash_search(ContQuerySchedulerShmem->proc_table, &db_entry->oid, HASH_ENTER, &found);
/* If we don't have an entry for this dboid, initialize a new one and fire off bg procs */
if (!found)
{
grp->db_oid = db_entry->oid;
namestrcpy(&grp->db_name, NameStr(db_entry->name));
start_group(grp);
}
}
/* Allow sinval catchup interrupts while sleeping */
EnableCatchupInterrupt();
/*
* Wait until naptime expires or we get some type of signal (all the
开发者ID:jberkus,项目名称:pipelinedb,代码行数:67,代码来源:cont_scheduler.c
示例20: FileRepResetPeer_Main
void FileRepResetPeer_Main(void)
{
/* BASIC PROCESS SETUP */
FileRepReset_ConfigureSignals();
/*
* If an exception is encountered, processing resumes here.
*
* See notes in postgres.c about the design of this coding and comments about how the error
* handling works.
*/
sigjmp_buf local_sigjmp_buf;
if (sigsetjmp(local_sigjmp_buf, 1) != 0)
{
HOLD_INTERRUPTS();
EmitErrorReport();
proc_exit(EXIT_CODE_SHOULD_ENTER_FAULT);
}
/* We can now handle ereport(ERROR) */
PG_exception_stack = &local_sigjmp_buf;
PG_SETMASK(&UnBlockSig);
/** NOW DO THE ACTUAL WORK */
char messageFromPeer[MESSAGE_FROM_PEER_BUF_SIZE];
char resetNumberFromPeer[MESSAGE_FROM_PEER_BUF_SIZE];
char resetNumberThatIndicatesResetComplete[MESSAGE_FROM_PEER_BUF_SIZE];
struct addrinfo *addrList = NULL;
char portStr[100];
PrimaryMirrorModeTransitionArguments args = primaryMirrorGetArgumentsFromLocalMemory();
Assert(args.mode == PMModePrimarySegment || args.mode == PMModeMirrorSegment);
snprintf(portStr, sizeof(portStr), "%d", args.peerPostmasterPort);
if (! determineTargetHost(&addrList, args.peerAddress, portStr))
{
elog(WARNING, "during reset, unable to look up address for peer host to coordinate reset; "
"will transition to fault state.");
proc_exit(EXIT_CODE_SHOULD_ENTER_FAULT);
}
sendMessageToPeerAndExitIfProblem(addrList, "beginPostmasterReset", messageFromPeer,
resetNumberThatIndicatesResetComplete);
for ( ;; )
{
pg_usleep(10 * 1000L); /* 10 ms */
sendMessageToPeerAndExitIfProblem(addrList, "getPostmasterResetStatus", messageFromPeer, resetNumberFromPeer );
if (strequals(messageFromPeer, RESET_STATUS_IS_IN_RESET_PIVOT_POINT))
{
if (args.mode == PMModeMirrorSegment)
{
/**
* peer is in the reset pivot point, we can break out of our checking loop and
* thus exit with a code telling the postmaster to begin the startup sequence again
*
* this is only done on the mirror as currently the mirror must execute the startup sequence
* before the primary
*/
elog(DEBUG1, "peer reset: primary peer has reached reset point");
break;
}
}
else if (strequals(messageFromPeer, RESET_STATUS_IS_RUNNING))
{
/** it's running -- is it >= than the reset number that indicates reset complete one */
if (strcmp( resetNumberFromPeer, resetNumberThatIndicatesResetComplete) >= 0)
{
/** yes, the reset is complete and so we can quit and do a restart */
elog(DEBUG1, "peer reset: mirror peer reset is complete");
break;
}
}
}
proc_exit(EXIT_CODE_SHOULD_RESTART_SHMEM_CLEANLY);
}
开发者ID:phan-pivotal,项目名称:gpdb,代码行数:78,代码来源:cdbfilerepresetpeerprocess.c
注:本文中的PG_SETMASK函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论