Ack. -----Original Message----- From: Hieu Hong Hoang <hieu.h.ho...@dektech.com.au> Sent: Tuesday, December 20, 2022 1:25 PM To: Thang Duc Nguyen <thang.d.ngu...@dektech.com.au>; Minh Hon Chau <minh.c...@dektech.com.au>; Thien Minh Huynh <thien.m.hu...@dektech.com.au> Cc: opensaf-devel@lists.sourceforge.net; Hieu Hong Hoang <hieu.h.ho...@dektech.com.au> Subject: [PATCH 1/1] mds: Fix errors reported by valgrind [#3328]
Valgrind reports some errors while running mdstest. This ticket will fix the reported errors. --- src/mds/apitest/mdstipc.h | 1 + src/mds/apitest/mdstipc_api.c | 77 +++++++++++++++++++++++++++------- src/mds/apitest/mdstipc_conf.c | 9 ++++ src/mds/mds_c_api.c | 7 +++- src/mds/mds_svc_op.c | 7 ++-- src/mds/mds_tipc_fctrl_intf.cc | 2 +- 6 files changed, 81 insertions(+), 22 deletions(-) diff --git a/src/mds/apitest/mdstipc.h b/src/mds/apitest/mdstipc.h index d877f9a3e..a8628d707 100644 --- a/src/mds/apitest/mdstipc.h +++ b/src/mds/apitest/mdstipc.h @@ -205,6 +205,7 @@ uint32_t destroy_pwe_on_vdest(MDS_HDL); /************** USER DEFINED WRAPPERS FOR MDS SERVICE APIs **************/ uint32_t tet_create_task(NCS_OS_CB, NCSCONTEXT*); +uint32_t tet_join_task(void *task_handle); uint32_t tet_release_task(void *task_handle); uint32_t wait_adest_sel_obj(MDS_SVC_ID, int64_t); uint32_t wait_vdest_sel_obj(TET_VDEST*, MDS_SVC_ID, int64_t); diff --git a/src/mds/apitest/mdstipc_api.c b/src/mds/apitest/mdstipc_api.c index 68c5b49d9..217329b4b 100644 --- a/src/mds/apitest/mdstipc_api.c +++ b/src/mds/apitest/mdstipc_api.c @@ -6214,7 +6214,7 @@ void tet_send_response_tp_13() 1, to_svcids) == NCSCC_RC_SUCCESS) { sleep(1); - TET_MDS_MSG msg; + TET_MDS_MSG msg = {5, 0, "dump", ""}; mds_send_get_response( gl_tet_adest.mds_pwe1_hdl, NCSMDS_SVC_ID_INTERNAL_MIN, @@ -6259,7 +6259,7 @@ void tet_send_response_tp_13() osaf_clock_gettime( CLOCK_MONOTONIC, &time1); - TET_MDS_MSG msg; + TET_MDS_MSG msg = {5, 0, "dump", ""}; if (mds_send_response( gl_tet_adest.mds_pwe1_hdl, NCSMDS_SVC_ID_EXTERNAL_MIN, @@ -6293,7 +6293,7 @@ void tet_send_response_tp_13() void tet_send_response_tp_14() { - int FAIL = 1; + int FAIL = 0; mds_shutdown(); printf("\nTest Case 14: Now send_response to dead Adest don't stuck" @@ -6330,7 +6330,7 @@ void tet_send_response_tp_14() printf("\nFail\n"); FAIL = 1; } - TET_MDS_MSG msg; + TET_MDS_MSG msg = {5, 0, "dump", ""}; mds_send_get_response( gl_tet_adest.mds_pwe1_hdl, NCSMDS_SVC_ID_INTERNAL_MIN, @@ -6363,23 +6363,55 @@ void tet_send_response_tp_14() NCSMDS_SCOPE_INTRANODE, 1, to_svcids) == NCSCC_RC_SUCCESS) { - while (is_adest_sel_obj_found(0)) { - if (mds_service_retrieve( + // Retrieve the up event + if (wait_adest_sel_obj( + NCSMDS_SVC_ID_EXTERNAL_MIN, + 10)) { + printf("\nFail\n"); + FAIL = 1; + } else if (mds_service_retrieve( gl_tet_adest.mds_pwe1_hdl, NCSMDS_SVC_ID_EXTERNAL_MIN, SA_DISPATCH_ONE) - == NCSCC_RC_SUCCESS && - gl_rcvdmsginfo.msg) { - // Received the message - break; - } + != NCSCC_RC_SUCCESS) { + printf("\nFail\n"); + FAIL = 1; + } + // Retrieve the message + if (wait_adest_sel_obj( + NCSMDS_SVC_ID_EXTERNAL_MIN, + 10)) { + printf("\nFail\n"); + FAIL = 1; + } else if (mds_service_retrieve( + gl_tet_adest.mds_pwe1_hdl, + NCSMDS_SVC_ID_EXTERNAL_MIN, + SA_DISPATCH_ONE) + != NCSCC_RC_SUCCESS + || !gl_rcvdmsginfo.msg) { + printf("\nFail\n"); + FAIL = 1; + } + // Retrieve the down event + if (wait_adest_sel_obj( + NCSMDS_SVC_ID_EXTERNAL_MIN, + 10)) { + printf("\nFail\n"); + FAIL = 1; + } else if (mds_service_retrieve( + gl_tet_adest.mds_pwe1_hdl, + NCSMDS_SVC_ID_EXTERNAL_MIN, + SA_DISPATCH_ONE) + != NCSCC_RC_SUCCESS) { + printf("\nFail\n"); + FAIL = 1; } sleep(15); // Make sure the adest down // timer expires osaf_clock_gettime(CLOCK_MONOTONIC, &time1); // Send response - TET_MDS_MSG msg; + TET_MDS_MSG msg = {5, 0, "dump", ""}; if (mds_send_response( gl_tet_adest.mds_pwe1_hdl, NCSMDS_SVC_ID_EXTERNAL_MIN, @@ -6397,17 +6429,30 @@ void tet_send_response_tp_14() printf("\nResponse to" " dead Adest hang >" " 50ms"); - } else { - FAIL = 0; + FAIL = 1; } + } else { + printf("\nResponse to" + " dead Adest successful\n"); + FAIL = 1; } + } else { + printf("\nFailed to subscribe\n"); + FAIL = 1; } + } else { + printf("\nFailed to install service\n"); + FAIL = 1; } + } else { + printf("\nFailed to get the adest handle\n"); + FAIL = 1; } kill(pid, SIGKILL); mds_shutdown(); } else { printf("\nFAIL to fork()\n"); + FAIL = 1; } test_validate(FAIL, 0); } @@ -7260,9 +7305,9 @@ void tet_send_all_tp_2() printf("\nSuccess\n"); /*Now Stop and Release the Receiver Thread*/ - if (tet_release_task(gl_tet_adest.svc[1].task.t_handle) == + if (tet_join_task(gl_tet_adest.svc[1].task.t_handle) == NCSCC_RC_SUCCESS) - printf("\nTASK is released\n"); + printf("\nTASK is joined\n"); fflush(stdout); #if 0 /*SNDRACK*/ diff --git a/src/mds/apitest/mdstipc_conf.c b/src/mds/apitest/mdstipc_conf.c index 7e2f69ca0..5a0f0c9c7 100644 --- a/src/mds/apitest/mdstipc_conf.c +++ b/src/mds/apitest/mdstipc_conf.c @@ -431,6 +431,7 @@ uint32_t mds_service_install(MDS_HDL mds_hdl, MDS_SVC_ID svc_id, svc_to_mds_info.info.svc_install.i_yr_svc_hdl = gl_tet_svc.yr_svc_hdl; svc_to_mds_info.info.svc_install.i_install_scope = install_scope; svc_to_mds_info.info.svc_install.i_mds_q_ownership = mds_q_ownership; + svc_to_mds_info.info.svc_install.i_msg_loss_indication = false; if (ncsmds_api(&svc_to_mds_info) == NCSCC_RC_SUCCESS) { printf("\n %d : SERVICE INSTALL is SUCCESSFULL", svc_id); @@ -1724,6 +1725,14 @@ uint32_t tet_create_task(NCS_OS_CB task_startup, NCSCONTEXT *t_handle) return NCSCC_RC_FAILURE; } +uint32_t tet_join_task(void *task_handle) { + if (m_NCS_TASK_JOIN(task_handle) == NCSCC_RC_SUCCESS) + return NCSCC_RC_SUCCESS; + else + return NCSCC_RC_FAILURE; +} + uint32_t tet_release_task(void *task_handle) { sleep(2); diff --git a/src/mds/mds_c_api.c b/src/mds/mds_c_api.c index 86d00716f..4faa69d09 100644 --- a/src/mds/mds_c_api.c +++ b/src/mds/mds_c_api.c @@ -757,6 +757,10 @@ uint32_t mds_mcm_pwe_destroy(NCSMDS_ADMOP_INFO *info) svc_info = (MDS_SVC_INFO *)ncs_patricia_tree_getnext( &gl_mds_mcm_cb->svc_list, NULL); while (svc_info != NULL) { + MDS_SVC_INFO *next_svc_info = + (MDS_SVC_INFO *)ncs_patricia_tree_getnext( + &gl_mds_mcm_cb->svc_list, + (uint8_t *)&svc_info->svc_hdl); temp_pwe_hdl = m_MDS_GET_PWE_HDL_FROM_SVC_HDL(svc_info->svc_hdl); if (temp_pwe_hdl == @@ -769,8 +773,7 @@ uint32_t mds_mcm_pwe_destroy(NCSMDS_ADMOP_INFO *info) mds_mcm_svc_uninstall(&temp_ncsmds_info); } - svc_info = (MDS_SVC_INFO *)ncs_patricia_tree_getnext( - &gl_mds_mcm_cb->svc_list, (uint8_t *)&svc_info->svc_hdl); + svc_info = next_svc_info; } /* STEP 2: Delete entry from PWE Table */ diff --git a/src/mds/mds_svc_op.c b/src/mds/mds_svc_op.c index 2398ad63d..cf927e595 100644 --- a/src/mds/mds_svc_op.c +++ b/src/mds/mds_svc_op.c @@ -111,12 +111,11 @@ const static char * DOWN_TAG = "svc_down"; #define MDS_SVC_LOG_INFO(tag, info, format, args...) \ m_MDS_LOG_INFO("MCM:API: %s : svc_id = %s(%d)" \ - " on VDEST id = %d, svc_pvt_ver = %d : " format, \ + " on VDEST id = %d : " format, \ tag, \ get_svc_names((info)->i_svc_id), \ (info)->i_svc_id, \ m_MDS_GET_VDEST_ID_FROM_PWE_HDL(info->i_mds_hdl), \ - (info)->info.svc_install.i_mds_svc_pvt_ver, \ ##args); uint32_t mds_svc_op_install(NCSMDS_INFO *info) { @@ -241,7 +240,9 @@ uint32_t mds_svc_op_install(NCSMDS_INFO *info) { } } - MDS_SVC_LOG_INFO(INSTALL_TAG, info, "Install successfull"); + MDS_SVC_LOG_INFO(INSTALL_TAG, info, "Install successful with" + " svc_pvt_ver = %d", + info->info.svc_install.i_mds_svc_pvt_ver); m_MDS_LEAVE(); return NCSCC_RC_SUCCESS; } diff --git a/src/mds/mds_tipc_fctrl_intf.cc b/src/mds/mds_tipc_fctrl_intf.cc index 8ae39eb16..548102aa1 100644 --- a/src/mds/mds_tipc_fctrl_intf.cc +++ b/src/mds/mds_tipc_fctrl_intf.cc @@ -238,9 +238,9 @@ uint32_t process_all_events(void) { running = false; } - delete evt; portid_map_mutex.unlock(); if (!running) m_NCS_SEL_OBJ_IND(&evt->destroy_ack_obj_); + delete evt; } } // timeout, scan all portid and send ack msgs -- 2.25.1 _______________________________________________ Opensaf-devel mailing list Opensaf-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/opensaf-devel