/** * This function initializes the DTMS_CB including the Patricia trees * * @param dtms_cb * * @return NCSCC_RC_SUCCESS * @return NCSCC_RC_FAILURE * */ uns32 dtm_cb_init(DTM_INTERNODE_CB * dtms_cb) { NCS_PATRICIA_PARAMS nodeid_param; NCS_PATRICIA_PARAMS comm_socket_param; NCS_PATRICIA_PARAMS ipaddr_param; TRACE_ENTER(); memset(&nodeid_param, 0, sizeof(NCS_PATRICIA_PARAMS)); memset(&comm_socket_param, 0, sizeof(NCS_PATRICIA_PARAMS)); memset(&ipaddr_param, 0, sizeof(NCS_PATRICIA_PARAMS)); nodeid_param.key_size = sizeof(uns32); comm_socket_param.key_size = sizeof(uns32); ipaddr_param.key_size = IPV6_ADDR_UNS8_CNT; /* Initialize patricia tree for nodeid list */ if (NCSCC_RC_SUCCESS != ncs_patricia_tree_init(&dtms_cb->nodeid_tree, &nodeid_param)) { LOG_ER("DTM: ncs_patricia_tree_init FAILED"); return NCSCC_RC_FAILURE; } /* Initialize comm_socket patricia tree */ if (NCSCC_RC_SUCCESS != ncs_patricia_tree_init(&dtms_cb->comm_sock_tree, &comm_socket_param)) { LOG_ER("DTM:ncs_patricia_tree_init FAILED"); return NCSCC_RC_FAILURE; } /* Initialize comm_socket patricia tree */ if (NCSCC_RC_SUCCESS != ncs_patricia_tree_init(&dtms_cb->ip_addr_tree, &ipaddr_param)) { LOG_ER("DTM:ncs_patricia_tree_init FAILED"); return NCSCC_RC_FAILURE; } if (m_NCS_IPC_CREATE(&dtms_cb->mbx) != NCSCC_RC_SUCCESS) { /* Mail box creation failed */ LOG_ER("DTM:IPC create FAILED"); return NCSCC_RC_FAILURE; } else { NCS_SEL_OBJ obj; if (NCSCC_RC_SUCCESS != m_NCS_IPC_ATTACH(&dtms_cb->mbx)) { m_NCS_IPC_RELEASE(&dtms_cb->mbx, NULL); LOG_ER("DTM: Internode Mailbox Attach failed"); return NCSCC_RC_FAILURE; } obj = m_NCS_IPC_GET_SEL_OBJ(&dtms_cb->mbx); /* retreive the corresponding fd for mailbox and fill it in cb */ dtms_cb->mbx_fd = m_GET_FD_FROM_SEL_OBJ(obj); /* extract and fill value needs to be extracted */ } TRACE_LEAVE(); return NCSCC_RC_SUCCESS; }
/**************************************************************************** * Name : gld_add_glnd_node * Description : Adds node_details info to the gld_cb and initilizes node_details->rsc_info_tree * * Arguments :GLSV_GLD_CB, glnd_mds_dest * * Return Values : * * Notes : None. *****************************************************************************/ GLSV_GLD_GLND_DETAILS *gld_add_glnd_node(GLSV_GLD_CB *gld_cb, MDS_DEST glnd_mds_dest) { GLSV_GLD_GLND_DETAILS *node_details; NCS_PATRICIA_PARAMS params = { sizeof(uns32) }; /* Need to add the node details */ node_details = m_MMGR_ALLOC_GLSV_GLD_GLND_DETAILS; if (node_details == NULL) { m_LOG_GLD_MEMFAIL(GLD_NODE_DETAILS_ALLOC_FAILED, __FILE__, __LINE__); return NULL; } memset(node_details, 0, sizeof(GLSV_GLD_GLND_DETAILS)); memcpy(&node_details->dest_id, &glnd_mds_dest, sizeof(MDS_DEST)); node_details->node_id = m_NCS_NODE_ID_FROM_MDS_DEST(glnd_mds_dest); node_details->status = GLND_OPERATIONAL_STATE; m_LOG_GLD_EVT(GLD_EVT_MDS_GLND_UP, NCSFL_SEV_NOTICE, __FILE__, __LINE__, 0, node_details->node_id); /* Initialize the pat tree for resource info */ if ((ncs_patricia_tree_init(&node_details->rsc_info_tree, ¶ms)) != NCSCC_RC_SUCCESS) { m_LOG_GLD_HEADLINE(GLD_PATRICIA_TREE_INIT_FAILED, NCSFL_SEV_ERROR, __FILE__, __LINE__, 0); m_MMGR_FREE_GLSV_GLD_GLND_DETAILS(node_details); return NULL; } node_details->pat_node.key_info = (uns8 *)&node_details->node_id; if (ncs_patricia_tree_add(&gld_cb->glnd_details, &node_details->pat_node) != NCSCC_RC_SUCCESS) { m_LOG_GLD_HEADLINE(GLD_PATRICIA_TREE_ADD_FAILED, NCSFL_SEV_ERROR, __FILE__, __LINE__, 0); m_MMGR_FREE_GLSV_GLD_GLND_DETAILS(node_details); return NULL; } return node_details; }
bool sysfTmrCreate(void) { NCS_PATRICIA_PARAMS pat_param; uint32_t rc = NCSCC_RC_SUCCESS; if (ncs_tmr_create_done == false) ncs_tmr_create_done = true; else return true; /* Empty Timer Service control block. */ memset(&gl_tcb, '\0', sizeof(SYSF_TMR_CB)); /* put local persistent guard in start state */ ncslpg_create(&gl_tcb.persist); /* Initialize the locks */ m_NCS_LOCK_INIT(&gl_tcb.safe.enter_lock); m_NCS_LOCK_INIT(&gl_tcb.safe.free_lock); memset((void *)&pat_param, 0, sizeof(NCS_PATRICIA_PARAMS)); pat_param.key_size = sizeof(uint64_t); rc = ncs_patricia_tree_init(&gl_tcb.tmr_pat_tree, &pat_param); if (rc != NCSCC_RC_SUCCESS) { return NCSCC_RC_FAILURE; } rc = m_NCS_SEL_OBJ_CREATE(&gl_tcb.sel_obj); if (rc != NCSCC_RC_SUCCESS) { ncs_patricia_tree_destroy(&gl_tcb.tmr_pat_tree); return NCSCC_RC_FAILURE; } tmr_destroying = false; /* create expiry thread */ int policy = SCHED_RR; /*root defaults */ int max_prio = sched_get_priority_max(policy); int min_prio = sched_get_priority_min(policy); int prio_val = ((max_prio - min_prio) * 0.87); if (m_NCS_TASK_CREATE((NCS_OS_CB)ncs_tmr_wait, 0, (char *)"OSAF_TMR", prio_val, policy, NCS_TMR_STACKSIZE, &gl_tcb.p_tsk_hdl) != NCSCC_RC_SUCCESS) { ncs_patricia_tree_destroy(&gl_tcb.tmr_pat_tree); m_NCS_SEL_OBJ_DESTROY(&gl_tcb.sel_obj); return false; } if (m_NCS_TASK_START(gl_tcb.p_tsk_hdl) != NCSCC_RC_SUCCESS) { m_NCS_TASK_RELEASE(gl_tcb.p_tsk_hdl); ncs_patricia_tree_destroy(&gl_tcb.tmr_pat_tree); m_NCS_SEL_OBJ_DESTROY(&gl_tcb.sel_obj); return false; } return true; }
/**************************************************************************** * Name : eds_cb_init * * Description : This function initializes the EDS_CB including the * Patricia trees. * * * Arguments : eds_cb * - Pointer to the EDS_CB. * * Return Values : NCSCC_RC_SUCCESS/NCSCC_RC_FAILURE. * * Notes : None. *****************************************************************************/ uint32_t eds_cb_init(EDS_CB *eds_cb) { NCS_PATRICIA_PARAMS reg_param, cname_param, nodelist_param; memset(®_param, 0, sizeof(NCS_PATRICIA_PARAMS)); memset(&cname_param, 0, sizeof(NCS_PATRICIA_PARAMS)); memset(&nodelist_param, 0, sizeof(NCS_PATRICIA_PARAMS)); reg_param.key_size = sizeof(uint32_t); cname_param.key_size = sizeof(SaNameT); nodelist_param.key_size = sizeof(uint32_t); TRACE_ENTER(); /* Assign Initial HA state */ eds_cb->ha_state = EDS_HA_INIT_STATE; eds_cb->csi_assigned = false; eds_cb->is_impl_set = false; /* Assign Version. Currently, hardcoded, This will change later */ m_GET_MY_VERSION(eds_cb->eds_version); /* Initialize patricia tree for reg list */ if (NCSCC_RC_SUCCESS != ncs_patricia_tree_init(&eds_cb->eda_reg_list, ®_param)) { LOG_ER("Patricia Init for Reg List failed"); TRACE_LEAVE(); return NCSCC_RC_FAILURE; } /* Initialize patricia tree for channel name list */ if (NCSCC_RC_SUCCESS != ncs_patricia_tree_init(&eds_cb->eds_cname_list, &cname_param)) { LOG_ER("Patricia Init for Channel Name List failed"); TRACE_LEAVE(); return NCSCC_RC_FAILURE; } /* Initialize patricia tree for cluster nodes list */ if (NCSCC_RC_SUCCESS != ncs_patricia_tree_init(&eds_cb->eds_cluster_nodes_list, &nodelist_param)) { LOG_ER("Patricia Init for Cluster Nodes List failed"); TRACE_LEAVE(); return NCSCC_RC_FAILURE; } TRACE_LEAVE(); return NCSCC_RC_SUCCESS; }
/**************************************************************************** * PROCEDURE: mbcsv_lib_init * * Description : This is the function which initalize the mbcsv libarary. * This function creates an global lock, creates MBCSV linked * list, etc. * * Arguments : req_info - Request info. * * Return Values : SA_AIS_OK/Failure code. * * Notes : None. *****************************************************************************/ uint32_t mbcsv_lib_init(NCS_LIB_REQ_INFO *req_info) { NCS_PATRICIA_PARAMS pt_params; uint32_t rc = SA_AIS_OK; TRACE_ENTER(); if (mbcsv_cb.created == true) { TRACE_LEAVE2("Lib init request failed: MBCA already created"); return SA_AIS_ERR_INIT; } /* * Create global lock */ m_NCS_LOCK_INIT(&mbcsv_cb.global_lock); /* * Create patricia tree for the MBCA registration instance */ pt_params.key_size = sizeof(uint32_t); if (ncs_patricia_tree_init(&mbcsv_cb.reg_list, &pt_params) != NCSCC_RC_SUCCESS) { TRACE_4("pat tree init failed"); rc = SA_AIS_ERR_FAILED_OPERATION; goto err1; } if (NCSCC_RC_SUCCESS != mbcsv_initialize_mbx_list()) { TRACE_4("pat tree init for mailbox failed"); rc = SA_AIS_ERR_FAILED_OPERATION; goto err2; } /* * Create patricia tree for the peer list */ if (mbcsv_initialize_peer_list() != NCSCC_RC_SUCCESS) { TRACE_4("pat tree init for peer list failed"); rc = SA_AIS_ERR_FAILED_OPERATION; goto err3; } mbcsv_cb.created = true; return rc; /* Handle Different Error Situations */ err3: ncs_patricia_tree_destroy(&mbcsv_cb.mbx_list); m_NCS_LOCK_DESTROY(&mbcsv_cb.mbx_list_lock); err2: ncs_patricia_tree_destroy(&mbcsv_cb.reg_list); err1: m_NCS_LOCK_DESTROY(&mbcsv_cb.global_lock); TRACE_LEAVE(); return rc; }
void avd_cstype_constructor(void) { NCS_PATRICIA_PARAMS patricia_params; patricia_params.key_size = sizeof(SaNameT); assert(ncs_patricia_tree_init(&cstype_db, &patricia_params) == NCSCC_RC_SUCCESS); avd_class_impl_set("SaAmfCSType", NULL, NULL, cstype_ccb_completed_hdlr, cstype_ccb_apply_cb); avd_class_impl_set("SaAmfCSBaseType", NULL, NULL, avd_imm_default_OK_completed_cb, NULL); }
void avd_app_constructor(void) { NCS_PATRICIA_PARAMS patricia_params; patricia_params.key_size = sizeof(SaNameT); assert(ncs_patricia_tree_init(&app_db, &patricia_params) == NCSCC_RC_SUCCESS); avd_class_impl_set("SaAmfApplication", app_rt_attr_cb, app_admin_op_cb, app_ccb_completed_cb, app_ccb_apply_cb); }
/**************************************************************************** Name : mqa_client_tree_init Description : This routine is used to initialize the client tree Arguments : cb - pointer to the MQA Control Block Return Values : NCSCC_RC_SUCCESS/NCSCC_RC_FAILURE Notes : None ******************************************************************************/ static uns32 mqa_client_tree_init(MQA_CB *cb) { NCS_PATRICIA_PARAMS param; memset(¶m, 0, sizeof(NCS_PATRICIA_PARAMS)); param.key_size = sizeof(SaMsgHandleT); if (ncs_patricia_tree_init(&cb->mqa_client_tree, ¶m) != NCSCC_RC_SUCCESS) { return NCSCC_RC_FAILURE; } return NCSCC_RC_SUCCESS; }
NCS_BOOL sysfTmrCreate(void) { NCS_PATRICIA_PARAMS pat_param; uns32 rc = NCSCC_RC_SUCCESS; if (ncs_tmr_create_done == FALSE) ncs_tmr_create_done = TRUE; else return TRUE; /* Empty Timer Service control block. */ memset(&gl_tcb, '\0', sizeof(SYSF_TMR_CB)); /* put local persistent guard in start state */ ncslpg_create(&gl_tcb.persist); /* Initialize the locks */ m_NCS_LOCK_INIT(&gl_tcb.safe.enter_lock); m_NCS_LOCK_INIT(&gl_tcb.safe.free_lock); memset((void *)&pat_param, 0, sizeof(NCS_PATRICIA_PARAMS)); pat_param.key_size = sizeof(uns64); rc = ncs_patricia_tree_init(&gl_tcb.tmr_pat_tree, &pat_param); if (rc != NCSCC_RC_SUCCESS) { return NCSCC_RC_FAILURE; } rc = m_NCS_SEL_OBJ_CREATE(&gl_tcb.sel_obj); if (rc != NCSCC_RC_SUCCESS) { ncs_patricia_tree_destroy(&gl_tcb.tmr_pat_tree); return NCSCC_RC_FAILURE; } tmr_destroying = FALSE; /* create expiry thread */ if (m_NCS_TASK_CREATE((NCS_OS_CB)ncs_tmr_wait, 0, NCS_TMR_TASKNAME, NCS_TMR_PRIORITY, NCS_TMR_STACKSIZE, &gl_tcb.p_tsk_hdl) != NCSCC_RC_SUCCESS) { ncs_patricia_tree_destroy(&gl_tcb.tmr_pat_tree); m_NCS_SEL_OBJ_DESTROY(gl_tcb.sel_obj); return FALSE; } if (m_NCS_TASK_START(gl_tcb.p_tsk_hdl) != NCSCC_RC_SUCCESS) { m_NCS_TASK_RELEASE(gl_tcb.p_tsk_hdl); ncs_patricia_tree_destroy(&gl_tcb.tmr_pat_tree); m_NCS_SEL_OBJ_DESTROY(gl_tcb.sel_obj); return FALSE; } return TRUE; }
/**************************************************************************** Name : mqa_queue_tree_init Description : This routine is used to initialize the queue tree Arguments : cb - pointer to the MQA Control Block Return Values : NCSCC_RC_SUCCESS/NCSCC_RC_FAILURE Notes : None ******************************************************************************/ static uns32 mqa_queue_tree_init(MQA_CB *cb) { NCS_PATRICIA_PARAMS param; uns32 rc = NCSCC_RC_SUCCESS; memset(¶m, 0, sizeof(NCS_PATRICIA_PARAMS)); param.key_size = sizeof(SaMsgQueueHandleT); if ((rc = ncs_patricia_tree_init(&cb->mqa_queue_tree, ¶m)) != NCSCC_RC_SUCCESS) { return rc; } return NCSCC_RC_SUCCESS; }
/**************************************************************************** Name : cpd_ckpt_map_tree_init Description : This routine is used to initialize the CPD Checkpoint MAP Tree. Arguments : cb - pointer to the CPD Control Block Return Values : NCSCC_RC_SUCCESS/NCSCC_RC_FAILURE Notes : None ******************************************************************************/ uns32 cpd_ckpt_map_tree_init(CPD_CB *cb) { NCS_PATRICIA_PARAMS param; memset(¶m, 0, sizeof(NCS_PATRICIA_PARAMS)); param.key_size = sizeof(SaNameT); if (ncs_patricia_tree_init(&cb->ckpt_map_tree, ¶m) != NCSCC_RC_SUCCESS) { return NCSCC_RC_FAILURE; } cb->is_ckpt_map_up = TRUE; return NCSCC_RC_SUCCESS; }
/**************************************************************************** Name : immd_immnd_info_tree_init Description : This routine is used to initialize the IMMND info Tree Arguments : cb - pointer to the IMMD Control Block Return Values : NCSCC_RC_SUCCESS/NCSCC_RC_FAILURE Notes : None *****************************************************************************/ uns32 immd_immnd_info_tree_init(IMMD_CB *cb) { NCS_PATRICIA_PARAMS param; memset(¶m, 0, sizeof(NCS_PATRICIA_PARAMS)); param.key_size = sizeof(NODE_ID); if (ncs_patricia_tree_init(&cb->immnd_tree, ¶m) != NCSCC_RC_SUCCESS) { return NCSCC_RC_FAILURE; } cb->is_immnd_tree_up = TRUE; return NCSCC_RC_SUCCESS; }
/*****************************************************************************\ * * PROCEDURE NAME: dta_svc_create * * DESCRIPTION: Create an instance of DTA, set configuration profile to * default, install this DTA with MDS and subscribe to DTS * events. * * RETURNS: SUCCESS - All went well * FAILURE - something went wrong. Turn on m_DTA_DBG_SINK() * for details. * \*****************************************************************************/ uns32 dta_svc_create(NCSDTA_CREATE *create) { /* Create a new structure and initialize all its fields */ DTA_CB *inst = &dta_cb; NCS_PATRICIA_PARAMS pt_params; m_DTA_LK_INIT; m_DTA_LK_CREATE(&inst->lock); m_DTA_LK(&inst->lock); inst->created = TRUE; inst->dts_exist = FALSE; /* Versioning changes */ inst->act_dts_ver = DTA_MIN_ACT_DTS_MDS_SUB_PART_VER; pt_params.key_size = sizeof(SS_SVC_ID); /*Create a Patricia tree for the DTA registration table instead of queue */ if (ncs_patricia_tree_init(&inst->reg_tbl, &pt_params) != NCSCC_RC_SUCCESS) { inst->created = FALSE; m_DTA_UNLK(&inst->lock); m_DTA_LK_DLT(&inst->lock); return m_DTA_DBG_SINK(NCSCC_RC_FAILURE, "dta_svc_create: Patricia tree init failed"); } /* * Get ADEST handle and then register with MDS. */ if (dta_get_ada_hdl() != NCSCC_RC_SUCCESS) { inst->created = FALSE; ncs_patricia_tree_destroy(&inst->reg_tbl); m_DTA_UNLK(&inst->lock); m_DTA_LK_DLT(&inst->lock); return m_DTA_DBG_SINK(NCSCC_RC_FAILURE, "dta_svc_create: Get ADEST handle failed"); } /* 3_0_b versioning changes - Subscribe to MDS with dta_mds_version */ inst->dta_mds_version = DTA_MDS_SUB_PART_VERSION; if (dta_mds_install_and_subscribe() != NCSCC_RC_SUCCESS) { inst->created = FALSE; ncs_patricia_tree_destroy(&inst->reg_tbl); m_DTA_UNLK(&inst->lock); m_DTA_LK_DLT(&inst->lock); return m_DTA_DBG_SINK(NCSCC_RC_FAILURE, "dta_svc_create: MDS install and subscribe failed"); } m_DTA_UNLK(&inst->lock); return NCSCC_RC_SUCCESS; }
/**************************************************************************** * Name : gld_cb_init * * Description : This function is invoked at init time. Initiaziles all the * parameters in the CB * * Arguments : gld_cb - GLD control block pointer. * * Return Values : NCSCC_RC_SUCCESS/NCSCC_RC_FAILURE. * * Notes : None. *****************************************************************************/ uns32 gld_cb_init(GLSV_GLD_CB *gld_cb) { NCS_PATRICIA_PARAMS params; memset(¶ms, 0, sizeof(NCS_PATRICIA_PARAMS)); /* Intialize all the patrica trees */ params.key_size = sizeof(uns32); params.info_size = 0; if ((ncs_patricia_tree_init(&gld_cb->glnd_details, ¶ms)) != NCSCC_RC_SUCCESS) { m_LOG_GLD_HEADLINE(GLD_PATRICIA_TREE_INIT_FAILED, NCSFL_SEV_ERROR, __FILE__, __LINE__, 0); return NCSCC_RC_FAILURE; } gld_cb->glnd_details_tree_up = TRUE; params.key_size = sizeof(uns32); params.info_size = 0; if ((ncs_patricia_tree_init(&gld_cb->rsc_info_id, ¶ms)) != NCSCC_RC_SUCCESS) { m_LOG_GLD_HEADLINE(GLD_PATRICIA_TREE_INIT_FAILED, NCSFL_SEV_ERROR, __FILE__, __LINE__, 0); return NCSCC_RC_FAILURE; } gld_cb->rsc_info_id_tree_up = TRUE; params.key_size = sizeof(SaNameT); params.info_size = 0; if ((ncs_patricia_tree_init(&gld_cb->rsc_map_info, ¶ms)) != NCSCC_RC_SUCCESS) { m_LOG_GLD_HEADLINE(GLD_PATRICIA_TREE_INIT_FAILED, NCSFL_SEV_ERROR, __FILE__, __LINE__, 0); return NCSCC_RC_FAILURE; } /* Initialize the next resource id */ gld_cb->nxt_rsc_id = 1; return NCSCC_RC_SUCCESS; }
/**************************************************************************** Name : cpd_ckpt_reploc_tree_init Description : This routine is used for replica location table Arguments : cb - pointer to the CPD Control Block Return Values : NCSCC_RC_SUCCESS/NCSCC_RC_FAILURE Notes : None ******************************************************************************/ uns32 cpd_ckpt_reploc_tree_init(CPD_CB *cb) { NCS_PATRICIA_PARAMS param; memset(¶m, 0, sizeof(NCS_PATRICIA_PARAMS)); /* param.key_size = 2 *sizeof(SaNameT); */ param.key_size = sizeof(CPD_REP_KEY_INFO); if (ncs_patricia_tree_init(&cb->ckpt_reploc_tree, ¶m) != NCSCC_RC_SUCCESS) { TRACE("CPD_CKPT_REPLOC_TREE_INIT FAILED"); return NCSCC_RC_FAILURE; } cb->is_ckpt_reploc_up = TRUE; TRACE("CPD_CKPT_REPLOC_TREE_INIT SUCCESS"); return NCSCC_RC_SUCCESS; }
/**************************************************************************** Name : mqa_queue_tree_init Description : This routine is used to initialize the queue tree Arguments : cb - pointer to the MQA Control Block Return Values : NCSCC_RC_SUCCESS/NCSCC_RC_FAILURE Notes : None ******************************************************************************/ static uint32_t mqa_queue_tree_init(MQA_CB *cb) { NCS_PATRICIA_PARAMS param; TRACE_ENTER(); uint32_t rc = NCSCC_RC_SUCCESS; memset(¶m, 0, sizeof(NCS_PATRICIA_PARAMS)); param.key_size = sizeof(SaMsgQueueHandleT); if ((rc = ncs_patricia_tree_init(&cb->mqa_queue_tree, ¶m)) != NCSCC_RC_SUCCESS) { TRACE_2("Initialization of the queue tree failed"); return rc; } TRACE_LEAVE(); return NCSCC_RC_SUCCESS; }
/**************************************************************************** Name : mqa_client_tree_init Description : This routine is used to initialize the client tree Arguments : cb - pointer to the MQA Control Block Return Values : NCSCC_RC_SUCCESS/NCSCC_RC_FAILURE Notes : None ******************************************************************************/ static uint32_t mqa_client_tree_init(MQA_CB *cb) { NCS_PATRICIA_PARAMS param; TRACE_ENTER(); memset(¶m, 0, sizeof(NCS_PATRICIA_PARAMS)); param.key_size = sizeof(SaMsgHandleT); if (ncs_patricia_tree_init(&cb->mqa_client_tree, ¶m) != NCSCC_RC_SUCCESS) { TRACE_2("FAILURE: initialization of the client tree failed"); return NCSCC_RC_FAILURE; } TRACE_LEAVE(); return NCSCC_RC_SUCCESS; }
/**************************************************************************** Name : avnd_pgdb_init Description : This routine initializes the PG database. Arguments : cb - ptr to the AvND control block Return Values : NCSCC_RC_SUCCESS/NCSCC_RC_FAILURE Notes : None. ******************************************************************************/ uns32 avnd_pgdb_init(AVND_CB *cb) { NCS_PATRICIA_PARAMS params; uns32 rc = NCSCC_RC_SUCCESS; memset(¶ms, 0, sizeof(NCS_PATRICIA_PARAMS)); params.key_size = sizeof(SaNameT); rc = ncs_patricia_tree_init(&cb->pgdb, ¶ms); if (NCSCC_RC_SUCCESS == rc) TRACE("PG DB create success"); else LOG_CR("PG DB create failed"); return rc; }
/**************************************************************************** Name : avnd_internode_avail_comp_db_init Description : This routine initializes the available internode components database. Arguments : cb - ptr to the AvND control block Return Values : NCSCC_RC_SUCCESS/NCSCC_RC_FAILURE Notes : None. ******************************************************************************/ uns32 avnd_internode_avail_comp_db_init(AVND_CB *cb) { NCS_PATRICIA_PARAMS params; uns32 rc = NCSCC_RC_SUCCESS; memset(¶ms, 0, sizeof(NCS_PATRICIA_PARAMS)); params.key_size = sizeof(SaNameT); rc = ncs_patricia_tree_init(&cb->internode_avail_comp_db, ¶ms); if (NCSCC_RC_SUCCESS != rc) { LOG_ER("internode_avail_comp_db initialization failed"); } return rc; }
/**************************************************************************** Name : avnd_nodeid_to_mdsdest_map_db_init Description : This routine initializes the node_id to mds dest map database. Arguments : cb - ptr to the AvND control block Return Values : NCSCC_RC_SUCCESS/NCSCC_RC_FAILURE Notes : None. ******************************************************************************/ uns32 avnd_nodeid_to_mdsdest_map_db_init(AVND_CB *cb) { NCS_PATRICIA_PARAMS params; uns32 rc = NCSCC_RC_SUCCESS; memset(¶ms, 0, sizeof(NCS_PATRICIA_PARAMS)); params.key_size = sizeof(NODE_ID); rc = ncs_patricia_tree_init(&cb->nodeid_mdsdest_db, ¶ms); if (NCSCC_RC_SUCCESS != rc) { LOG_ER("nodeid_mdsdest_db initialization failed"); } return rc; }
/***********************************************************************//** * @brief This routine is used to initialize the group tree. * * @return NCSCC_RC_SUCCESS/NCSCC_RC_FAILURE. ***************************************************************************/ uns32 plma_group_tree_init() { NCS_PATRICIA_PARAMS param; PLMA_CB *cb = plma_ctrlblk; TRACE_ENTER(); memset(¶m, 0, sizeof(NCS_PATRICIA_PARAMS)); param.key_size = sizeof(SaPlmEntityGroupHandleT); if (ncs_patricia_tree_init(&cb->entity_group_info, ¶m) != NCSCC_RC_SUCCESS) { LOG_ER("PLMA: GROUP TREE INIT FAILED"); return NCSCC_RC_FAILURE; } TRACE_LEAVE(); return NCSCC_RC_SUCCESS; }
/**************************************************************************** Name : mqa_client_tree_find_and_add Description : This routine adds the new client to the client tree and creates the selection object for that client. Arguments : mqa_cb : pointer to the mqa control block. hdl_id : the handle id. flag : true/false if true create the new node if node doesn't exist.FALSE -> search for an existing node. Return Values : returns the MQA_CLIENT_INFO node. Notes : The caller takes the cb lock before calling this function ******************************************************************************/ MQA_CLIENT_INFO *mqa_client_tree_find_and_add(MQA_CB *mqa_cb, SaMsgHandleT hdl_id, bool flag) { MQA_CLIENT_INFO *client_info = NULL; NCS_PATRICIA_PARAMS param; uint32_t rc = NCSCC_RC_SUCCESS; TRACE_ENTER(); client_info = (MQA_CLIENT_INFO *)ncs_patricia_tree_get(&mqa_cb->mqa_client_tree, (uint8_t *)&hdl_id); if (flag == true) { /* create and allocate the memory */ if (!client_info) { client_info = (MQA_CLIENT_INFO *)m_MMGR_ALLOC_MQA_CLIENT_INFO; if (!client_info) { TRACE_4("Client database creation failed"); return NULL; } memset(client_info, 0, sizeof(MQA_CLIENT_INFO)); /* Store the client_info pointer as msghandle. */ client_info->msgHandle = NCS_PTR_TO_UNS64_CAST(client_info); client_info->patnode.key_info = (uint8_t *)&client_info->msgHandle; if ((rc = ncs_patricia_tree_add(&mqa_cb->mqa_client_tree, &client_info->patnode)) != NCSCC_RC_SUCCESS) { TRACE_2("Client database Registration Failed"); m_MMGR_FREE_MQA_CLIENT_INFO(client_info); return NULL; } /* Create the group track tree */ memset(¶m, 0, sizeof(NCS_PATRICIA_PARAMS)); param.key_size = SA_MAX_NAME_LENGTH; if (ncs_patricia_tree_init(&client_info->mqa_track_tree, ¶m) != NCSCC_RC_SUCCESS) { TRACE_2("Initialization of the client tree failed"); m_MMGR_FREE_MQA_CLIENT_INFO(client_info); return NULL; } } } TRACE_LEAVE(); return client_info; }
/**************************************************************************** Name : mqa_client_tree_find_and_add Description : This routine adds the new client to the client tree and creates the selection object for that client. Arguments : mqa_cb : pointer to the mqa control block. hdl_id : the handle id. flag : TRUE/FALSE if TRUE create the new node if node doesn't exist.FALSE -> search for an existing node. Return Values : returns the MQA_CLIENT_INFO node. Notes : The caller takes the cb lock before calling this function ******************************************************************************/ MQA_CLIENT_INFO *mqa_client_tree_find_and_add(MQA_CB *mqa_cb, SaMsgHandleT hdl_id, NCS_BOOL flag) { MQA_CLIENT_INFO *client_info = NULL; NCS_PATRICIA_PARAMS param; uns32 rc = NCSCC_RC_SUCCESS; client_info = (MQA_CLIENT_INFO *)ncs_patricia_tree_get(&mqa_cb->mqa_client_tree, (uns8 *)&hdl_id); if (flag == TRUE) { /* create and allocate the memory */ if (!client_info) { client_info = (MQA_CLIENT_INFO *)m_MMGR_ALLOC_MQA_CLIENT_INFO; if (!client_info) { m_LOG_MQSV_A(MQA_CLIENT_ALLOC_FAILED, NCSFL_LC_MQSV_INIT, NCSFL_SEV_ERROR, 0, __FILE__, __LINE__); return NULL; } memset(client_info, 0, sizeof(MQA_CLIENT_INFO)); /* Store the client_info pointer as msghandle. */ client_info->msgHandle = NCS_PTR_TO_UNS64_CAST(client_info); client_info->patnode.key_info = (uns8 *)&client_info->msgHandle; if ((rc = ncs_patricia_tree_add(&mqa_cb->mqa_client_tree, &client_info->patnode)) != NCSCC_RC_SUCCESS) { m_LOG_MQSV_A(MQA_CLIENT_TREE_ADD_FAILED, NCSFL_LC_MQSV_INIT, NCSFL_SEV_ERROR, rc, __FILE__, __LINE__); m_MMGR_FREE_MQA_CLIENT_INFO(client_info); return NULL; } /* Create the group track tree */ memset(¶m, 0, sizeof(NCS_PATRICIA_PARAMS)); param.key_size = SA_MAX_NAME_LENGTH; if (ncs_patricia_tree_init(&client_info->mqa_track_tree, ¶m) != NCSCC_RC_SUCCESS) { m_MMGR_FREE_MQA_CLIENT_INFO(client_info); return NULL; } } } return client_info; }
/**************************************************************************\ * * start_exec_mod_cb * * Description: Initialize execute module control block. * * Synopsis: * * Call Arguments: * SUCCESS/FAILURE * * Returns: * None. * * Notes: * \**************************************************************************/ uns32 start_exec_mod_cb(void) { NCS_PATRICIA_PARAMS pt_params; int spair[2]; pt_params.key_size = sizeof(uns32); if (ncs_patricia_tree_init(&module_cb.pid_list, &pt_params) != NCSCC_RC_SUCCESS) { return m_LEAP_DBG_SINK(NCSCC_RC_FAILURE); } if (0 != socketpair(AF_UNIX, SOCK_DGRAM, 0, spair)) { perror("init_exec_mod_cb: socketpair: "); return m_LEAP_DBG_SINK(NCSCC_RC_FAILURE); } module_cb.read_fd = spair[0]; module_cb.write_fd = spair[1]; /* Create a task which will handle the signal and give call back */ if (m_NCS_TASK_CREATE((NCS_OS_CB)ncs_exec_mod_hdlr, 0, NCS_EXEC_MOD_TASKNAME, NCS_EXEC_MOD_PRIORITY, NCS_EXEC_MOD_STACKSIZE, &module_cb.em_task_handle) != NCSCC_RC_SUCCESS) { return m_LEAP_DBG_SINK(NCSCC_RC_FAILURE);; } if (m_NCS_TASK_START(module_cb.em_task_handle) != NCSCC_RC_SUCCESS) { m_NCS_TASK_RELEASE(module_cb.em_task_handle); return m_LEAP_DBG_SINK(NCSCC_RC_FAILURE);; } module_cb.init = TRUE; m_NCS_SIGNAL(SIGCHLD, ncs_exec_module_signal_hdlr); return NCSCC_RC_SUCCESS; }
/**************************************************************************** Name : ava_hdl_init Description : This routine initializes the handle database. Arguments : hdl_db - ptr to the handle database Return Values : NCSCC_RC_SUCCESS/NCSCC_RC_FAILURE Notes : None ******************************************************************************/ uint32_t ava_hdl_init(AVA_HDL_DB *hdl_db) { NCS_PATRICIA_PARAMS param; uint32_t rc = NCSCC_RC_SUCCESS; TRACE_ENTER(); memset(¶m, 0, sizeof(NCS_PATRICIA_PARAMS)); /* init the hdl db tree */ param.key_size = sizeof(uint32_t); param.info_size = 0; rc = ncs_patricia_tree_init(&hdl_db->hdl_db_anchor, ¶m); if (NCSCC_RC_SUCCESS == rc) hdl_db->num = 0; else TRACE("Patricia tree init failed for Handled DB"); TRACE_LEAVE(); return rc; }
/**************************************************************************** * Name : gld_add_glnd_node * Description : Adds node_details info to the gld_cb and initilizes node_details->rsc_info_tree * * Arguments :GLSV_GLD_CB, glnd_mds_dest * * Return Values : * * Notes : None. *****************************************************************************/ GLSV_GLD_GLND_DETAILS *gld_add_glnd_node(GLSV_GLD_CB *gld_cb, MDS_DEST glnd_mds_dest) { GLSV_GLD_GLND_DETAILS *node_details; NCS_PATRICIA_PARAMS params = { sizeof(uint32_t) }; TRACE_ENTER2("glnd_mds_dest %" PRIx64, glnd_mds_dest); /* Need to add the node details */ node_details = m_MMGR_ALLOC_GLSV_GLD_GLND_DETAILS; if (node_details == NULL) { LOG_CR("Node details alloc failed: Error %s", strerror(errno)); assert(0); } memset(node_details, 0, sizeof(GLSV_GLD_GLND_DETAILS)); memcpy(&node_details->dest_id, &glnd_mds_dest, sizeof(MDS_DEST)); node_details->node_id = m_NCS_NODE_ID_FROM_MDS_DEST(glnd_mds_dest); node_details->status = GLND_OPERATIONAL_STATE; TRACE("EVT Processing MDS GLND UP: node_id %u", node_details->node_id); /* Initialize the pat tree for resource info */ if ((ncs_patricia_tree_init(&node_details->rsc_info_tree, ¶ms)) != NCSCC_RC_SUCCESS) { LOG_ER("Patricia tree init failed"); m_MMGR_FREE_GLSV_GLD_GLND_DETAILS(node_details); node_details = NULL; goto end; } node_details->pat_node.key_info = (uint8_t *)&node_details->node_id; if (ncs_patricia_tree_add(&gld_cb->glnd_details, &node_details->pat_node) != NCSCC_RC_SUCCESS) { LOG_ER("Patricia tree add failed"); m_MMGR_FREE_GLSV_GLD_GLND_DETAILS(node_details); node_details = NULL; goto end; } end: TRACE_LEAVE2("Node id %u",node_details->node_id); return node_details; }
/**************************************************************************** * Name : glnd_cb_create * * Description : This will create the CB and create the internal structures * * Arguments : pool id - pool id for the handle manager * * Return Values : GLND CB Pointer * * Notes : None. *****************************************************************************/ GLND_CB *glnd_cb_create(uns32 pool_id) { GLND_CB *glnd_cb = NULL; NCS_PATRICIA_PARAMS params = { 0 }; SaAmfHealthcheckKeyT healthy; int8 *health_key = NULL; SaAisErrorT amf_error; /* register with the Log service */ glnd_flx_log_reg(); /* allocate the memory */ glnd_cb = m_MMGR_ALLOC_GLND_CB; if (!glnd_cb) { m_LOG_GLND_MEMFAIL(GLND_CB_ALLOC_FAILED, __FILE__, __LINE__); glnd_flx_log_dereg(); return NULL; } memset(glnd_cb, 0, sizeof(GLND_CB)); glnd_cb->pool_id = pool_id; /* create the handle */ glnd_cb->cb_hdl_id = ncshm_create_hdl((uns8)pool_id, NCS_SERVICE_ID_GLND, (NCSCONTEXT)glnd_cb); if (!glnd_cb->cb_hdl_id) { m_LOG_GLND_HEADLINE(GLND_CB_TAKE_HANDLE_FAILED, NCSFL_SEV_ERROR, __FILE__, __LINE__); goto hdl_err; } /* create the internal strucutures */ /* create the client Tree */ params.key_size = sizeof(SaLckHandleT); params.info_size = 0; if ((ncs_patricia_tree_init(&glnd_cb->glnd_client_tree, ¶ms)) != NCSCC_RC_SUCCESS) { m_LOG_GLND_HEADLINE(GLND_CLIENT_TREE_INIT_FAILED, NCSFL_SEV_ERROR, __FILE__, __LINE__); goto client_err; } /* create the agent tree */ params.key_size = sizeof(MDS_DEST); params.info_size = 0; if ((ncs_patricia_tree_init(&glnd_cb->glnd_agent_tree, ¶ms)) != NCSCC_RC_SUCCESS) { m_LOG_GLND_HEADLINE(GLND_AGENT_TREE_INIT_FAILED, NCSFL_SEV_ERROR, __FILE__, __LINE__); goto agent_err; } /* create the Resource tree */ params.key_size = sizeof(SaLckResourceIdT); params.info_size = 0; if ((ncs_patricia_tree_init(&glnd_cb->glnd_res_tree, ¶ms)) != NCSCC_RC_SUCCESS) { m_LOG_GLND_HEADLINE(GLND_RSC_TREE_INIT_FAILED, NCSFL_SEV_ERROR, __FILE__, __LINE__); goto res_err; } /* create the mail box and attach it */ if (m_NCS_IPC_CREATE(&glnd_cb->glnd_mbx) != NCSCC_RC_SUCCESS) { m_LOG_GLND_HEADLINE(GLND_IPC_CREATE_FAILED, NCSFL_SEV_ERROR, __FILE__, __LINE__); goto mbx_create_err; } if (m_NCS_IPC_ATTACH(&glnd_cb->glnd_mbx) != NCSCC_RC_SUCCESS) { m_LOG_GLND_HEADLINE(GLND_IPC_ATTACH_FAILED, NCSFL_SEV_ERROR, __FILE__, __LINE__); goto mbx_attach_err; } /* EDU initialisation */ m_NCS_EDU_HDL_INIT(&glnd_cb->glnd_edu_hdl); /* resigter with the MDS */ if (glnd_mds_register(glnd_cb) != NCSCC_RC_SUCCESS) { m_LOG_GLND_HEADLINE(GLND_MDS_REGISTER_FAILED, NCSFL_SEV_ERROR, __FILE__, __LINE__); goto mds_err; } else m_LOG_GLND_HEADLINE(GLND_MDS_REGISTER_SUCCESS, NCSFL_SEV_NOTICE, __FILE__, __LINE__); /* Initialise with the AMF service */ if (glnd_amf_init(glnd_cb) != NCSCC_RC_SUCCESS) { m_LOG_GLND_HEADLINE(GLND_AMF_INIT_FAILED, NCSFL_SEV_ERROR, __FILE__, __LINE__); goto amf_init_err; } else m_LOG_GLND_HEADLINE(GLND_AMF_INIT_SUCCESS, NCSFL_SEV_NOTICE, __FILE__, __LINE__); /* register with the AMF service */ if (glnd_amf_register(glnd_cb) != NCSCC_RC_SUCCESS) { m_LOG_GLND_HEADLINE(GLND_AMF_REGISTER_FAILED, NCSFL_SEV_ERROR, __FILE__, __LINE__); goto amf_reg_err; } else m_LOG_GLND_HEADLINE(GLND_AMF_REGISTER_SUCCESS, NCSFL_SEV_NOTICE, __FILE__, __LINE__); /* everything went off well.. store the hdl in the global variable */ gl_glnd_hdl = glnd_cb->cb_hdl_id; /* start the AMF Health Check */ memset(&healthy, 0, sizeof(healthy)); health_key = (int8 *)getenv("GLSV_ENV_HEALTHCHECK_KEY"); if (health_key == NULL) { if (strlen("A1B2") < sizeof(healthy.key)) strncpy((char *)healthy.key, "A1B2", sizeof(healthy.key)); /* TBD Log the info */ } else { if (strlen((char *)health_key) <= sizeof(healthy.key)) strncpy((char *)healthy.key, (char *)health_key, SA_AMF_HEALTHCHECK_KEY_MAX - 1); } healthy.keyLen = strlen((char *)healthy.key); amf_error = saAmfHealthcheckStart(glnd_cb->amf_hdl, &glnd_cb->comp_name, &healthy, SA_AMF_HEALTHCHECK_AMF_INVOKED, SA_AMF_COMPONENT_RESTART); if (amf_error != SA_AIS_OK) { m_LOG_GLND_HEADLINE(GLND_AMF_HEALTHCHECK_START_FAILED, NCSFL_SEV_ERROR, __FILE__, __LINE__); } else m_LOG_GLND_HEADLINE(GLND_AMF_HEALTHCHECK_START_SUCCESS, NCSFL_SEV_NOTICE, __FILE__, __LINE__); if (glnd_cb->node_state != GLND_CLIENT_INFO_GET_STATE) { TRACE("setting the state as GLND_OPERATIONAL_STATE"); /* GLND HAS STRTED */ glnd_cb->node_state = GLND_OPERATIONAL_STATE; } /*create a shared memory segment to Checkpint Resource info, lck_info & backup_event info */ if (glnd_shm_create(glnd_cb) != NCSCC_RC_SUCCESS) goto glnd_shm_create_fail; return glnd_cb; glnd_shm_create_fail: glnd_amf_deregister(glnd_cb); amf_reg_err: glnd_amf_de_init(glnd_cb); amf_init_err: glnd_mds_unregister(glnd_cb); mds_err: m_NCS_EDU_HDL_FLUSH(&glnd_cb->glnd_edu_hdl); m_NCS_IPC_DETACH(&glnd_cb->glnd_mbx, glnd_cleanup_mbx, glnd_cb); mbx_attach_err: m_NCS_IPC_RELEASE(&glnd_cb->glnd_mbx, NULL); mbx_create_err: ncs_patricia_tree_destroy(&glnd_cb->glnd_res_tree); res_err: ncs_patricia_tree_destroy(&glnd_cb->glnd_agent_tree); agent_err: ncs_patricia_tree_destroy(&glnd_cb->glnd_client_tree); client_err: ncshm_destroy_hdl(NCS_SERVICE_ID_GLND, glnd_cb->cb_hdl_id); hdl_err: glnd_flx_log_dereg(); /* free the control block */ m_MMGR_FREE_GLND_CB(glnd_cb); return NULL; }
/** * This function initializes the CLMS_CB including the * Patricia trees. * * @param clms_cb * - Pointer to the CLMS_CB. * * @return NCSCC_RC_SUCCESS/NCSCC_RC_FAILURE. */ uint32_t clms_cb_init(CLMS_CB * clms_cb) { NCS_PATRICIA_PARAMS client_param; NCS_PATRICIA_PARAMS id_param; NCS_PATRICIA_PARAMS eename_param; NCS_PATRICIA_PARAMS nodename_param; NCS_PATRICIA_PARAMS ip_param; TRACE_ENTER(); memset(&client_param, 0, sizeof(NCS_PATRICIA_PARAMS)); memset(&id_param, 0, sizeof(NCS_PATRICIA_PARAMS)); memset(&eename_param, 0, sizeof(NCS_PATRICIA_PARAMS)); memset(&nodename_param, 0, sizeof(NCS_PATRICIA_PARAMS)); memset(&ip_param, 0, sizeof(NCS_PATRICIA_PARAMS)); client_param.key_size = sizeof(uint32_t); id_param.key_size = sizeof(uint32_t); eename_param.key_size = sizeof(SaNameT); nodename_param.key_size = sizeof(SaNameT); ip_param.key_size = sizeof(uint32_t); /* Assign Initial HA state */ clms_cb->ha_state = CLMS_HA_INIT_STATE; osaf_cluster = NULL; clms_cb->reg_with_plm = SA_FALSE; clms_cb->cluster_view_num = 0; clms_cb->csi_assigned = false; clms_cb->curr_invid = 1; clms_cb->immOiHandle = 0; clms_cb->is_impl_set = false; clms_cb->rtu_pending = false; /* Flag to control try-again of rt-updates */ /* Assign Version. Currently, hardcoded, This will change later */ clms_cb->clm_ver.releaseCode = CLM_RELEASE_CODE; clms_cb->clm_ver.majorVersion = CLM_MAJOR_VERSION_4; clms_cb->clm_ver.minorVersion = CLM_MINOR_VERSION; /* Initialize patricia tree for reg list */ if (NCSCC_RC_SUCCESS != ncs_patricia_tree_init(&clms_cb->client_db, &client_param)) return NCSCC_RC_FAILURE; /* Initialize nodes_db patricia tree */ if (NCSCC_RC_SUCCESS != ncs_patricia_tree_init(&clms_cb->nodes_db, &nodename_param)) return NCSCC_RC_FAILURE; /* Initialize ee_lookup patricia tree */ if (NCSCC_RC_SUCCESS != ncs_patricia_tree_init(&clms_cb->ee_lookup, &eename_param)) return NCSCC_RC_FAILURE; /* Initialize id_lookup patricia tree */ if (NCSCC_RC_SUCCESS != ncs_patricia_tree_init(&clms_cb->id_lookup, &id_param)) return NCSCC_RC_FAILURE; /* Initialize ip_lookup patricia tree */ if (NCSCC_RC_SUCCESS != ncs_patricia_tree_init(&clms_cb->iplist, &ip_param)) return NCSCC_RC_FAILURE; TRACE_LEAVE(); return NCSCC_RC_SUCCESS; }
/** * Function to init the intranode processing * * * @return NCSCC_RC_SUCCESS * @return NCSCC_RC_FAILURE * */ uint32_t dtm_intra_processing_init(char *node_ip, DTM_IP_ADDR_TYPE i_addr_family) { int servlen, size = DTM_INTRANODE_SOCK_SIZE; /* For socket fd and server len */ struct sockaddr_un serv_addr; /* For Unix Sock address */ char server_ux_name[255]; NCS_PATRICIA_PARAMS pat_tree_params; struct sockaddr_in serveraddr; struct sockaddr_in6 serveraddr6; int flags; TRACE_ENTER(); /* UNIX is default transport for intranode */ dtm_socket_domain = AF_UNIX; if (NULL == (dtm_intranode_cb = calloc(1, sizeof(DTM_INTRANODE_CB)))) { LOG_ER("DTM: Memory allocation failed for dtm_intranode_cb"); return NCSCC_RC_FAILURE; } dtm_intranode_cb->sock_domain = dtm_socket_domain; /* Open a socket, If socket opens to fail return Error */ dtm_intranode_cb->server_sockfd = socket(dtm_socket_domain, SOCK_STREAM, 0); if (dtm_intranode_cb->server_sockfd < 0) { LOG_ER("DTM: Socket creation failed err :%s ", strerror(errno)); free(dtm_intranode_cb); return NCSCC_RC_FAILURE; } /*Make the socket Non-Blocking for accepting */ if ((flags = fcntl(dtm_intranode_cb->server_sockfd, F_GETFL, NULL)) < 0) { LOG_ER("DTM :fcntl(F_SETFL, O_NONBLOCK) err :%s ", strerror(errno)); return false; } flags |= O_NONBLOCK; if(fcntl(dtm_intranode_cb->server_sockfd, F_SETFL, flags) < 0) { /*Non-Blocking Options hasnt been set, what shall we do now */ LOG_ER("DTM: Socket NON Block set failed err :%s ", strerror(errno)); close(dtm_intranode_cb->server_sockfd); free(dtm_intranode_cb); return NCSCC_RC_FAILURE; } /* Increase the socket buffer size */ if (setsockopt(dtm_intranode_cb->server_sockfd, SOL_SOCKET, SO_RCVBUF, &size, sizeof(size)) != 0) { LOG_ER("DTM: Unable to set the SO_RCVBUF err :%s ", strerror(errno)); close(dtm_intranode_cb->server_sockfd); free(dtm_intranode_cb); return NCSCC_RC_FAILURE; } if (setsockopt(dtm_intranode_cb->server_sockfd, SOL_SOCKET, SO_SNDBUF, &size, sizeof(size)) != 0) { LOG_ER("DTM: Unable to set the SO_SNDBUF err :%s ", strerror(errno)); close(dtm_intranode_cb->server_sockfd); free(dtm_intranode_cb); return NCSCC_RC_FAILURE; } dtm_intranode_cb->nodeid = m_NCS_GET_NODE_ID; bzero((char *)&serv_addr, sizeof(serv_addr)); if (dtm_socket_domain == AF_UNIX) { #define UX_SOCK_NAME_PREFIX PKGLOCALSTATEDIR "/osaf_dtm_intra_server" sprintf(server_ux_name, "%s", UX_SOCK_NAME_PREFIX); serv_addr.sun_family = AF_UNIX; strcpy(serv_addr.sun_path, server_ux_name); unlink(serv_addr.sun_path); servlen = strlen(serv_addr.sun_path) + sizeof(serv_addr.sun_family); /* Bind the created socket here with the address NODEID, * if bind fails return error by the closing the * created socket*/ if (bind(dtm_intranode_cb->server_sockfd, (struct sockaddr *)&serv_addr, servlen) < 0) { LOG_ER("DTM: Bind failed err :%s ", strerror(errno)); close(dtm_intranode_cb->server_sockfd); free(dtm_intranode_cb); return NCSCC_RC_FAILURE; } if (chmod(UX_SOCK_NAME_PREFIX, (S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH)) < 0) { LOG_ER("chmod %s failed - %s", UX_SOCK_NAME_PREFIX, strerror(errno)); close(dtm_intranode_cb->server_sockfd); free(dtm_intranode_cb); return NCSCC_RC_FAILURE; } } else { if (dtm_socket_domain == AF_INET) { memset(&serveraddr, 0, sizeof(serveraddr)); serveraddr.sin_family = AF_INET; serveraddr.sin_port = htons(DTM_INTRA_SERVER_PORT); serveraddr.sin_addr.s_addr = htonl(INADDR_LOOPBACK); if (bind(dtm_intranode_cb->server_sockfd, (struct sockaddr *)&serveraddr, sizeof(serveraddr) ) < 0) { LOG_ER("DTM: Bind failed err :%s ", strerror(errno)); close(dtm_intranode_cb->server_sockfd); free(dtm_intranode_cb); return NCSCC_RC_FAILURE; } } else { memset(&serveraddr6, 0, sizeof(serveraddr6)); serveraddr6.sin6_family = AF_INET6; serveraddr.sin_port = htons(DTM_INTRA_SERVER_PORT); inet_pton(AF_INET6, "localhost", &serveraddr6.sin6_addr); if (bind(dtm_intranode_cb->server_sockfd, (struct sockaddr *)&serveraddr6, sizeof(serveraddr6) ) < 0) { LOG_ER("DTM_INTRA: Bind failed"); close(dtm_intranode_cb->server_sockfd); free(dtm_intranode_cb); return NCSCC_RC_FAILURE; } } } listen(dtm_intranode_cb->server_sockfd, 20); memset(&pat_tree_params, 0, sizeof(pat_tree_params)); pat_tree_params.key_size = sizeof(uint32_t); if (NCSCC_RC_SUCCESS != ncs_patricia_tree_init(&dtm_intranode_cb->dtm_intranode_pid_list, &pat_tree_params)) { LOG_ER("DTM: ncs_patricia_tree_init failed for dtm_intranode_pid_list"); close(dtm_intranode_cb->server_sockfd); free(dtm_intranode_cb); return NCSCC_RC_FAILURE; } pat_tree_params.key_size = sizeof(int); if (NCSCC_RC_SUCCESS != ncs_patricia_tree_init(&dtm_intranode_cb->dtm_intranode_fd_list, &pat_tree_params)) { LOG_ER("DTM: ncs_patricia_tree_init failed for dtm_intranode_pid_list"); close(dtm_intranode_cb->server_sockfd); free(dtm_intranode_cb); return NCSCC_RC_FAILURE; } pat_tree_params.key_size = sizeof(uint32_t); if (NCSCC_RC_SUCCESS != ncs_patricia_tree_init(&dtm_intranode_cb->dtm_svc_subscr_list, &pat_tree_params)) { LOG_ER("DTM: ncs_patricia_tree_init failed for dtm_intranode_pid_list"); close(dtm_intranode_cb->server_sockfd); free(dtm_intranode_cb); return NCSCC_RC_FAILURE; } pat_tree_params.key_size = sizeof(uint32_t); if (NCSCC_RC_SUCCESS != ncs_patricia_tree_init(&dtm_intranode_cb->dtm_svc_install_list, &pat_tree_params)) { LOG_ER("DTM: ncs_patricia_tree_init failed for dtm_intranode_pid_list"); close(dtm_intranode_cb->server_sockfd); free(dtm_intranode_cb); return NCSCC_RC_FAILURE; } dtm_intranode_add_self_node_to_node_db(dtm_intranode_cb->nodeid, node_ip, i_addr_family); if (m_NCS_IPC_CREATE(&dtm_intranode_cb->mbx) != NCSCC_RC_SUCCESS) { /* Mail box creation failed */ LOG_ER("DTM : Intranode Mailbox Creation failed"); close(dtm_intranode_cb->server_sockfd); free(dtm_intranode_cb); return NCSCC_RC_FAILURE; } else { NCS_SEL_OBJ obj; /* Code added for attaching the mailbox, to eliminate the DBG Print at sysf_ipc.c: 640 */ if (NCSCC_RC_SUCCESS != m_NCS_IPC_ATTACH(&dtm_intranode_cb->mbx)) { m_NCS_IPC_RELEASE(&dtm_intranode_cb->mbx, NULL); close(dtm_intranode_cb->server_sockfd); free(dtm_intranode_cb); LOG_ER("DTM: Intranode Mailbox Attach failed"); return NCSCC_RC_FAILURE; } obj = m_NCS_IPC_GET_SEL_OBJ(&dtm_intranode_cb->mbx); /* retreive the corresponding fd for mailbox and fill it in cb */ dtm_intranode_cb->mbx_fd = m_GET_FD_FROM_SEL_OBJ(obj); /* extract and fill value needs to be extracted */ } dtm_intranode_add_poll_fdlist(dtm_intranode_cb->server_sockfd, POLLIN); dtm_intranode_add_poll_fdlist(dtm_intranode_cb->mbx_fd, POLLIN); if (dtm_intranode_create_rcv_task(dtm_intranode_cb->task_hdl) != NCSCC_RC_SUCCESS) { LOG_ER("MDS:MDTM: Receive Task Creation Failed in MDTM_INIT\n"); close(dtm_intranode_cb->server_sockfd); free(dtm_intranode_cb); return NCSCC_RC_FAILURE; } TRACE_LEAVE(); return NCSCC_RC_SUCCESS; }