MCPcopy Create free account
hub / github.com/apache/cloudberry / CountChildren

Function CountChildren

src/backend/postmaster/postmaster.c:6023–6057  ·  view source on GitHub ↗

* Count up number of child processes of specified types (dead_end children * are always excluded). */

Source from the content-addressed store, hash-verified

6021 * are always excluded).
6022 */
6023static int
6024CountChildren(int target)
6025{
6026 dlist_iter iter;
6027 int cnt = 0;
6028
6029 dlist_foreach(iter, &BackendList)
6030 {
6031 Backend *bp = dlist_container(Backend, elem, iter.cur);
6032
6033 if (bp->dead_end)
6034 continue;
6035
6036 /*
6037 * Since target == BACKEND_TYPE_ALL is the most common case, we test
6038 * it first and avoid touching shared memory for every child.
6039 */
6040 if (target != BACKEND_TYPE_ALL)
6041 {
6042 /*
6043 * Assign bkend_type for any recently announced WAL Sender
6044 * processes.
6045 */
6046 if (bp->bkend_type == BACKEND_TYPE_NORMAL &&
6047 IsPostmasterChildWalSender(bp->child_slot))
6048 bp->bkend_type = BACKEND_TYPE_WALSND;
6049
6050 if (!(target & bp->bkend_type))
6051 continue;
6052 }
6053
6054 cnt++;
6055 }
6056 return cnt;
6057}
6058
6059
6060/*

Callers 2

canAcceptConnectionsFunction · 0.85
PostmasterStateMachineFunction · 0.85

Calls 1

Tested by

no test coverage detected