diff --git a/opal/mca/event/libevent2019/libevent/opal_rename.h b/opal/mca/event/libevent2019/libevent/opal_rename.h index 086ad3adc2..17b1295f8a 100644 --- a/opal/mca/event/libevent2019/libevent/opal_rename.h +++ b/opal/mca/event/libevent2019/libevent/opal_rename.h @@ -193,7 +193,6 @@ extern "C" { #define event_base_got_exit opal_libevent2019_event_base_got_exit #define event_base_init_common_timeout opal_libevent2019_event_base_init_common_timeout #define event_base_loop opal_libevent2019_event_base_loop -#define event_base_loopbreak opal_libevent2019_event_base_loopbreak #define event_base_loopexit opal_libevent2019_event_base_loopexit #define event_base_new opal_libevent2019_event_base_new #define event_base_new_with_config opal_libevent2019_event_base_new_with_config diff --git a/opal/mca/event/libevent2019/libevent2019.h b/opal/mca/event/libevent2019/libevent2019.h index cda1356ca1..9154ccbb7f 100644 --- a/opal/mca/event/libevent2019/libevent2019.h +++ b/opal/mca/event/libevent2019/libevent2019.h @@ -90,6 +90,8 @@ OPAL_DECLSPEC int opal_event_init(void); #define opal_event_base_init_common_timeout (b, t) event_base_init_common_timeout((b), (t)) +#define opal_event_base_loopbreak(b) event_base_loopbreak(b) + /* Event priority APIs */ #define opal_event_base_priority_init(b, n) event_base_priority_init((b), (n)) diff --git a/orte/runtime/orte_finalize.c b/orte/runtime/orte_finalize.c index 107e15a48b..b0a3ec87b3 100644 --- a/orte/runtime/orte_finalize.c +++ b/orte/runtime/orte_finalize.c @@ -63,6 +63,18 @@ int orte_finalize(void) /* set the flag indicating we are finalizing */ orte_finalizing = true; +#if ORTE_ENABLE_PROGRESS_THREADS + /* stop the progress thread */ + orte_event_base_active = false; + /* break the event loop */ + opal_event_base_loopbreak(orte_event_base); + /* wait for thread to exit */ + opal_thread_join(&orte_progress_thread, NULL); + OBJ_DESTRUCT(&orte_progress_thread); + /* release the event base */ + opal_event_base_free(orte_event_base); +#endif + /* close the orte_show_help system */ orte_show_help_finalize(); @@ -75,7 +87,6 @@ int orte_finalize(void) /* cleanup the process info */ orte_proc_info_finalize(); -#if !ORTE_DISABLE_FULL_SUPPORT /* Free some MCA param strings */ if (NULL != orte_launch_agent) { free(orte_launch_agent); @@ -83,30 +94,12 @@ int orte_finalize(void) if( NULL != orte_default_hostfile ) { free(orte_default_hostfile); } -#if ORTE_ENABLE_PROGRESS_THREADS - if (ORTE_PROC_IS_APP) { - /* stop the progress thread */ - orte_event_base_active = false; - /* must trigger the "finalize" event to break us - * out of the event loop - */ - opal_event_active(&orte_finalize_event, OPAL_EV_WRITE, 1); - /* wait for thread to exit */ - opal_thread_join(&orte_progress_thread, NULL); - OBJ_DESTRUCT(&orte_progress_thread); - /* release the event base */ - opal_event_base_free(orte_event_base); - } -#endif -#endif /* Close the general debug stream */ opal_output_close(orte_debug_output); -#if 0 /* finalize the opal utilities */ opal_finalize(); -#endif return ORTE_SUCCESS; } diff --git a/orte/runtime/orte_init.c b/orte/runtime/orte_init.c index d9a25abffc..2874a1f64c 100644 --- a/orte/runtime/orte_init.c +++ b/orte/runtime/orte_init.c @@ -68,7 +68,7 @@ orte_process_name_t orte_name_wildcard = {ORTE_JOBID_WILDCARD, ORTE_VPID_WILDCAR orte_process_name_t orte_name_invalid = {ORTE_JOBID_INVALID, ORTE_VPID_INVALID}; -#if !ORTE_DISABLE_FULL_SUPPORT && ORTE_ENABLE_PROGRESS_THREADS +#if ORTE_ENABLE_PROGRESS_THREADS static void* orte_progress_thread_engine(opal_object_t *obj); #endif @@ -79,19 +79,6 @@ static void* orte_progress_thread_engine(opal_object_t *obj); #endif const char orte_version_string[] = ORTE_IDENT_STRING; -#if !ORTE_DISABLE_FULL_SUPPORT && ORTE_ENABLE_PROGRESS_THREADS -static void ignore_callback(int fd, short args, void *cbdata) -{ - if (NULL == cbdata) { - /* nothing to do here */ - } else { - opal_event_t *ev = (opal_event_t*)cbdata; - struct timeval tv = {1, 0}; - opal_event_evtimer_add(ev, &tv); - } -} -#endif - int orte_init(int* pargc, char*** pargv, orte_proc_type_t flags) { int ret; @@ -150,24 +137,10 @@ int orte_init(int* pargc, char*** pargv, orte_proc_type_t flags) goto error; } -#if !ORTE_DISABLE_FULL_SUPPORT && ORTE_ENABLE_PROGRESS_THREADS +#if ORTE_ENABLE_PROGRESS_THREADS #if OPAL_EVENT_HAVE_THREAD_SUPPORT /* get a separate orte event base */ orte_event_base = opal_event_base_create(); - /* setup the finalize event - we'll need it - * to break the thread out of the event lib - * when we want to stop it - */ - opal_event_set(orte_event_base, &orte_finalize_event, -1, OPAL_EV_WRITE, ignore_callback, NULL); - opal_event_set_priority(&orte_finalize_event, ORTE_ERROR_PRI); - /* construct the thread object */ - OBJ_CONSTRUCT(&orte_progress_thread, opal_thread_t); - /* fork off a thread to progress it */ - orte_progress_thread.t_run = orte_progress_thread_engine; - if (OPAL_SUCCESS != (ret = opal_thread_start(&orte_progress_thread))) { - error = "orte progress thread start"; - goto error; - } #else error = "event thread support is not configured"; ret = ORTE_ERROR; @@ -184,6 +157,18 @@ int orte_init(int* pargc, char*** pargv, orte_proc_type_t flags) goto error; } + /* start the event thread, if required */ +#if ORTE_ENABLE_PROGRESS_THREADS + /* construct the thread object */ + OBJ_CONSTRUCT(&orte_progress_thread, opal_thread_t); + /* fork off a thread to progress it */ + orte_progress_thread.t_run = orte_progress_thread_engine; + if (OPAL_SUCCESS != (ret = opal_thread_start(&orte_progress_thread))) { + error = "orte progress thread start"; + goto error; + } +#endif + /* All done */ return ORTE_SUCCESS; @@ -198,7 +183,7 @@ int orte_init(int* pargc, char*** pargv, orte_proc_type_t flags) } -#if !ORTE_DISABLE_FULL_SUPPORT && ORTE_ENABLE_PROGRESS_THREADS +#if ORTE_ENABLE_PROGRESS_THREADS static void* orte_progress_thread_engine(opal_object_t *obj) { while (orte_event_base_active) {