From 0dc2499fea2e5aac4044a63fc68608134f112c0b Mon Sep 17 00:00:00 2001
From: Danny Auble <da@schedmd.com>
Date: Fri, 2 Dec 2011 10:09:43 -0800
Subject: [PATCH] BGQ - fixed ending of message thread in a way that made srun
 not lock up.

---
 src/srun/srun.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/src/srun/srun.c b/src/srun/srun.c
index 3b4adfede69..947d66daf32 100644
--- a/src/srun/srun.c
+++ b/src/srun/srun.c
@@ -488,7 +488,7 @@ int srun(int ac, char **av)
 	_send_step_complete_rpc(global_rc);
 	if (msg_thread) {
 		srun_shutdown = true;
-		pthread_kill(msg_thread, SIGINT);
+		pthread_cancel(msg_thread);
 		pthread_join(msg_thread, NULL);
 	}
 #else
@@ -1123,6 +1123,9 @@ static void *_msg_thr_internal(void *arg)
 	slurm_msg_t *msg;
 	int *slurmctld_fd_ptr = (int *)arg;
 
+	(void) pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL);
+	(void) pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, NULL);
+
 	while (!srun_shutdown) {
 		newsockfd = slurm_accept_msg_conn(*slurmctld_fd_ptr, &cli_addr);
 		if (newsockfd == SLURM_SOCKET_ERROR) {
-- 
GitLab