diff --git a/ompi/mca/osc/pt2pt/osc_pt2pt.c b/ompi/mca/osc/pt2pt/osc_pt2pt.c index 39e42bf80b..0d630a6e28 100644 --- a/ompi/mca/osc/pt2pt/osc_pt2pt.c +++ b/ompi/mca/osc/pt2pt/osc_pt2pt.c @@ -19,6 +19,7 @@ #include "osc_pt2pt.h" #include "osc_pt2pt_sendreq.h" +#include "ompi/mca/osc/base/base.h" #include "opal/runtime/opal_progress.h" #include "opal/threads/mutex.h" #include "ompi/win/win.h" @@ -32,6 +33,11 @@ ompi_osc_pt2pt_module_free(ompi_win_t *win) int ret = OMPI_SUCCESS; int tmp; ompi_osc_pt2pt_module_t *module = P2P_MODULE(win); + void *foo; + + opal_output_verbose(1, ompi_osc_base_output, + "pt2pt component destroying window with id %d", + module->p2p_comm->c_contextid); OPAL_THREAD_LOCK(&module->p2p_lock); while (OMPI_WIN_EXPOSE_EPOCH & ompi_win_get_mode(win)) { @@ -55,7 +61,7 @@ ompi_osc_pt2pt_module_free(ompi_win_t *win) #if OMPI_ENABLE_PROGRESS_THREADS mca_osc_pt2pt_component.p2p_c_thread_run = false; opal_condition_broadcast(&ompi_request_cond); - opal_thread_join(&mca_osc_pt2pt_component.p2p_c_thread, &ret); + opal_thread_join(&mca_osc_pt2pt_component.p2p_c_thread, &foo); #else opal_progress_unregister(ompi_osc_pt2pt_component_progress); #endif diff --git a/ompi/mca/osc/pt2pt/osc_pt2pt_component.c b/ompi/mca/osc/pt2pt/osc_pt2pt_component.c index c94fb639f2..74d44762b0 100644 --- a/ompi/mca/osc/pt2pt/osc_pt2pt_component.c +++ b/ompi/mca/osc/pt2pt/osc_pt2pt_component.c @@ -195,6 +195,11 @@ ompi_osc_pt2pt_component_init(bool enable_progress_threads, OBJ_CONSTRUCT(&mca_osc_pt2pt_component.p2p_c_pending_requests, opal_list_t); +#if OMPI_ENABLE_PROGRESS_THREADS + OBJ_CONSTRUCT(&mca_osc_pt2pt_component.p2p_c_thread, opal_thread_t); + mca_osc_pt2pt_component.p2p_c_thread_run = false; +#endif + return OMPI_SUCCESS; } @@ -279,6 +284,10 @@ ompi_osc_pt2pt_component_select(ompi_win_t *win, ret = ompi_comm_dup(comm, &(module->p2p_comm), 0); if (ret != OMPI_SUCCESS) goto cleanup; + opal_output_verbose(1, ompi_osc_base_output, + "pt2pt component creating window with id %d", + module->p2p_comm->c_contextid); + module->p2p_num_pending_sendreqs = (unsigned int*) malloc(sizeof(unsigned int) * ompi_comm_size(module->p2p_comm)); if (NULL == module->p2p_num_pending_sendreqs) goto cleanup; @@ -339,7 +348,6 @@ ompi_osc_pt2pt_component_select(ompi_win_t *win, module->p2p_comm->c_contextid, module); ret = opal_hash_table_get_size(&mca_osc_pt2pt_component.p2p_c_modules); - if (ret == 1) { #if OMPI_ENABLE_PROGRESS_THREADS mca_osc_pt2pt_component.p2p_c_thread_run = true; @@ -350,6 +358,7 @@ ompi_osc_pt2pt_component_select(ompi_win_t *win, ret = opal_progress_register(ompi_osc_pt2pt_component_progress); #endif } + if (OMPI_SUCCESS != ret) goto cleanup; OPAL_THREAD_UNLOCK(&mca_osc_pt2pt_component.p2p_c_lock); /* fill in window information */ @@ -382,7 +391,7 @@ ompi_osc_pt2pt_component_select(ompi_win_t *win, OPAL_THREAD_LOCK(&mca_osc_pt2pt_component.p2p_c_lock); opal_list_append(&mca_osc_pt2pt_component.p2p_c_pending_requests, &buffer->mpireq.super.super); - OPAL_THREAD_LOCK(&mca_osc_pt2pt_component.p2p_c_lock); + OPAL_THREAD_UNLOCK(&mca_osc_pt2pt_component.p2p_c_lock); return OMPI_SUCCESS; diff --git a/opal/threads/thread.c b/opal/threads/thread.c index ee82e03753..d5d7dc4009 100644 --- a/opal/threads/thread.c +++ b/opal/threads/thread.c @@ -135,6 +135,7 @@ int opal_thread_start(opal_thread_t *t) int opal_thread_join(opal_thread_t *t, void **thr_return) { int rc = pthread_join(t->t_handle, thr_return); + t->t_handle = (pthread_t) -1; return (rc == 0) ? OPAL_SUCCESS : OPAL_ERROR; } @@ -164,7 +165,7 @@ int opal_thread_start(opal_thread_t *t) int rc; if (OMPI_ENABLE_DEBUG) { - if (NULL == t->t_run || t->t_handle != (pthread_t) -1) { + if (NULL == t->t_run || t->t_handle != (thread_t) -1) { return OPAL_ERR_BAD_PARAM; } } @@ -179,6 +180,7 @@ int opal_thread_start(opal_thread_t *t) int opal_thread_join(opal_thread_t *t, void **thr_return) { int rc = thr_join(t->t_handle, NULL, thr_return); + t->t_handle = (thread_t) -1; return (rc == 0) ? OPAL_SUCCESS : OPAL_ERROR; }