1
1

Instead of completely free'ing the event base, pause the PMIx progress thread before tearing down the infrastructure, and then release the event base at the end of the procedure. This allows any infrastructure objects holding events to delete them prior to free'ing the event base.

Signed-off-by: Ralph Castain <rhc@open-mpi.org>
Этот коммит содержится в:
Ralph Castain 2017-02-15 05:02:43 -08:00
родитель f7fe2f7189
Коммит 9cd7349d7c
4 изменённых файлов: 44 добавлений и 43 удалений

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

@ -459,8 +459,11 @@ PMIX_EXPORT pmix_status_t PMIx_Finalize(const pmix_info_t info[], size_t ninfo)
}
if (!pmix_globals.external_evbase) {
/* stop the progress thread */
(void)pmix_progress_thread_stop(NULL);
/* stop the progress thread, but leave the event base
* still constructed. This will allow us to safely
* tear down the infrastructure, including removal
* of any events objects may be holding */
(void)pmix_progress_thread_pause(NULL);
}
PMIX_DESTRUCT(&pmix_client_globals.myserver);
@ -472,17 +475,13 @@ PMIX_EXPORT pmix_status_t PMIx_Finalize(const pmix_info_t info[], size_t ninfo)
}
#endif
pmix_rte_finalize();
PMIX_LIST_DESTRUCT(&pmix_client_globals.pending_requests);
if (0 <= pmix_client_globals.myserver.sd) {
CLOSE_THE_SOCKET(pmix_client_globals.myserver.sd);
}
pmix_bfrop_close();
pmix_class_finalize();
pmix_rte_finalize();
return PMIX_SUCCESS;
}

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

@ -101,10 +101,8 @@ void pmix_rte_finalize(void)
much */
pmix_output_finalize();
#if 0
/* close the bfrops */
(void)pmix_mca_base_framework_close(&pmix_bfrops_base_framework);
#endif
pmix_bfrop_close();
/* clean out the globals */
PMIX_RELEASE(pmix_globals.mypeer);
@ -117,7 +115,14 @@ void pmix_rte_finalize(void)
}
PMIX_DESTRUCT(&pmix_globals.events);
#if PMIX_NO_LIB_DESTRUCTOR
pmix_cleanup();
#endif
/* now safe to release the event base */
if (!pmix_globals.external_evbase) {
(void)pmix_progress_thread_stop(NULL);
}
#if PMIX_NO_LIB_DESTRUCTOR
pmix_cleanup();
#endif
}

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

@ -227,11 +227,30 @@ PMIX_EXPORT pmix_status_t PMIx_server_init(pmix_server_module_t *module,
return PMIX_SUCCESS;
}
static void cleanup_server_state(void)
PMIX_EXPORT pmix_status_t PMIx_server_finalize(void)
{
int i;
pmix_peer_t *peer;
if (1 != pmix_globals.init_cntr) {
--pmix_globals.init_cntr;
return PMIX_SUCCESS;
}
pmix_globals.init_cntr = 0;
pmix_output_verbose(2, pmix_globals.debug_output,
"pmix:server finalize called");
if (!pmix_globals.external_evbase) {
/* stop the progress thread, but leave the event base
* still constructed. This will allow us to safely
* tear down the infrastructure, including removal
* of any events objects may be holding */
(void)pmix_progress_thread_pause(NULL);
}
pmix_ptl_base_stop_listening();
for (i=0; i < pmix_server_globals.clients.size; i++) {
if (NULL != (peer = (pmix_peer_t*)pmix_pointer_array_get_item(&pmix_server_globals.clients, i))) {
PMIX_RELEASE(peer);
@ -255,33 +274,10 @@ static void cleanup_server_state(void)
pmix_bfrop_close();
pmix_rte_finalize();
}
PMIX_EXPORT pmix_status_t PMIx_server_finalize(void)
{
if (1 != pmix_globals.init_cntr) {
--pmix_globals.init_cntr;
return PMIX_SUCCESS;
}
pmix_globals.init_cntr = 0;
pmix_output_verbose(2, pmix_globals.debug_output,
"pmix:server finalize called");
if (!pmix_globals.external_evbase) {
/* stop the progress thread */
(void)pmix_progress_thread_stop(NULL);
}
pmix_ptl_base_stop_listening();
cleanup_server_state();
pmix_output_verbose(2, pmix_globals.debug_output,
"pmix:server finalize complete");
/* finalize the class/object system */
pmix_class_finalize();
return PMIX_SUCCESS;
}

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

@ -518,17 +518,18 @@ PMIX_EXPORT pmix_status_t PMIx_tool_finalize(void)
"pmix:tool finalize sync received");
if (!pmix_globals.external_evbase) {
/* stop the progress thread */
(void)pmix_progress_thread_stop(NULL);
/* stop the progress thread, but leave the event base
* still constructed. This will allow us to safely
* tear down the infrastructure, including removal
* of any events objects may be holding */
(void)pmix_progress_thread_pause(NULL);
}
/* shutdown services */
pmix_rte_finalize();
PMIX_DESTRUCT(&pmix_client_globals.myserver);
PMIX_LIST_DESTRUCT(&pmix_client_globals.pending_requests);
pmix_class_finalize();
/* shutdown services */
pmix_rte_finalize();
return PMIX_SUCCESS;
}