mirror of
https://github.com/postgres/postgres.git
synced 2025-11-09 06:21:09 +03:00
Add WalRcvGetState() to retrieve the state of a WAL receiver
This has come up as useful as an alternative of WalRcvStreaming(), to be able to do sanity checks based on the state of a WAL receiver. This will be used in a follow-up commit. Author: Xuneng Zhou <xunengzhou@gmail.com> Discussion: https://postgr.es/m/19093-c4fff49a608f82a0@postgresql.org
This commit is contained in:
@@ -119,6 +119,20 @@ WalRcvRunning(void)
|
||||
return false;
|
||||
}
|
||||
|
||||
/* Return the state of the walreceiver. */
|
||||
WalRcvState
|
||||
WalRcvGetState(void)
|
||||
{
|
||||
WalRcvData *walrcv = WalRcv;
|
||||
WalRcvState state;
|
||||
|
||||
SpinLockAcquire(&walrcv->mutex);
|
||||
state = walrcv->walRcvState;
|
||||
SpinLockRelease(&walrcv->mutex);
|
||||
|
||||
return state;
|
||||
}
|
||||
|
||||
/*
|
||||
* Is walreceiver running and streaming (or at least attempting to connect,
|
||||
* or starting up)?
|
||||
|
||||
Reference in New Issue
Block a user