From b3f54249961aff63b18085a608b1dadab5c2f5e0 Mon Sep 17 00:00:00 2001
From: tewk <tewk@unknown>
Date: Thu, 1 Aug 2002 21:08:04 +0000
Subject: [PATCH] Added pipe cleanup code

---
 src/slurmd/io.c       | 3 +++
 src/slurmd/pipes.c    | 7 +++++++
 src/slurmd/pipes.h    | 1 +
 src/slurmd/slurmd.c   | 3 ++-
 src/slurmd/task_mgr.c | 3 ++-
 5 files changed, 15 insertions(+), 2 deletions(-)

diff --git a/src/slurmd/io.c b/src/slurmd/io.c
index aab682844fd..2179048acf6 100644
--- a/src/slurmd/io.c
+++ b/src/slurmd/io.c
@@ -169,6 +169,7 @@ void * stdin_io_pipe_thread ( void * arg )
 	}
 	stdin_return:
 	free_circular_buffer ( cir_buf ) ;
+	close ( task_start->pipes[CHILD_IN_WR] ) ;
 	pthread_exit ( NULL ) ;
 }
 
@@ -263,6 +264,7 @@ void * stdout_io_pipe_thread ( void * arg )
 	stdout_return:
 	free_circular_buffer ( cir_buf ) ;
 	slurm_close_stream ( task_start->sockets[STDIN_OUT_SOCK] ) ;
+	close ( task_start->pipes[CHILD_OUT_RD] ) ;
 	pthread_exit ( NULL ) ; 
 }
 
@@ -364,6 +366,7 @@ void * stderr_io_pipe_thread ( void * arg )
 	stderr_return:
 	free_circular_buffer ( cir_buf ) ;
 	slurm_close_stream ( task_start->sockets[SIG_STDERR_SOCK] ) ;
+	close ( task_start->pipes[CHILD_ERR_RD] ) ;
 	pthread_exit ( NULL ) ; 
 }
 
diff --git a/src/slurmd/pipes.c b/src/slurmd/pipes.c
index 00a8a4982b3..ab4ec75544c 100644
--- a/src/slurmd/pipes.c
+++ b/src/slurmd/pipes.c
@@ -12,6 +12,13 @@ void setup_parent_pipes ( int * pipes )
 	close ( pipes[CHILD_ERR_WR] ) ;
 }
 
+void cleanup_parent_pipes ( int * pipes )
+{
+	close ( pipes[CHILD_IN_WR] ) ;
+	close ( pipes[CHILD_OUT_RD] ) ;
+	close ( pipes[CHILD_ERR_RD] ) ;
+}
+
 int init_parent_pipes ( int * pipes )
 {
 	int rc ;
diff --git a/src/slurmd/pipes.h b/src/slurmd/pipes.h
index 017b1a8b011..055d5c66c30 100644
--- a/src/slurmd/pipes.h
+++ b/src/slurmd/pipes.h
@@ -5,6 +5,7 @@
 int init_parent_pipes ( int * pipes ) ;
 void setup_parent_pipes ( int * pipes ) ; 
 int setup_child_pipes ( int * pipes ) ;
+void cleanup_parent_pipes ( int * pipes ) ;
 
 #endif
 
diff --git a/src/slurmd/slurmd.c b/src/slurmd/slurmd.c
index 9f459a92940..f7c98ff7c92 100644
--- a/src/slurmd/slurmd.c
+++ b/src/slurmd/slurmd.c
@@ -134,7 +134,7 @@ int slurmd_init ( )
 	shmem_seg = get_shmem ( ) ;
 	init_shmem ( shmem_seg ) ;
 	slurm_ssl_init ( ) ;
-	slurm_init_verifier ( & verify_ctx , "pub_key_file" ) ;
+	slurm_init_verifier ( & verify_ctx , "public.cert" ) ;
 	initialize_credential_state_list ( & credential_state_list ) ;
 	return SLURM_SUCCESS ;
 }
@@ -241,6 +241,7 @@ int slurmd_msg_engine ( void * args )
 			service_connection ( ( void * ) conn_arg ) ;
 		}
 	}			
+	slurm_shutdown_msg_engine ( sockfd ) ;
 	return 0 ;
 }
 
diff --git a/src/slurmd/task_mgr.c b/src/slurmd/task_mgr.c
index 60c4417bae4..63a1813e519 100644
--- a/src/slurmd/task_mgr.c
+++ b/src/slurmd/task_mgr.c
@@ -126,7 +126,6 @@ void * task_exec_thread ( void * arg )
 
 	/* create pipes to read child stdin, stdout, sterr */
 	init_parent_pipes ( task_start->pipes ) ;
-	forward_io ( arg ) ;
 
 #define FORK_ERROR -1
 #define CHILD_PROCCESS 0
@@ -191,7 +190,9 @@ void * task_exec_thread ( void * arg )
 		default: /*parent proccess */
 			task_start->exec_pid = cpid ;
 			setup_parent_pipes ( task_start->pipes ) ;
+	forward_io ( arg ) ;
 			waitpid ( cpid , & task_return_code , 0 ) ;
+			cleanup_parent_pipes (  task_start->pipes ) ;
 			send_task_exit_msg ( task_return_code , task_start ) ;
 			break;
 	}
-- 
GitLab