int PostmasterMain(int argc, char* argv[]) { …… gs_signal_slots_init(GLOBAL_ALL_PROCS + EXTERN_SLOTS_NUM); //信号插槽初始化 gs_signal_startup_siginfo("PostmasterMain"); gs_signal_monitor_startup(); …… } void gs_signal_slots_init(unsigned long int size) { g_instance.signal_base->slots = (GsSignalSlot*)MemoryContextAlloc(t_thrd.mem_cxt.gs_signal_mem_cxt, (sizeof(GsSignalSlot) * size)); /* create GsSignal for ever slot */ g_instance.signal_base->slots_size = size; for (loop = 0; loop < g_instance.signal_base->slots_size; loop++) { int cnt_nodes = ((loop > 0) ? SUB_HODLER_SIZE : size); // SUB_HODLER_SIZE = 100 GsSignalSlot* tmp_sig_slot = tmp_sig_slot = &(g_instance.signal_base->slots[loop]); tmp_sig_slot->gssignal = gs_signal_init(cnt_nodes); } } static GsSignal* gs_signal_init(int cnt_nodes) { GsSignal* gs_signal = (GsSignal*)MemoryContextAlloc(t_thrd.mem_cxt.gs_signal_mem_cxt, sizeof(struct GsSignal)); gs_signal_sigpool_init(gs_signal, cnt_nodes); return gs_signal; } static void gs_signal_sigpool_init(GsSignal* gs_signal, int cnt_nodes) { SignalPool* sigpool = &gs_signal->sig_pool; sigpool->free_head = (GsNode*)MemoryContextAlloc(t_thrd.mem_cxt.gs_signal_mem_cxt, (unsigned int)(cnt_nodes) * sizeof(GsNode)); for (loop = 0; loop < (unsigned int)cnt_nodes - 1; loop++) { sigpool->free_head[loop].next = &(sigpool->free_head[loop + 1]); } sigpool->free_head[cnt_nodes - 1].next = NULL; sigpool->free_head = &sigpool->free_head[0]; sigpool->free_tail = &sigpool->free_head[cnt_nodes - 1]; sigpool->used_head = NULL; sigpool->used_tail = NULL; sigpool->pool_size = cnt_nodes; }