PostgreSQL Source Code
git master
|
#include <signal.h>
Go to the source code of this file.
Data Structures | |
struct | Latch |
struct | WaitEvent |
Macros | |
#define | WL_LATCH_SET (1 << 0) |
#define | WL_SOCKET_READABLE (1 << 1) |
#define | WL_SOCKET_WRITEABLE (1 << 2) |
#define | WL_TIMEOUT (1 << 3) /* not for WaitEventSetWait() */ |
#define | WL_POSTMASTER_DEATH (1 << 4) |
#define | WL_EXIT_ON_PM_DEATH (1 << 5) |
#define | WL_SOCKET_CONNECTED WL_SOCKET_WRITEABLE |
#define | WL_SOCKET_MASK |
Typedefs | |
typedef struct Latch | Latch |
typedef struct WaitEvent | WaitEvent |
typedef struct WaitEventSet | WaitEventSet |
Functions | |
void | InitializeLatchSupport (void) |
void | InitLatch (Latch *latch) |
void | InitSharedLatch (Latch *latch) |
void | OwnLatch (Latch *latch) |
void | DisownLatch (Latch *latch) |
void | SetLatch (Latch *latch) |
void | ResetLatch (Latch *latch) |
WaitEventSet * | CreateWaitEventSet (MemoryContext context, int nevents) |
void | FreeWaitEventSet (WaitEventSet *set) |
int | AddWaitEventToSet (WaitEventSet *set, uint32 events, pgsocket fd, Latch *latch, void *user_data) |
void | ModifyWaitEvent (WaitEventSet *set, int pos, uint32 events, Latch *latch) |
int | WaitEventSetWait (WaitEventSet *set, long timeout, WaitEvent *occurred_events, int nevents, uint32 wait_event_info) |
int | WaitLatch (Latch *latch, int wakeEvents, long timeout, uint32 wait_event_info) |
int | WaitLatchOrSocket (Latch *latch, int wakeEvents, pgsocket sock, long timeout, uint32 wait_event_info) |
void | InitializeLatchWaitSet (void) |
void | latch_sigusr1_handler (void) |
#define WL_EXIT_ON_PM_DEATH (1 << 5) |
Definition at line 129 of file latch.h.
Referenced by AddWaitEventToSet(), ApplyLauncherMain(), autoprewarm_main(), AutoVacLauncherMain(), BackgroundWriterMain(), be_tls_open_server(), CheckpointerMain(), ConditionVariableTimedSleep(), copy_read_data(), gather_readnext(), initialize_worker_spi(), InitializeLatchWaitSet(), libpqrcv_connect(), libpqrcv_PQgetResult(), logicalrep_worker_stop(), LogicalRepApplyLoop(), mq_putmessage(), pg_sleep(), pgfdw_get_cleanup_result(), pgfdw_get_result(), ProcSleep(), ProcWaitForSignal(), read_or_wait(), recoveryApplyDelay(), secure_open_gssapi(), shm_mq_receive_bytes(), shm_mq_send_bytes(), shm_mq_wait_internal(), test_shm_mq_pipelined(), throttle(), wait_for_relation_state_change(), wait_for_worker_state_change(), wait_for_workers_to_become_ready(), WaitForParallelWorkersToAttach(), WaitForParallelWorkersToFinish(), WaitForProcSignalBarrier(), WaitForReplicationWorkerAttach(), WaitForWALToBecomeAvailable(), WaitLatch(), WaitLatchOrSocket(), WalRcvWaitForStartPosition(), WalReceiverMain(), WalSndLoop(), WalSndWaitForWal(), WalSndWriteData(), and WalWriterMain().
#define WL_LATCH_SET (1 << 0) |
Definition at line 124 of file latch.h.
Referenced by AddWaitEventToSet(), ApplyLauncherMain(), autoprewarm_main(), AutoVacLauncherMain(), BackgroundWriterMain(), CheckpointerMain(), ConditionVariableTimedSleep(), copy_read_data(), FreeWaitEventSet(), gather_readnext(), initialize_worker_spi(), InitializeLatchWaitSet(), libpqrcv_connect(), libpqrcv_PQgetResult(), logicalrep_worker_stop(), LogicalRepApplyLoop(), ModifyWaitEvent(), mq_putmessage(), pg_promote(), pg_sleep(), pgarch_MainLoop(), pgfdw_get_cleanup_result(), pgfdw_get_result(), PgstatCollectorMain(), pq_init(), ProcSleep(), ProcWaitForSignal(), recoveryApplyDelay(), secure_read(), secure_write(), shm_mq_receive_bytes(), shm_mq_send_bytes(), shm_mq_wait_internal(), SwitchBackToLocalLatch(), SwitchToSharedLatch(), SyncRepWaitForLSN(), SysLoggerMain(), test_shm_mq_pipelined(), throttle(), wait_for_relation_state_change(), wait_for_worker_state_change(), wait_for_workers_to_become_ready(), WaitEventSetWait(), WaitForBackgroundWorkerShutdown(), WaitForBackgroundWorkerStartup(), WaitForParallelWorkersToAttach(), WaitForParallelWorkersToFinish(), WaitForProcSignalBarrier(), WaitForReplicationWorkerAttach(), WaitForWALToBecomeAvailable(), WaitLatch(), WaitLatchOrSocket(), WalRcvWaitForStartPosition(), WalReceiverMain(), WalSndLoop(), WalSndWaitForWal(), WalSndWriteData(), and WalWriterMain().
#define WL_POSTMASTER_DEATH (1 << 4) |
Definition at line 128 of file latch.h.
Referenced by AddWaitEventToSet(), FreeWaitEventSet(), ModifyWaitEvent(), pg_promote(), pgarch_MainLoop(), PgstatCollectorMain(), pq_init(), secure_read(), secure_write(), SyncRepWaitForLSN(), WaitEventSetWait(), WaitForBackgroundWorkerShutdown(), WaitForBackgroundWorkerStartup(), WaitLatch(), and WaitLatchOrSocket().
#define WL_SOCKET_CONNECTED WL_SOCKET_WRITEABLE |
Definition at line 134 of file latch.h.
Referenced by libpqrcv_connect(), ModifyWaitEvent(), and WaitEventSetWait().
#define WL_SOCKET_MASK |
Definition at line 137 of file latch.h.
Referenced by AddWaitEventToSet(), WaitEventSetWait(), and WaitLatchOrSocket().
#define WL_SOCKET_READABLE (1 << 1) |
Definition at line 125 of file latch.h.
Referenced by be_tls_open_server(), be_tls_read(), be_tls_write(), copy_read_data(), libpqrcv_connect(), libpqrcv_PQgetResult(), LogicalRepApplyLoop(), ModifyWaitEvent(), pgfdw_get_cleanup_result(), pgfdw_get_result(), PgstatCollectorMain(), read_or_wait(), secure_read(), SysLoggerMain(), WaitEventSetWait(), WalReceiverMain(), WalSndLoop(), WalSndWaitForWal(), and WalSndWriteData().
#define WL_SOCKET_WRITEABLE (1 << 2) |
Definition at line 126 of file latch.h.
Referenced by be_tls_open_server(), be_tls_read(), be_tls_write(), libpqrcv_connect(), ModifyWaitEvent(), pq_init(), secure_open_gssapi(), secure_write(), WaitEventSetWait(), WalSndLoop(), WalSndWaitForWal(), and WalSndWriteData().
#define WL_TIMEOUT (1 << 3) /* not for WaitEventSetWait() */ |
Definition at line 127 of file latch.h.
Referenced by ApplyLauncherMain(), autoprewarm_main(), AutoVacLauncherMain(), BackgroundWriterMain(), CheckpointerMain(), ConditionVariableTimedSleep(), copy_read_data(), initialize_worker_spi(), logicalrep_worker_stop(), LogicalRepApplyLoop(), pg_promote(), pg_sleep(), pgarch_MainLoop(), pgfdw_get_cleanup_result(), recoveryApplyDelay(), throttle(), wait_for_relation_state_change(), wait_for_worker_state_change(), WaitForProcSignalBarrier(), WaitForReplicationWorkerAttach(), WaitForWALToBecomeAvailable(), WaitLatch(), WaitLatchOrSocket(), WalReceiverMain(), WalSndLoop(), WalSndWaitForWal(), WalSndWriteData(), and WalWriterMain().
typedef struct WaitEventSet WaitEventSet |
int AddWaitEventToSet | ( | WaitEventSet * | set, |
uint32 | events, | ||
pgsocket | fd, | ||
Latch * | latch, | ||
void * | user_data | ||
) |
Definition at line 808 of file latch.c.
References Assert, elog, ERROR, WaitEventSet::events, fd(), WaitEventSet::latch, MyProcPid, Latch::owner_pid, PGINVALID_SOCKET, postmaster_alive_fds, POSTMASTER_FD_WATCH, selfpipe_readfd, WaitEvent::user_data, WL_EXIT_ON_PM_DEATH, WL_LATCH_SET, WL_POSTMASTER_DEATH, and WL_SOCKET_MASK.
Referenced by InitializeLatchWaitSet(), PgstatCollectorMain(), pq_init(), SysLoggerMain(), and WaitLatchOrSocket().
WaitEventSet* CreateWaitEventSet | ( | MemoryContext | context, |
int | nevents | ||
) |
Definition at line 611 of file latch.c.
References AcquireExternalFD(), close, elog, ERROR, MAXALIGN, MemoryContextAllocZero(), WaitEventSet::nevents, pgwin32_signal_event, ReleaseExternalFD(), and StaticAssertStmt.
Referenced by InitializeLatchWaitSet(), PgstatCollectorMain(), pq_init(), SysLoggerMain(), and WaitLatchOrSocket().
void DisownLatch | ( | Latch * | latch | ) |
Definition at line 362 of file latch.c.
References Assert, Latch::is_shared, MyProcPid, and Latch::owner_pid.
Referenced by AuxiliaryProcKill(), ProcKill(), and StartupXLOG().
void FreeWaitEventSet | ( | WaitEventSet * | set | ) |
Definition at line 744 of file latch.c.
References close, WaitEvent::events, WaitEvent::fd, pfree(), WaitEvent::pos, ReleaseExternalFD(), WL_LATCH_SET, and WL_POSTMASTER_DEATH.
Referenced by PgstatCollectorMain(), and WaitLatchOrSocket().
void InitializeLatchSupport | ( | void | ) |
Definition at line 175 of file latch.c.
References Assert, close, elog, FATAL, IsUnderPostmaster, MyProcPid, ReleaseExternalFD(), ReserveExternalFD(), selfpipe_owner_pid, selfpipe_readfd, and selfpipe_writefd.
Referenced by InitPostmasterChild(), and InitStandaloneProcess().
void InitializeLatchWaitSet | ( | void | ) |
Definition at line 253 of file latch.c.
References AddWaitEventToSet(), Assert, CreateWaitEventSet(), IsUnderPostmaster, WaitEventSet::latch_pos, LatchWaitSetLatchPos, MyLatch, PG_USED_FOR_ASSERTS_ONLY, PGINVALID_SOCKET, TopMemoryContext, WL_EXIT_ON_PM_DEATH, and WL_LATCH_SET.
Referenced by InitPostmasterChild(), and InitStandaloneProcess().
void InitLatch | ( | Latch * | latch | ) |
Definition at line 274 of file latch.c.
References Assert, elog, ERROR, Latch::is_set, Latch::is_shared, MyProcPid, Latch::owner_pid, selfpipe_owner_pid, and selfpipe_readfd.
Referenced by InitPostmasterChild(), and InitStandaloneProcess().
void InitSharedLatch | ( | Latch * | latch | ) |
Definition at line 306 of file latch.c.
References elog, ERROR, Latch::is_set, Latch::is_shared, and Latch::owner_pid.
Referenced by InitProcGlobal(), and XLOGShmemInit().
void latch_sigusr1_handler | ( | void | ) |
Definition at line 1944 of file latch.c.
References sendSelfPipeByte(), and waiting.
Referenced by bgworker_sigusr1_handler(), and procsignal_sigusr1_handler().
void ModifyWaitEvent | ( | WaitEventSet * | set, |
int | pos, | ||
uint32 | events, | ||
Latch * | latch | ||
) |
Definition at line 887 of file latch.c.
References generate_unaccent_rules::action, Assert, elog, ereport, errcode_for_socket_access(), errmsg(), ERROR, WaitEventSet::events, WaitEvent::events, WaitEvent::fd, WaitEventSet::latch, MyProcPid, WaitEventSet::nevents, Latch::owner_pid, PGINVALID_SOCKET, PostmasterIsAlive, PostmasterPid, WL_LATCH_SET, WL_POSTMASTER_DEATH, WL_SOCKET_CONNECTED, WL_SOCKET_READABLE, and WL_SOCKET_WRITEABLE.
Referenced by secure_read(), secure_write(), SwitchBackToLocalLatch(), SwitchToSharedLatch(), and WaitLatch().
void OwnLatch | ( | Latch * | latch | ) |
Definition at line 342 of file latch.c.
References Assert, elog, ERROR, Latch::is_shared, MyProcPid, Latch::owner_pid, selfpipe_owner_pid, and selfpipe_readfd.
Referenced by InitAuxiliaryProcess(), InitProcess(), and StartupXLOG().
void ResetLatch | ( | Latch * | latch | ) |
Definition at line 588 of file latch.c.
References Assert, Latch::is_set, MyProcPid, Latch::owner_pid, and pg_memory_barrier.
Referenced by ApplyLauncherMain(), autoprewarm_main(), AutoVacLauncherMain(), BackgroundWriterMain(), CheckpointerMain(), ConditionVariableTimedSleep(), copy_read_data(), gather_readnext(), initialize_worker_spi(), libpqrcv_connect(), libpqrcv_PQgetResult(), logicalrep_worker_stop(), LogicalRepApplyLoop(), mq_putmessage(), pg_promote(), pg_sleep(), pgarch_MainLoop(), pgfdw_get_cleanup_result(), pgfdw_get_result(), PgstatCollectorMain(), ProcSleep(), ProcWaitForSignal(), recoveryApplyDelay(), secure_read(), secure_write(), shm_mq_receive_bytes(), shm_mq_send_bytes(), shm_mq_wait_internal(), SyncRepWaitForLSN(), SysLoggerMain(), test_shm_mq_pipelined(), throttle(), wait_for_relation_state_change(), wait_for_worker_state_change(), wait_for_workers_to_become_ready(), WaitForBackgroundWorkerShutdown(), WaitForBackgroundWorkerStartup(), WaitForParallelWorkersToAttach(), WaitForParallelWorkersToFinish(), WaitForProcSignalBarrier(), WaitForReplicationWorkerAttach(), WaitForWALToBecomeAvailable(), WalRcvWaitForStartPosition(), WalReceiverMain(), WalSndLoop(), WalSndWaitForWal(), WalSndWriteData(), and WalWriterMain().
void SetLatch | ( | Latch * | latch | ) |
Definition at line 505 of file latch.c.
References Latch::is_set, kill, MyProcPid, Latch::owner_pid, pg_memory_barrier, sendSelfPipeByte(), SIGUSR1, and waiting.
Referenced by avl_sigusr2_handler(), CheckDeadLockAlert(), ConditionVariableBroadcast(), ConditionVariableSignal(), die(), ForwardSyncRequest(), handle_sig_alarm(), HandleCatchupInterrupt(), HandleNotifyInterrupt(), HandleParallelMessageInterrupt(), IdleInTransactionSessionTimeoutHandler(), IdleSessionTimeoutHandler(), logicalrep_worker_wakeup_ptr(), pgarch_waken(), pgarch_waken_stop(), ProcessClientReadInterrupt(), ProcessClientWriteInterrupt(), ProcSendSignal(), procsignal_sigusr1_handler(), ProcWakeup(), RecoveryConflictInterrupt(), ReqCheckpointHandler(), RequestXLogStreaming(), shm_mq_detach_internal(), shm_mq_inc_bytes_read(), shm_mq_send_bytes(), shm_mq_sendv(), shm_mq_set_receiver(), shm_mq_set_sender(), SignalHandlerForConfigReload(), SignalHandlerForShutdownRequest(), sigUsr1Handler(), StatementCancelHandler(), StrategyGetBuffer(), SwitchBackToLocalLatch(), SwitchToSharedLatch(), SyncRepWakeQueue(), test_shm_mq_main(), WakeupRecovery(), WalRcvForceReply(), WalSndLastCycleHandler(), WalSndWaitForWal(), WalSndWakeup(), WalSndWriteData(), write_syslogger_file(), and XLogSetAsyncXactLSN().
int WaitEventSetWait | ( | WaitEventSet * | set, |
long | timeout, | ||
WaitEvent * | occurred_events, | ||
int | nevents, | ||
uint32 | wait_event_info | ||
) |
Definition at line 1231 of file latch.c.
References Assert, buf, drainSelfPipe(), EINTR, elog, ereport, errcode_for_socket_access(), errmsg(), ERROR, WaitEvent::events, WaitEvent::fd, INSTR_TIME_GET_MILLISEC, INSTR_TIME_SET_CURRENT, INSTR_TIME_SUBTRACT, WaitEventSet::nevents, PGINVALID_SOCKET, pgstat_report_wait_end(), pgstat_report_wait_start(), pgwin32_dispatch_queued_signals(), WaitEvent::pos, PostmasterIsAliveInternal(), proc_exit(), start_time, unlikely, WaitEvent::user_data, WaitEventSetWaitBlock(), waiting, WL_LATCH_SET, WL_POSTMASTER_DEATH, WL_SOCKET_CONNECTED, WL_SOCKET_MASK, WL_SOCKET_READABLE, and WL_SOCKET_WRITEABLE.
Referenced by PgstatCollectorMain(), secure_read(), secure_write(), SysLoggerMain(), WaitLatch(), and WaitLatchOrSocket().
Definition at line 390 of file latch.c.
References Assert, WaitEventSet::exit_on_postmaster_death, IsUnderPostmaster, LatchWaitSetLatchPos, ModifyWaitEvent(), WaitEventSetWait(), WL_EXIT_ON_PM_DEATH, WL_LATCH_SET, WL_POSTMASTER_DEATH, and WL_TIMEOUT.
Referenced by ApplyLauncherMain(), autoprewarm_main(), AutoVacLauncherMain(), BackgroundWriterMain(), CheckpointerMain(), ConditionVariableTimedSleep(), gather_readnext(), initialize_worker_spi(), logicalrep_worker_stop(), mq_putmessage(), pg_promote(), pg_sleep(), pgarch_MainLoop(), ProcSleep(), ProcWaitForSignal(), recoveryApplyDelay(), shm_mq_receive_bytes(), shm_mq_send_bytes(), shm_mq_wait_internal(), SyncRepWaitForLSN(), test_shm_mq_pipelined(), throttle(), wait_for_relation_state_change(), wait_for_worker_state_change(), wait_for_workers_to_become_ready(), WaitForBackgroundWorkerShutdown(), WaitForBackgroundWorkerStartup(), WaitForParallelWorkersToAttach(), WaitForParallelWorkersToFinish(), WaitForProcSignalBarrier(), WaitForReplicationWorkerAttach(), WaitForWALToBecomeAvailable(), WalRcvWaitForStartPosition(), and WalWriterMain().
int WaitLatchOrSocket | ( | Latch * | latch, |
int | wakeEvents, | ||
pgsocket | sock, | ||
long | timeout, | ||
uint32 | wait_event_info | ||
) |
Definition at line 438 of file latch.c.
References AddWaitEventToSet(), Assert, CreateWaitEventSet(), CurrentMemoryContext, FreeWaitEventSet(), IsUnderPostmaster, PGINVALID_SOCKET, WaitEventSetWait(), WL_EXIT_ON_PM_DEATH, WL_LATCH_SET, WL_POSTMASTER_DEATH, WL_SOCKET_MASK, and WL_TIMEOUT.
Referenced by be_tls_open_server(), copy_read_data(), libpqrcv_connect(), libpqrcv_PQgetResult(), LogicalRepApplyLoop(), pgfdw_get_cleanup_result(), pgfdw_get_result(), read_or_wait(), secure_open_gssapi(), WalReceiverMain(), WalSndLoop(), WalSndWaitForWal(), and WalSndWriteData().