void saClmFinalize_03(void) { safassert(saClmInitialize(&clmHandle, &clmCallbacks_1, &clmVersion_1), SA_AIS_OK); safassert(saClmFinalize(clmHandle), SA_AIS_OK); rc = saClmFinalize(clmHandle); test_validate(rc, SA_AIS_ERR_BAD_HANDLE); }
void saClmFinalize_01(void) { safassert(saClmInitialize(&clmHandle, &clmCallbacks_1, &clmVersion_1), SA_AIS_OK); rc = saClmFinalize(clmHandle); test_validate(rc, SA_AIS_OK); safassert(saClmInitialize_4(&clmHandle, &clmCallbacks_4, &clmVersion_4), SA_AIS_OK); rc = saClmFinalize(clmHandle); test_validate(rc, SA_AIS_OK); }
/** * smfnd_up * @param i_node_id Clm node id * @param i_smfnd_dest Destination to Clm node */ uns32 smfnd_up(SaClmNodeIdT i_node_id, MDS_DEST i_smfnd_dest) { SaAisErrorT rc; SaClmHandleT clmHandle; SmfndNodeT *smfnd = NULL; TRACE("SMFND UP for node id %x", i_node_id); /* Find Clm info about the node */ rc = saClmInitialize(&clmHandle, NULL, &clmVersion); if (rc != SA_AIS_OK) { LOG_ER("saClmInitialize failed %d", rc); return NCSCC_RC_FAILURE; } /* Make shure the node id does not already exists */ smfnd = get_smfnd(i_node_id); if (smfnd != NULL) { LOG_ER("smfnd already exists %x", i_node_id); return NCSCC_RC_FAILURE; } /* Does not exists, create a new cleared structure */ smfnd = calloc(1, sizeof(SmfndNodeT)); if (smfnd == NULL) { LOG_ER("alloc failed"); return NCSCC_RC_FAILURE; } /* Get Clm info about the node */ rc = saClmClusterNodeGet(clmHandle, i_node_id, 10000000000LL, &smfnd->clmInfo); if (rc != SA_AIS_OK) { LOG_ER("saClmClusterNodeGet failed %d", rc); free(smfnd); return NCSCC_RC_FAILURE; } rc = saClmFinalize(clmHandle); if (rc != SA_AIS_OK) { LOG_ER("saClmFinalize failed %d", rc); free(smfnd); return NCSCC_RC_FAILURE; } /* Make shure the name string is null terminated */ smfnd->clmInfo.nodeName.value[smfnd->clmInfo.nodeName.length] = 0; /* Store the destination to the smfnd */ smfnd->dest = i_smfnd_dest; /* Store the node info in the smfnd list */ smfnd->next = firstSmfnd; firstSmfnd = smfnd; TRACE("SMFND added for node name %s, id %x", smfnd->clmInfo.nodeName.value, smfnd->clmInfo.nodeId); return NCSCC_RC_SUCCESS; }
/**************************************************************************** * Name : eds_se_lib_destroy * * Description : Invoked to destroy the EDS * * * Arguments : * Return Values : NCSCC_RC_SUCCESS/NCSCC_RC_FAILURE.. * * Notes : None. *****************************************************************************/ static uint32_t eds_se_lib_destroy(NCS_LIB_REQ_INFO *req_info) { /** Code to destroy the EDS **/ EDS_CB *eds_cb; m_INIT_CRITICAL; TRACE_ENTER(); if (NULL == (eds_cb = (NCSCONTEXT)ncshm_take_hdl(NCS_SERVICE_ID_EDS, gl_eds_hdl))) { LOG_ER("Handle take failed for global handle"); TRACE_LEAVE(); return (NCSCC_RC_FAILURE); } else { m_START_CRITICAL; /** Lock EDA_CB **/ m_NCS_LOCK(&eds_cb->cb_lock, NCS_LOCK_WRITE); /* deregister from AMF */ saAmfComponentUnregister(eds_cb->amf_hdl, &eds_cb->comp_name, NULL); /* End association from the AMF lib */ saAmfFinalize(eds_cb->amf_hdl); /* Finalize with CLM */ saClmFinalize(eds_cb->clm_hdl); /* Clean up all internal structures */ eds_remove_reglist_entry(eds_cb, 0, true); /* Destroy the cb */ eds_cb_destroy(eds_cb); /* Give back the handle */ ncshm_give_hdl(gl_eds_hdl); ncshm_destroy_hdl(NCS_SERVICE_ID_GLD, gl_eds_hdl); /* Detach from IPC */ m_NCS_IPC_DETACH(&eds_cb->mbx, eds_clear_mbx, eds_cb); /* Disconnect from MDS */ eds_mds_finalize(eds_cb); /* Release the IPC */ m_NCS_IPC_RELEASE(&eds_cb->mbx, NULL); /** UnLock EDA_CB **/ m_NCS_UNLOCK(&eds_cb->cb_lock, NCS_LOCK_WRITE); m_NCS_LOCK_DESTROY(&eds_cb->cb_lock); m_MMGR_FREE_EDS_CB(eds_cb); gl_eds_hdl = 0; m_END_CRITICAL; TRACE("eds-cb-lib destroy done ."); } TRACE_LEAVE(); return (NCSCC_RC_SUCCESS); }
void saftest_daemon_handle_session_finalize_request( saftest_map_table_entry_t *map_entry, saftest_msg_t *request, saftest_msg_t **reply) { clm_session_t *clm_session = NULL; SaAisErrorT status; saftest_log("Received a finalize request for id %d\n", saftest_msg_get_ubit32_value(request, "CLM_SESSION_ID")); clm_session = lookup_clm_session_from_request(request); status = saClmFinalize(clm_session->clm_handle); clm_session->selection_object = 0; clm_session->clm_handle = 0; (*reply) = saftest_reply_msg_create(request, map_entry->reply_op, status); }
int ast_ais_clm_unload_module(void) { SaAisErrorT ais_res; if (clm_init_res != SA_AIS_OK) { return 0; } ast_cli_unregister_multiple(ais_cli, ARRAY_LEN(ais_cli)); ais_res = saClmFinalize(clm_handle); if (ais_res != SA_AIS_OK) { ast_log(LOG_ERROR, "Problem stopping cluster membership service: %s\n", ais_err2str(ais_res)); return -1; } return 0; }
void saClmClusterTrackStop_01(void) { trackFlags = SA_TRACK_CURRENT; nodeId = 131343; invocation = 600; safassert(saClmInitialize(&clmHandle, &clmCallback11, &clmVersion_1), SA_AIS_OK); rc = saClmClusterTrack(clmHandle, trackFlags, NULL); rc = saClmClusterTrack(clmHandle, trackFlags, NULL); rc = saClmClusterNodeGetAsync(clmHandle, invocation, nodeId); rc = saClmClusterTrack(clmHandle, trackFlags, NULL); rc = saClmClusterNodeGetAsync(clmHandle, invocation, nodeId); rc = saClmClusterNodeGetAsync(clmHandle, invocation, nodeId); rc = saClmClusterTrack(clmHandle, trackFlags, NULL); safassert(saClmClusterTrackStop(clmHandle), SA_AIS_OK); safassert(saClmDispatch(clmHandle,SA_DISPATCH_ALL), SA_AIS_OK); rc = saClmClusterTrack(clmHandle, trackFlags, NULL); safassert(saClmClusterTrackStop(clmHandle), SA_AIS_OK); safassert(saClmFinalize(clmHandle), SA_AIS_OK); test_validate(rc, SA_AIS_OK); }
void saClmFinalize_02(void) { rc = saClmFinalize(-1); test_validate(rc, SA_AIS_ERR_BAD_HANDLE); }
static void test_clm_during_cpg_test(void) { SaClmHandleT clmHandle = { 0 }; SaAisErrorT err; SaClmCallbacksT callbacks = { .saClmClusterNodeGetCallback = _clm_nodeget_callback, .saClmClusterTrackCallback = _clm_nodetrack_callback, }; SaVersionT version = { .releaseCode = 'B', .majorVersion = 1, .minorVersion = 1 }; SaClmClusterNodeT node; int status = 0; pid_t r; while ( (err = saClmInitialize(&clmHandle, &callbacks, &version)) == SA_AIS_ERR_TRY_AGAIN ); if ( err != SA_AIS_OK ) DIE("saClmInitialize(): %d", err); if ( (err = saClmClusterNodeGet(clmHandle, SA_CLM_LOCAL_NODE_ID, 1000000, &node)) != SA_AIS_OK ) DIE("saClmNodeGet(): %d", err); test_data.node_id = node.nodeId; DPRINTF("We are '%.*s', ID: %d", node.nodeName.length, node.nodeName.value, node.nodeId); if ( (err = saClmClusterTrack(clmHandle, SA_TRACK_CURRENT | SA_TRACK_CHANGES, NULL)) != SA_AIS_OK ) DIE("saClmClusterTrack(): %d", err); r = 0; status = 0; /* Note: The man pages of FreeBSD says that waitpid() should return 0 if no process has ended * but I get 1 instead. Weird. * TODO(Jflesch): Figure out what I did wrong. */ while ( test_data.keep_dispatching && (test_data.test_cpg_pid == -1 || ( (r = waitpid(test_data.test_cpg_pid, &status, WNOHANG) != -1) && (r == 0 || r == 1 || (!WIFEXITED(status) && !WIFSIGNALED(status))) ) ) ) { if ( (err = saClmDispatch(clmHandle, SA_DISPATCH_ALL)) != SA_AIS_OK ) DIE("saClmDispatch(): %d", err); if ( test_data.nmb_peers == test_data.max_nmb_peers ) { if ( test_data.master_id != test_data.node_id ) { DPRINTF("Synchronized."); /* -> we are a slave, the only thing we have to do is run CPG tests again */ test_data.keep_dispatching = 0; test_data.run_cpg_test = 1; } else if ( test_data.test_cpg_pid == -1 ) { DPRINTF("Synchronized."); test_data.nmb_clm_notifications = 0; DPRINTF("(master) Running CPG tests ..."); test_data.test_cpg_pid = start_cpg_tests(); /* // */ DPRINTF("(master) CPG tests started"); } } usleep(10 * 1000); /* 10ms */ } if ( test_data.keep_dispatching ) /* => end of test */ { if ( test_data.test_cpg_pid < 0 ) DIE("CPG tests not even started"); if ( r <= -1 ) DIE("waitpid() failed: %d, %s", errno, strerror(errno)); if ( WIFSIGNALED(status) ) DIE("CPG tests died because of signal %d", WTERMSIG(status)); if ( WEXITSTATUS(status) != 0 ) DIE("CPG tests died returning the value %d", WEXITSTATUS(status)); } #ifdef BE_NICE if ( (err = saClmClusterTrackStop(clmHandle)) != SA_AIS_OK ) DIE("saClmTrackStop(): %d", err); #endif if ( (err = saClmFinalize(clmHandle)) != SA_AIS_OK ) DIE("saClmFinalize(): %d", err); if ( test_data.nmb_clm_notifications <= 0 ) DIE("Got no CLM notifications"); if ( test_data.run_cpg_test ) { DPRINTF("(slave) Running CPG tests ..."); test_cpg_multiplayer(test_data.max_nmb_peers); DPRINTF("(slave) CPG test finished"); } } void test_clm(int nmb_peers) { if ( nmb_peers <= 1 ) DIE("Not enought peers"); test_data = TEST_DATA_START_VALUE; test_data.max_nmb_peers = nmb_peers; DPRINTF(" - Rerun of the CPG multiplayer test, keeping an eye on CLM behavior"); test_clm_during_cpg_test(); /* DPRINTF(" - Misuse of the API"); ? */ }