Per suggestion from George, use a pipe for terminating the thread.
Refs trac:4510 This commit was SVN r31381. The following Trac tickets were found above: Ticket 4510 --> https://svn.open-mpi.org/trac/ompi/ticket/4510
Этот коммит содержится в:
родитель
373f97cdae
Коммит
bbdbc5f8a8
@ -661,7 +661,7 @@ static void component_shutdown(void)
|
||||
if (ORTE_PROC_IS_HNP && mca_oob_tcp_component.listen_thread_active) {
|
||||
mca_oob_tcp_component.listen_thread_active = false;
|
||||
/* tell the thread to exit */
|
||||
write(mca_oob_tcp_component.stop_thread, &i, sizeof(int));
|
||||
write(mca_oob_tcp_component.stop_thread[1], &i, sizeof(int));
|
||||
opal_thread_join(&mca_oob_tcp_component.listen_thread, NULL);
|
||||
}
|
||||
|
||||
|
@ -78,7 +78,7 @@ typedef struct {
|
||||
opal_thread_t listen_thread; /**< handle to the listening thread */
|
||||
bool listen_thread_active;
|
||||
struct timeval listen_thread_tv; /**< Timeout when using listen thread */
|
||||
int stop_thread; /**< file descriptor used to exit the listen thread */
|
||||
int stop_thread[2]; /**< pipe used to exit the listen thread */
|
||||
|
||||
/* peers available via this transport - the index is the process name,
|
||||
* and the pointer returned is the pointer to the last module that
|
||||
|
@ -125,7 +125,10 @@ int orte_oob_tcp_start_listening(void)
|
||||
* harvest connection requests as rapidly as possible
|
||||
*/
|
||||
if (ORTE_PROC_IS_HNP) {
|
||||
mca_oob_tcp_component.stop_thread = open("/dev/null", O_RDWR);
|
||||
if (0 > pipe(mca_oob_tcp_component.stop_thread)) {
|
||||
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
|
||||
return ORTE_ERR_OUT_OF_RESOURCE;
|
||||
}
|
||||
mca_oob_tcp_component.listen_thread_active = true;
|
||||
mca_oob_tcp_component.listen_thread.t_run = listen_thread;
|
||||
mca_oob_tcp_component.listen_thread.t_arg = NULL;
|
||||
@ -642,8 +645,8 @@ static void* listen_thread(opal_object_t *obj)
|
||||
max = (listener->sd > max) ? listener->sd : max;
|
||||
}
|
||||
/* add the stop_thread fd */
|
||||
FD_SET(mca_oob_tcp_component.stop_thread, &readfds);
|
||||
max = (mca_oob_tcp_component.stop_thread > max) ? mca_oob_tcp_component.stop_thread : max;
|
||||
FD_SET(mca_oob_tcp_component.stop_thread[0], &readfds);
|
||||
max = (mca_oob_tcp_component.stop_thread[0] > max) ? mca_oob_tcp_component.stop_thread[0] : max;
|
||||
|
||||
/* set timeout interval */
|
||||
timeout.tv_sec = mca_oob_tcp_component.listen_thread_tv.tv_sec;
|
||||
@ -655,6 +658,8 @@ static void* listen_thread(opal_object_t *obj)
|
||||
rc = select(max + 1, &readfds, NULL, NULL, &timeout);
|
||||
if (!mca_oob_tcp_component.listen_thread_active) {
|
||||
/* we've been asked to terminate */
|
||||
close(mca_oob_tcp_component.stop_thread[0]);
|
||||
close(mca_oob_tcp_component.stop_thread[1]);
|
||||
return NULL;
|
||||
}
|
||||
if (rc < 0) {
|
||||
|
Загрузка…
x
Ссылка в новой задаче
Block a user