Hi Hans,
Removed the following changes from the patch. The problem is not
reproducible with or without IMMND restarts.
@@ -2655,12 +2655,9 @@ else (entry exists)
MDS_PROCESS_INFO *info = mds_process_info_get(adest);
if (info != NULL) {
- info->count--;
TRACE("svc %d down cnt:%d, db cnt:%d", svc_id, info->count,
mds_process_info_cnt());
- if (info->count == 0) {
- mds_process_info_del(info);
- free(info);
- }
+ mds_process_info_del(info);
+ free(info);
}
Ack from me, When the above modification is removed and pushed.
/Neel.
On Friday 29 August 2014 04:31 PM, Hans Feldt wrote:
> osaf/libs/core/mds/include/mds_core.h | 3 ++-
> osaf/libs/core/mds/mds_c_api.c | 14 ++------------
> osaf/libs/core/mds/mds_c_db.c | 35
> ++++++++++++++++++++++++++++++-----
> osaf/libs/core/mds/mds_main.c | 15 ++++++++++++---
> 4 files changed, 46 insertions(+), 21 deletions(-)
>
>
> The process_info_db needs to be available early before MDS is initialized. So
> its initialization is moved to mds_auth_server_create(). The patricia tree
> cannot be located in the control block which is dynamically created so it is
> now statically allocated.
>
> diff --git a/osaf/libs/core/mds/include/mds_core.h
> b/osaf/libs/core/mds/include/mds_core.h
> --- a/osaf/libs/core/mds/include/mds_core.h
> +++ b/osaf/libs/core/mds/include/mds_core.h
> @@ -288,7 +288,6 @@ typedef struct mds_mcm_cb {
> NCS_PATRICIA_TREE subtn_results;
> NCS_PATRICIA_TREE svc_list; /* Tree of MDS_SVC_INFO information */
> NCS_PATRICIA_TREE vdest_list; /* Tree of MDS_VDEST_INFO information */
> - NCS_PATRICIA_TREE process_info_db; /* all known local MDS dests */
> } MDS_MCM_CB;
>
> /* Global MDSCB */
> @@ -315,6 +314,8 @@ MDS_PROCESS_INFO *mds_process_info_get(M
> int mds_process_info_add(MDS_PROCESS_INFO *info);
> int mds_process_info_del(MDS_PROCESS_INFO *info);
> int mds_process_info_cnt(void);
> +int mds_process_info_db_init(void);
> +
>
> /* ******************************************** */
> /* ******************************************** */
> diff --git a/osaf/libs/core/mds/mds_c_api.c b/osaf/libs/core/mds/mds_c_api.c
> --- a/osaf/libs/core/mds/mds_c_api.c
> +++ b/osaf/libs/core/mds/mds_c_api.c
> @@ -2655,12 +2655,9 @@ else (entry exists)
>
> MDS_PROCESS_INFO *info = mds_process_info_get(adest);
> if (info != NULL) {
> - info->count--;
> TRACE("svc %d down cnt:%d, db cnt:%d", svc_id, info->count,
> mds_process_info_cnt());
> - if (info->count == 0) {
> - mds_process_info_del(info);
> - free(info);
> - }
> + mds_process_info_del(info);
> + free(info);
> }
>
> status =
> mds_svc_tbl_query(m_MDS_GET_PWE_HDL_FROM_SVC_HDL(local_svc_hdl),
> @@ -3823,13 +3820,6 @@ uint32_t mds_mcm_init(void)
>
> ncs_patricia_tree_add(&gl_mds_mcm_cb->vdest_list, (NCS_PATRICIA_NODE
> *)vdest_for_adest_node);
>
> - memset(&pat_tree_params, 0, sizeof(pat_tree_params));
> - pat_tree_params.key_size = sizeof(MDS_DEST);
> - if (NCSCC_RC_SUCCESS !=
> ncs_patricia_tree_init(&gl_mds_mcm_cb->process_info_db, &pat_tree_params)) {
> - m_MDS_LOG_ERR("MCM_API : patricia_tree_init:proc_info :failure,
> L mds_mcm_init");
> - return NCSCC_RC_FAILURE;
> - }
> -
> return NCSCC_RC_SUCCESS;
> }
>
> diff --git a/osaf/libs/core/mds/mds_c_db.c b/osaf/libs/core/mds/mds_c_db.c
> --- a/osaf/libs/core/mds/mds_c_db.c
> +++ b/osaf/libs/core/mds/mds_c_db.c
> @@ -2331,17 +2331,27 @@ uint32_t mds_subtn_res_tbl_cleanup(void)
> return NCSCC_RC_SUCCESS;
> }
>
> +/****************************************************************************/
> +/* Process info database, stores mapping between mdsdest and pid
> + * Only used by some services. Tree itself cannot be located in control block
> + * which is dynamically allocated.
> + */
> +
> +static NCS_PATRICIA_TREE process_info_db; /* all known local MDS dests */
> +
> MDS_PROCESS_INFO *mds_process_info_get(MDS_DEST mds_dest)
> {
> - return (MDS_PROCESS_INFO *)
> ncs_patricia_tree_get(&gl_mds_mcm_cb->process_info_db,
> - (uint8_t *)&mds_dest);
> + if (process_info_db.n_nodes > 0)
> + return (MDS_PROCESS_INFO *)
> ncs_patricia_tree_get(&process_info_db,
> + (uint8_t *)&mds_dest);
> + return NULL;
> }
>
> int mds_process_info_add(MDS_PROCESS_INFO *info)
> {
> TRACE_ENTER2("dest:%lx, pid:%d", info->mds_dest, info->pid);
> info->patnode.key_info = (uint8_t *)&info->mds_dest;
> - int rc = ncs_patricia_tree_add(&gl_mds_mcm_cb->process_info_db,
> + int rc = ncs_patricia_tree_add(&process_info_db,
> (NCS_PATRICIA_NODE *)&info->patnode);
> return rc;
> }
> @@ -2349,14 +2359,29 @@ int mds_process_info_add(MDS_PROCESS_INF
> int mds_process_info_del(MDS_PROCESS_INFO *info)
> {
> TRACE_ENTER2("dest:%lx, pid:%d", info->mds_dest, info->pid);
> - int rc = ncs_patricia_tree_del(&gl_mds_mcm_cb->process_info_db,
> + int rc = ncs_patricia_tree_del(&process_info_db,
> (NCS_PATRICIA_NODE *)&info->patnode);
> return rc;
> }
>
> int mds_process_info_cnt(void)
> {
> - return gl_mds_mcm_cb->process_info_db.n_nodes;
> + return process_info_db.n_nodes;
> +}
> +
> +int mds_process_info_db_init(void)
> +{
> + NCS_PATRICIA_PARAMS pat_tree_params = {0};
> +
> + /* locking not needed */
> + pat_tree_params.key_size = sizeof(MDS_DEST);
> + if (NCSCC_RC_SUCCESS != ncs_patricia_tree_init(
> + &process_info_db, &pat_tree_params)) {
> + syslog(LOG_ERR, "%s: patricia_tree_init failed", __FUNCTION__);
> + return NCSCC_RC_FAILURE;
> + }
> +
> + return NCSCC_RC_SUCCESS;
> }
>
> /*********************************************************
> diff --git a/osaf/libs/core/mds/mds_main.c b/osaf/libs/core/mds/mds_main.c
> --- a/osaf/libs/core/mds/mds_main.c
> +++ b/osaf/libs/core/mds/mds_main.c
> @@ -153,18 +153,21 @@ static void mds_register_callback(int fd
>
> osaf_mutex_lock_ordie(&gl_mds_library_mutex);
>
> - if (mds_process_info_get(mds_dest) == NULL) {
> + MDS_PROCESS_INFO *info = mds_process_info_get(mds_dest);
> + if (info == NULL) {
> MDS_PROCESS_INFO *info = malloc(sizeof(MDS_PROCESS_INFO));
> osafassert(info);
> info->mds_dest = mds_dest;
> info->uid = creds->uid;
> info->pid = creds->pid;
> info->gid = creds->gid;
> + info->count = 1;
> int rc = mds_process_info_add(info);
> osafassert(rc == NCSCC_RC_SUCCESS);
> } else {
> /* this happens in clients that uses both OM and OI */
> - TRACE("dest %lx already exist", mds_dest);
> + info->count++;
> + TRACE("dest %lx already exist, cnt:%u", mds_dest, info->count);
> }
>
> osaf_mutex_unlock_ordie(&gl_mds_library_mutex);
> @@ -188,8 +191,13 @@ static void mds_register_callback(int fd
> */
> int mds_auth_server_create(const char *name)
> {
> + if (mds_process_info_db_init() != NCSCC_RC_SUCCESS) {
> + syslog(LOG_ERR, "%s: mds_process_info_db_init failed",
> __FUNCTION__);
> + return NCSCC_RC_FAILURE;
> + }
> +
> if (osaf_auth_server_create(name, mds_register_callback) != 0) {
> - syslog(LOG_ERR, "MDS_LIB_CREATE: osaf_auth_server_create
> failed");
> + syslog(LOG_ERR, "%s: osaf_auth_server_create failed",
> __FUNCTION__);
> return NCSCC_RC_FAILURE;
> }
>
> @@ -233,6 +241,7 @@ int mds_auth_server_connect(const char *
> if (type != MDS_REGISTER_RESP) {
> TRACE_3("wrong type %d", type);
> rc = NCSCC_RC_FAILURE;
> + goto fail;
> }
> int status = ncs_decode_32bit(&p);
> TRACE("received type:%d, status:%d", type, status);
------------------------------------------------------------------------------
Slashdot TV.
Video for Nerds. Stuff that matters.
http://tv.slashdot.org/
_______________________________________________
Opensaf-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/opensaf-devel