diff --git a/opal/mca/btl/tcp/btl_tcp.c b/opal/mca/btl/tcp/btl_tcp.c index 6e7e2f4e4c..0b41afa7b5 100644 --- a/opal/mca/btl/tcp/btl_tcp.c +++ b/opal/mca/btl/tcp/btl_tcp.c @@ -98,7 +98,6 @@ int mca_btl_tcp_add_procs( struct mca_btl_base_module_t* btl, tcp_endpoint = OBJ_NEW(mca_btl_tcp_endpoint_t); if(NULL == tcp_endpoint) { OPAL_THREAD_UNLOCK(&tcp_proc->proc_lock); - OBJ_RELEASE(opal_proc); return OPAL_ERR_OUT_OF_RESOURCE; } @@ -106,7 +105,6 @@ int mca_btl_tcp_add_procs( struct mca_btl_base_module_t* btl, rc = mca_btl_tcp_proc_insert(tcp_proc, tcp_endpoint); if(rc != OPAL_SUCCESS) { OPAL_THREAD_UNLOCK(&tcp_proc->proc_lock); - OBJ_RELEASE(opal_proc); OBJ_RELEASE(tcp_endpoint); continue; } diff --git a/opal/mca/btl/tcp/btl_tcp_proc.c b/opal/mca/btl/tcp/btl_tcp_proc.c index 4ae02169b0..b7a49f65bc 100644 --- a/opal/mca/btl/tcp/btl_tcp_proc.c +++ b/opal/mca/btl/tcp/btl_tcp_proc.c @@ -76,12 +76,15 @@ void mca_btl_tcp_proc_construct(mca_btl_tcp_proc_t* tcp_proc) void mca_btl_tcp_proc_destruct(mca_btl_tcp_proc_t* tcp_proc) { - /* remove from list of all proc instances */ - OPAL_THREAD_LOCK(&mca_btl_tcp_component.tcp_lock); - opal_hash_table_remove_value_uint64(&mca_btl_tcp_component.tcp_procs, - tcp_proc->proc_opal->proc_name); - OPAL_THREAD_UNLOCK(&mca_btl_tcp_component.tcp_lock); - + if( NULL != tcp_proc->proc_opal ) { + /* remove from list of all proc instances */ + OPAL_THREAD_LOCK(&mca_btl_tcp_component.tcp_lock); + opal_hash_table_remove_value_uint64(&mca_btl_tcp_component.tcp_procs, + tcp_proc->proc_opal->proc_name); + OPAL_THREAD_UNLOCK(&mca_btl_tcp_component.tcp_lock); + /* Do not OBJ_RELEASE the proc_opal ! */ + /* OBJ_RELEASE(tcp_proc->proc_opal); */ + } /* release resources */ if(NULL != tcp_proc->proc_endpoints) { free(tcp_proc->proc_endpoints); @@ -97,7 +100,7 @@ void mca_btl_tcp_proc_destruct(mca_btl_tcp_proc_t* tcp_proc) * datastructure. */ -mca_btl_tcp_proc_t* mca_btl_tcp_proc_create(const opal_proc_t* proc) +mca_btl_tcp_proc_t* mca_btl_tcp_proc_create(opal_proc_t* proc) { uint64_t hash = proc->proc_name; mca_btl_tcp_proc_t* btl_proc; @@ -116,6 +119,7 @@ mca_btl_tcp_proc_t* mca_btl_tcp_proc_create(const opal_proc_t* proc) if(NULL == btl_proc) return NULL; btl_proc->proc_opal = proc; + OBJ_RETAIN(btl_proc->proc_opal); /* add to hash table of all proc instance */ opal_hash_table_set_value_uint64(&mca_btl_tcp_component.tcp_procs, @@ -683,7 +687,7 @@ int mca_btl_tcp_proc_insert( mca_btl_tcp_proc_t* btl_proc, * Remove an endpoint from the proc array and indicate the address is * no longer in use. */ - + int mca_btl_tcp_proc_remove(mca_btl_tcp_proc_t* btl_proc, mca_btl_base_endpoint_t* btl_endpoint) { size_t i; diff --git a/opal/mca/btl/tcp/btl_tcp_proc.h b/opal/mca/btl/tcp/btl_tcp_proc.h index 9e5c13b4c7..14548386dc 100644 --- a/opal/mca/btl/tcp/btl_tcp_proc.h +++ b/opal/mca/btl/tcp/btl_tcp_proc.h @@ -38,7 +38,7 @@ struct mca_btl_tcp_proc_t { opal_list_item_t super; /**< allow proc to be placed on a list */ - const opal_proc_t *proc_opal; + opal_proc_t *proc_opal; /**< pointer to corresponding opal_proc_t */ struct mca_btl_tcp_addr_t* proc_addrs; @@ -104,7 +104,7 @@ enum mca_btl_tcp_connection_quality { }; -mca_btl_tcp_proc_t* mca_btl_tcp_proc_create(const opal_proc_t* proc); +mca_btl_tcp_proc_t* mca_btl_tcp_proc_create(opal_proc_t* proc); mca_btl_tcp_proc_t* mca_btl_tcp_proc_lookup(const opal_process_name_t* name); int mca_btl_tcp_proc_insert(mca_btl_tcp_proc_t*, mca_btl_base_endpoint_t*); int mca_btl_tcp_proc_remove(mca_btl_tcp_proc_t*, mca_btl_base_endpoint_t*);