From 8d3055e3e7e0610fcbb95aa2e6662ccdf9cd4b66 Mon Sep 17 00:00:00 2001 From: Tim Woodall Date: Fri, 3 Sep 2004 00:06:57 +0000 Subject: [PATCH] re-order event library init/cleanup to handle a cleanup issue on threaded build (at least this seems to fix it on my box :-) ) This commit was SVN r2459. --- src/mca/ptl/tcp/src/ptl_tcp_component.c | 11 +---------- src/runtime/ompi_rte_finalize.c | 6 +++++- src/runtime/ompi_rte_init.c | 9 +++++++++ 3 files changed, 15 insertions(+), 11 deletions(-) diff --git a/src/mca/ptl/tcp/src/ptl_tcp_component.c b/src/mca/ptl/tcp/src/ptl_tcp_component.c index 7176759186..3e7db0d6bc 100644 --- a/src/mca/ptl/tcp/src/ptl_tcp_component.c +++ b/src/mca/ptl/tcp/src/ptl_tcp_component.c @@ -173,7 +173,7 @@ int mca_ptl_tcp_component_close(void) ompi_event_del(&mca_ptl_tcp_component.tcp_recv_event); close(mca_ptl_tcp_component.tcp_listen_sd); } - return ompi_event_fini(); + return OMPI_SUCCESS; } @@ -387,15 +387,6 @@ mca_ptl_base_module_t** mca_ptl_tcp_component_init(int *num_ptl_modules, *allow_multi_user_threads = true; *have_hidden_threads = OMPI_HAVE_THREADS; - /* need to set ompi_using_threads() as ompi_event_init() will spawn a thread if supported */ - if(OMPI_HAVE_THREADS) - ompi_set_using_threads(true); - - if((rc = ompi_event_init()) != OMPI_SUCCESS) { - ompi_output(0, "mca_ptl_tcp_component_init: unable to initialize event dispatch thread: %d\n", rc); - return NULL; - } - ompi_free_list_init(&mca_ptl_tcp_component.tcp_send_frags, sizeof(mca_ptl_tcp_send_frag_t), OBJ_CLASS(mca_ptl_tcp_send_frag_t), diff --git a/src/runtime/ompi_rte_finalize.c b/src/runtime/ompi_rte_finalize.c index 90ad633601..aed27f2913 100644 --- a/src/runtime/ompi_rte_finalize.c +++ b/src/runtime/ompi_rte_finalize.c @@ -8,6 +8,7 @@ #include "include/constants.h" #include "runtime/runtime.h" +#include "event/event.h" #include "util/output.h" #include "util/proc_info.h" #include "threads/mutex.h" @@ -29,11 +30,14 @@ int ompi_rte_finalize(void) { ompi_rte_unregister(); - mca_oob_base_close(); + + /* cleanup the event processing thread first - before doing any other cleanup */ + ompi_event_fini(); mca_pcm_base_close(); mca_llm_base_close(); mca_pcmclient_base_close(); mca_ns_base_close(); + mca_oob_base_close(); ompi_session_dir_finalize(); diff --git a/src/runtime/ompi_rte_init.c b/src/runtime/ompi_rte_init.c index df41147059..038d8e3f32 100644 --- a/src/runtime/ompi_rte_init.c +++ b/src/runtime/ompi_rte_init.c @@ -10,6 +10,7 @@ #include "include/constants.h" #include "runtime/runtime.h" +#include "event/event.h" #include "util/output.h" #include "threads/mutex.h" #include "mca/mca.h" @@ -103,6 +104,14 @@ int ompi_rte_init(bool *allow_multi_user_threads, bool *have_hidden_threads) ret = mca_base_param_register_int("ompi", "rte", "debug", NULL, 0); mca_base_param_lookup_int(ret, &ompi_rte_debug_flag); + /* + * Initialize the event library + */ + if (OMPI_SUCCESS != (ret = ompi_event_init())) { + ompi_output(0, "ompi_rte_init: ompi_event_init failed with error status: %d\n", ret); + return ret; + } + /* * Out of Band Messaging */