/** geo_proc_module_init create the geo-replication context pool @param : context_count : number of contexts @retval : 0 : done @retval -1 : out of memory */ int geo_proc_module_init(uint32_t context_count) { geo_proc_ctx_t *p; uint32_t idxCur; ruc_obj_desc_t *pnext; uint32_t ret = 0; geo_proc_context_allocated = 0; geo_proc_context_count = context_count; geo_proc_context_freeListHead = (geo_proc_ctx_t*) NULL; /* ** create the active list */ ruc_listHdrInit((ruc_obj_desc_t*) & geo_proc_context_activeListHead); /* ** create the Transaction context pool */ geo_proc_context_freeListHead = (geo_proc_ctx_t*) ruc_listCreate(context_count, sizeof (geo_proc_ctx_t)); if (geo_proc_context_freeListHead == (geo_proc_ctx_t*) NULL) { /* ** out of memory */ severe("Out of memory: requested size %d",(int)(context_count * sizeof (geo_proc_ctx_t))); return -1; } /* ** store the pointer to the first context */ geo_proc_context_pfirst = geo_proc_context_freeListHead; /* ** initialize each entry of the free list */ idxCur = 0; pnext = (ruc_obj_desc_t*) NULL; while ((p = (geo_proc_ctx_t*) ruc_objGetNext((ruc_obj_desc_t*) geo_proc_context_freeListHead, &pnext)) != (geo_proc_ctx_t*) NULL) { p->index = idxCur; p->free = TRUE; geo_proc_ctxInit(p, TRUE); p->record_buf_p = NULL; idxCur++; } /* ** Initialize the timer module:period is 100 ms */ geo_ctx_tmr_init(100, 15); /* ** Clear the statistics counter */ memset(geo_proc_stats, 0, sizeof (uint64_t) * GEO_CTX_COUNTER_MAX); geo_proc_debug_init(); return ret; }
/** north_lbg_module_init create the Transaction context pool @param : north_lbg_ctx_count : number of Transaction context @retval : RUC_OK : done @retval RUC_NOK : out of memory */ uint32_t north_lbg_module_init(uint32_t north_lbg_ctx_count) { north_lbg_ctx_t *p; uint32_t idxCur; ruc_obj_desc_t *pnext; uint32_t ret = RUC_OK; north_lbg_context_allocated = 0; north_lbg_context_count = north_lbg_ctx_count; north_lbg_context_freeListHead = (north_lbg_ctx_t*) NULL; /* ** create the active list */ ruc_listHdrInit((ruc_obj_desc_t*) & north_lbg_context_activeListHead); /* ** create the af unix context pool */ north_lbg_context_freeListHead = (north_lbg_ctx_t*) ruc_listCreate(north_lbg_ctx_count, sizeof (north_lbg_ctx_t)); if (north_lbg_context_freeListHead == (north_lbg_ctx_t*) NULL) { /* ** out of memory */ RUC_WARNING(north_lbg_ctx_count * sizeof (north_lbg_ctx_t)); return RUC_NOK; } /* ** store the pointer to the first context */ north_lbg_context_pfirst = north_lbg_context_freeListHead; /* ** initialize each entry of the free list */ idxCur = 0; pnext = (ruc_obj_desc_t*) NULL; while ((p = (north_lbg_ctx_t*) ruc_objGetNext((ruc_obj_desc_t*) north_lbg_context_freeListHead, &pnext)) != (north_lbg_ctx_t*) NULL) { p->index = idxCur; p->free = TRUE; north_lbg_ctxInit(p, TRUE); p->state = NORTH_LBG_DEPENDENCY; idxCur++; } north_lbg_debug_init(); /* ** timer mode init */ north_lbg_tmr_init(200, 15); return ret; }
/*---------------------------------------------- ** init of the observer service **---------------------------------------------- ** IN : ** . maxServer = number server context ** . maxClient = number of client context ** OUT : RUC_OK or RUC_NOK **----------------------------------------------- */ uint32_t ruc_observer_init(uint32_t maxClient, uint32_t maxServer) { int idx; ruc_obj_desc_t * pnext=(ruc_obj_desc_t*)NULL; RUC_OBSERVER_SERVER_T * pSrv; RUC_OBSERVER_CLIENT_T * pClt; if (ruc_observer_initDone == TRUE) { return RUC_OK; } ruc_observer_max_server = maxServer; ruc_observer_max_client = maxClient; /* ** create the server distributor */ ruc_observer_server_freeListHead = (RUC_OBSERVER_SERVER_T *)ruc_listCreate(maxServer, sizeof(RUC_OBSERVER_SERVER_T)); if (ruc_observer_server_freeListHead == (RUC_OBSERVER_SERVER_T*)NULL) { /* ** out of memory */ ERRFAT "runc_observer_init: out of memory" ENDERRFAT; return RUC_NOK; } /* ** initialize each element of the free list */ idx = 0; pnext = (ruc_obj_desc_t*)NULL; while ((pSrv = (RUC_OBSERVER_SERVER_T*) ruc_objGetNext(&ruc_observer_server_freeListHead->link, &pnext)) !=(RUC_OBSERVER_SERVER_T*)NULL) { pSrv->nbEvent = 0; pSrv->ref = idx; pSrv->pEventTbl = NULL; strcpy(pSrv->name,"FREE"); idx +=1; } ruc_listHdrInit(&ruc_observer_server_activeList.link); /* ** create the client distributor */ ruc_observer_client_freeListHead = (RUC_OBSERVER_CLIENT_T *)ruc_listCreate(maxClient, sizeof(RUC_OBSERVER_CLIENT_T)); if (ruc_observer_client_freeListHead == (RUC_OBSERVER_CLIENT_T*)NULL) { /* ** out of memory */ ERRFAT "runc_observer_init: out of memory" ENDERRFAT; return RUC_NOK; } /* ** initialize each element of the free list */ idx = 0; pnext = (ruc_obj_desc_t*)NULL; while ((pClt = (RUC_OBSERVER_CLIENT_T*) ruc_objGetNext((ruc_obj_desc_t*)ruc_observer_client_freeListHead, &pnext)) !=(RUC_OBSERVER_CLIENT_T*)NULL) { pClt->priority = -1; pClt->ref = idx; pClt->objRef = NULL; pClt->event = -1; pClt->callBack = (ruc_observer_cbk)NULL; strcpy(pClt->name,"FREE"); idx +=1; } ruc_observer_initDone = TRUE; return RUC_OK; }
/** af_unix_module_init create the Transaction context pool @param : af_unix_ctx_count : number of Transaction context @param : max_xmit_buf_count : number of xmit buffers @param : max_xmit_buf_size : xmit buffer size @param : max_recv_buf_count : number of receive buffers @param : max_recv_buf_count : receive buffer size @retval : RUC_OK : done @retval RUC_NOK : out of memory */ uint32_t af_unix_module_init(uint32_t af_unix_ctx_count, int max_xmit_buf_count, int max_xmit_buf_size, int max_recv_buf_count, int max_recv_buf_size ) { af_unix_ctx_generic_t *p; uint32_t idxCur; ruc_obj_desc_t *pnext; uint32_t ret = RUC_OK; af_unix_xmit_buf_count = max_xmit_buf_count; af_unix_xmit_buf_size = max_xmit_buf_size; af_unix_recv_buf_count = max_recv_buf_count; af_unix_recv_buf_size = max_recv_buf_size; af_unix_context_allocated = 0; af_unix_context_count = af_unix_ctx_count; while (1) { af_unix_buffer_pool_tb[0] = ruc_buf_poolCreate(af_unix_xmit_buf_count, af_unix_xmit_buf_size); if (af_unix_buffer_pool_tb[0] == NULL) { ret = RUC_NOK; severe( "xmit ruc_buf_poolCreate(%d,%d)", af_unix_xmit_buf_count, af_unix_xmit_buf_size ); break; } af_unix_buffer_pool_tb[1] = ruc_buf_poolCreate(af_unix_recv_buf_count, af_unix_recv_buf_size); if (af_unix_buffer_pool_tb[1] == NULL) { ret = RUC_NOK; severe( "rcv ruc_buf_poolCreate(%d,%d)", af_unix_recv_buf_count, af_unix_recv_buf_size ); break; } af_unix_context_freeListHead = (af_unix_ctx_generic_t*) NULL; /* ** create the active list */ ruc_listHdrInit((ruc_obj_desc_t*) & af_unix_context_activeListHead); /* ** create the af unix context pool */ af_unix_context_freeListHead = (af_unix_ctx_generic_t*) ruc_listCreate(af_unix_ctx_count, sizeof (af_unix_ctx_generic_t)); if (af_unix_context_freeListHead == (af_unix_ctx_generic_t*) NULL) { /* ** out of memory */ RUC_WARNING(af_unix_ctx_count * sizeof (af_unix_ctx_generic_t)); return RUC_NOK; } /* ** store the pointer to the first context */ af_unix_context_pfirst = af_unix_context_freeListHead; /* ** initialize each entry of the free list */ idxCur = 0; pnext = (ruc_obj_desc_t*) NULL; while ((p = (af_unix_ctx_generic_t*) ruc_objGetNext((ruc_obj_desc_t*) af_unix_context_freeListHead, &pnext)) != (af_unix_ctx_generic_t*) NULL) { p->index = idxCur; p->free = TRUE; af_unix_ctxInit(p, TRUE); idxCur++; } af_unix_debug_init(); break; } return ret; }