PostgreSQL Source Code
git master
|
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_CLOSED (1 << 7) |
#define | WL_SOCKET_ACCEPT WL_SOCKET_READABLE |
#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) |
void | ShutdownLatchSupport (void) |
WaitEventSet * | CreateWaitEventSet (ResourceOwner resowner, int nevents) |
void | FreeWaitEventSet (WaitEventSet *set) |
void | FreeWaitEventSetAfterFork (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) |
int | GetNumRegisteredWaitEvents (WaitEventSet *set) |
bool | WaitEventSetCanReportClosed (void) |
#define WL_SOCKET_ACCEPT WL_SOCKET_READABLE |
#define WL_SOCKET_CONNECTED WL_SOCKET_WRITEABLE |
#define WL_SOCKET_MASK |
#define WL_TIMEOUT (1 << 3) /* not for WaitEventSetWait() */ |
typedef struct WaitEventSet WaitEventSet |
int AddWaitEventToSet | ( | WaitEventSet * | set, |
uint32 | events, | ||
pgsocket | fd, | ||
Latch * | latch, | ||
void * | user_data | ||
) |
Definition at line 963 of file latch.c.
References Assert, elog, ERROR, WaitEventSet::events, WaitEventSet::exit_on_postmaster_death, fd(), WaitEventSet::latch, WaitEventSet::latch_pos, MyProcPid, WaitEventSet::nevents, WaitEventSet::nevents_space, Latch::owner_pid, PGINVALID_SOCKET, WaitEvent::pos, postmaster_alive_fds, POSTMASTER_FD_WATCH, selfpipe_readfd, WaitEventAdjustPoll(), WL_EXIT_ON_PM_DEATH, WL_LATCH_SET, WL_POSTMASTER_DEATH, and WL_SOCKET_MASK.
Referenced by ConfigurePostmasterWaitSet(), ExecAppendAsyncEventWait(), InitializeLatchWaitSet(), postgresForeignAsyncConfigureWait(), pq_init(), SysLoggerMain(), and WaitLatchOrSocket().
WaitEventSet* CreateWaitEventSet | ( | ResourceOwner | resowner, |
int | nevents | ||
) |
Definition at line 751 of file latch.c.
References AcquireExternalFD(), close, data, elog, ERROR, WaitEventSet::events, WaitEventSet::exit_on_postmaster_death, WaitEventSet::latch, MAXALIGN, MemoryContextAllocZero(), WaitEventSet::nevents_space, WaitEventSet::owner, pgwin32_signal_event, WaitEventSet::pollfds, ReleaseExternalFD(), ResourceOwnerEnlarge(), ResourceOwnerRememberWaitEventSet(), StaticAssertStmt, and TopMemoryContext.
Referenced by ConfigurePostmasterWaitSet(), ExecAppendAsyncEventWait(), InitializeLatchWaitSet(), pq_init(), SysLoggerMain(), and WaitLatchOrSocket().
void DisownLatch | ( | Latch * | latch | ) |
Definition at line 489 of file latch.c.
References Assert, Latch::is_shared, MyProcPid, and Latch::owner_pid.
Referenced by AuxiliaryProcKill(), ProcKill(), and ShutdownWalRecovery().
void FreeWaitEventSet | ( | WaitEventSet * | set | ) |
Definition at line 874 of file latch.c.
References close, WaitEventSet::events, WaitEventSet::nevents, WaitEventSet::owner, pfree(), ReleaseExternalFD(), ResourceOwnerForgetWaitEventSet(), WL_LATCH_SET, and WL_POSTMASTER_DEATH.
Referenced by ConfigurePostmasterWaitSet(), ExecAppendAsyncEventWait(), ResOwnerReleaseWaitEventSet(), ShutdownLatchSupport(), and WaitLatchOrSocket().
void FreeWaitEventSetAfterFork | ( | WaitEventSet * | set | ) |
Definition at line 917 of file latch.c.
References close, pfree(), and ReleaseExternalFD().
Referenced by ClosePostmasterPorts().
int GetNumRegisteredWaitEvents | ( | WaitEventSet * | set | ) |
Definition at line 2262 of file latch.c.
References WaitEventSet::nevents.
Referenced by ExecAppendAsyncEventWait(), and postgresForeignAsyncConfigureWait().
void InitializeLatchSupport | ( | void | ) |
Definition at line 232 of file latch.c.
References Assert, close, elog, FATAL, IsUnderPostmaster, latch_sigurg_handler(), MyProcPid, pqsignal(), ReleaseExternalFD(), ReserveExternalFD(), selfpipe_owner_pid, selfpipe_readfd, selfpipe_writefd, SIG_IGN, and UnBlockSig.
Referenced by InitPostmasterChild(), InitStandaloneProcess(), and PostmasterMain().
void InitializeLatchWaitSet | ( | void | ) |
Definition at line 346 of file latch.c.
References AddWaitEventToSet(), Assert, CreateWaitEventSet(), IsUnderPostmaster, LatchWaitSet, LatchWaitSetLatchPos, MyLatch, PG_USED_FOR_ASSERTS_ONLY, PGINVALID_SOCKET, WL_EXIT_ON_PM_DEATH, and WL_LATCH_SET.
Referenced by InitPostmasterChild(), and InitStandaloneProcess().
void InitLatch | ( | Latch * | latch | ) |
Definition at line 394 of file latch.c.
References Assert, elog, ERROR, Latch::is_set, Latch::is_shared, Latch::maybe_sleeping, MyProcPid, Latch::owner_pid, selfpipe_owner_pid, and selfpipe_readfd.
Referenced by InitProcessLocalLatch().
void InitSharedLatch | ( | Latch * | latch | ) |
Definition at line 430 of file latch.c.
References elog, ERROR, Latch::is_set, Latch::is_shared, Latch::maybe_sleeping, and Latch::owner_pid.
Referenced by InitProcGlobal(), and XLogRecoveryShmemInit().
void ModifyWaitEvent | ( | WaitEventSet * | set, |
int | pos, | ||
uint32 | events, | ||
Latch * | latch | ||
) |
Definition at line 1049 of file latch.c.
References Assert, elog, ERROR, WaitEventSet::events, WaitEvent::events, WaitEventSet::latch, MyProcPid, Latch::owner_pid, WaitEventAdjustPoll(), WL_LATCH_SET, and WL_POSTMASTER_DEATH.
Referenced by pq_check_connection(), secure_read(), secure_write(), SwitchBackToLocalLatch(), SwitchToSharedLatch(), WaitLatch(), and WalSndWait().
void OwnLatch | ( | Latch * | latch | ) |
Definition at line 463 of file latch.c.
References Assert, elog, Latch::is_shared, MyProcPid, Latch::owner_pid, PANIC, selfpipe_owner_pid, and selfpipe_readfd.
Referenced by InitAuxiliaryProcess(), InitProcess(), and InitWalRecovery().
void ResetLatch | ( | Latch * | latch | ) |
Definition at line 724 of file latch.c.
References Assert, Latch::is_set, Latch::maybe_sleeping, MyProcPid, Latch::owner_pid, and pg_memory_barrier.
Referenced by ApplyLauncherMain(), autoprewarm_main(), BackgroundWriterMain(), CheckpointerMain(), CheckpointWriteDelay(), ConditionVariableTimedSleep(), copy_read_data(), do_pg_backup_stop(), gather_readnext(), lazy_truncate_heap(), libpqrcv_connect(), libpqrcv_PQgetResult(), libpqsrv_cancel(), libpqsrv_connect_internal(), libpqsrv_get_result(), LogicalParallelApplyLoop(), logicalrep_worker_stop_internal(), LogicalRepApplyLoop(), mq_putmessage(), pa_send_data(), pa_wait_for_xact_state(), pg_promote(), pg_sleep(), pg_wait_until_termination(), pgarch_MainLoop(), pgfdw_get_cleanup_result(), pq_check_connection(), ProcessPendingWrites(), ProcSleep(), ProcWaitForSignal(), recoveryApplyDelay(), secure_read(), secure_write(), ServerLoop(), shm_mq_receive_bytes(), shm_mq_send_bytes(), shm_mq_wait_internal(), ShutDownSlotSync(), summarizer_wait_for_wal(), SyncRepWaitForLSN(), SysLoggerMain(), test_shm_mq_pipelined(), throttle(), wait_for_relation_state_change(), wait_for_slot_activity(), wait_for_worker_state_change(), wait_for_workers_to_become_ready(), WaitForBackgroundWorkerShutdown(), WaitForBackgroundWorkerStartup(), WaitForParallelWorkersToAttach(), WaitForParallelWorkersToFinish(), WaitForReplicationWorkerAttach(), WaitForWALToBecomeAvailable(), WalRcvWaitForStartPosition(), WalReceiverMain(), WalSndLoop(), WalSndWaitForWal(), WalWriterMain(), and worker_spi_main().
void SetLatch | ( | Latch * | latch | ) |
Definition at line 632 of file latch.c.
References Latch::is_set, kill, Latch::maybe_sleeping, MyProcPid, Latch::owner_pid, pg_memory_barrier, sendSelfPipeByte(), and waiting.
Referenced by avl_sigusr2_handler(), CheckDeadLockAlert(), ClientCheckTimeoutHandler(), ConditionVariableBroadcast(), ConditionVariableSignal(), die(), ForwardSyncRequest(), handle_pm_child_exit_signal(), handle_pm_pmsignal_signal(), handle_pm_reload_request_signal(), handle_pm_shutdown_request_signal(), handle_sig_alarm(), HandleCatchupInterrupt(), HandleNotifyInterrupt(), HandleParallelApplyMessageInterrupt(), HandleParallelMessageInterrupt(), IdleInTransactionSessionTimeoutHandler(), IdleSessionTimeoutHandler(), IdleStatsUpdateTimeoutHandler(), logicalrep_worker_wakeup_ptr(), pgarch_waken_stop(), PgArchWakeup(), ProcessClientReadInterrupt(), ProcessClientWriteInterrupt(), ProcessPendingWrites(), ProcSendSignal(), procsignal_sigusr1_handler(), ProcWakeup(), 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(), TransactionTimeoutHandler(), WakeupRecovery(), WakeupWalSummarizer(), WalRcvForceReply(), WalSndLastCycleHandler(), WalSndWaitForWal(), and XLogSetAsyncXactLSN().
void ShutdownLatchSupport | ( | void | ) |
Definition at line 364 of file latch.c.
References close, FreeWaitEventSet(), InvalidPid, LatchWaitSet, pqsignal(), selfpipe_owner_pid, selfpipe_readfd, selfpipe_writefd, and SIG_IGN.
bool WaitEventSetCanReportClosed | ( | void | ) |
int WaitEventSetWait | ( | WaitEventSet * | set, |
long | timeout, | ||
WaitEvent * | occurred_events, | ||
int | nevents, | ||
uint32 | wait_event_info | ||
) |
Definition at line 1424 of file latch.c.
References Assert, WaitEventSet::events, WaitEvent::events, WaitEvent::fd, INSTR_TIME_GET_MILLISEC, INSTR_TIME_SET_CURRENT, INSTR_TIME_SET_ZERO, INSTR_TIME_SUBTRACT, Latch::is_set, WaitEventSet::latch, WaitEventSet::latch_pos, Latch::maybe_sleeping, pg_memory_barrier, PGINVALID_SOCKET, pgstat_report_wait_end(), pgstat_report_wait_start(), pgwin32_dispatch_queued_signals(), WaitEvent::pos, start_time, WaitEvent::user_data, WaitEventSetWaitBlock(), waiting, and WL_LATCH_SET.
Referenced by ExecAppendAsyncEventWait(), pq_check_connection(), secure_read(), secure_write(), ServerLoop(), SysLoggerMain(), WaitLatch(), WaitLatchOrSocket(), and WalSndWait().
Definition at line 517 of file latch.c.
References Assert, WaitEventSet::exit_on_postmaster_death, IsUnderPostmaster, LatchWaitSet, LatchWaitSetLatchPos, ModifyWaitEvent(), WaitEventSetWait(), WL_EXIT_ON_PM_DEATH, WL_LATCH_SET, WL_POSTMASTER_DEATH, and WL_TIMEOUT.
Referenced by ApplyLauncherMain(), autoprewarm_main(), BackgroundWriterMain(), CheckpointerMain(), CheckpointWriteDelay(), ConditionVariableTimedSleep(), do_pg_backup_stop(), gather_readnext(), lazy_truncate_heap(), LogicalParallelApplyLoop(), logicalrep_worker_stop_internal(), mq_putmessage(), pa_send_data(), pa_wait_for_xact_state(), pg_promote(), pg_sleep(), pg_wait_until_termination(), pgarch_MainLoop(), ProcSleep(), ProcWaitForSignal(), recoveryApplyDelay(), RegisterSyncRequest(), shm_mq_receive_bytes(), shm_mq_send_bytes(), shm_mq_wait_internal(), ShutDownSlotSync(), summarizer_wait_for_wal(), SyncRepWaitForLSN(), test_shm_mq_pipelined(), throttle(), wait_for_relation_state_change(), wait_for_slot_activity(), wait_for_worker_state_change(), wait_for_workers_to_become_ready(), WaitForBackgroundWorkerShutdown(), WaitForBackgroundWorkerStartup(), WaitForParallelWorkersToAttach(), WaitForParallelWorkersToFinish(), WaitForReplicationWorkerAttach(), WaitForWALToBecomeAvailable(), WalRcvWaitForStartPosition(), WalSummarizerMain(), WalWriterMain(), and worker_spi_main().
int WaitLatchOrSocket | ( | Latch * | latch, |
int | wakeEvents, | ||
pgsocket | sock, | ||
long | timeout, | ||
uint32 | wait_event_info | ||
) |
Definition at line 565 of file latch.c.
References AddWaitEventToSet(), Assert, CreateWaitEventSet(), CurrentResourceOwner, 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(), libpqsrv_cancel(), libpqsrv_connect_internal(), libpqsrv_get_result(), LogicalRepApplyLoop(), pgfdw_get_cleanup_result(), read_or_wait(), secure_open_gssapi(), and WalReceiverMain().