1
1

Fix the segfault problem in the orteds - turns out it only occurred with progress threads enabled. Ensure the thread gets started at the right time (at the end of init), although the event base gets created earlier. Remove the finalize event as we can instead use the loopbreak call to exit the event loop.

This commit was SVN r27721.
Этот коммит содержится в:
Ralph Castain 2012-12-25 19:30:18 +00:00
родитель c8e34813b6
Коммит cada035f38
4 изменённых файлов: 29 добавлений и 50 удалений

Просмотреть файл

@ -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

Просмотреть файл

@ -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))

Просмотреть файл

@ -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;
}

Просмотреть файл

@ -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) {