@@ -56,7 +56,11 @@ struct exec_ctx {
5656
5757static void exec_ctx_destroy (struct exec_ctx * tc )
5858{
59- free (tc );
59+ if (tc ) {
60+ int saved_errno = errno ;
61+ free (tc );
62+ errno = saved_errno ;
63+ }
6064}
6165
6266static struct exec_ctx * exec_ctx_create (json_t * jobspec )
@@ -84,27 +88,6 @@ static void start_cb (struct bulk_exec *exec, void *arg)
8488{
8589 struct jobinfo * job = arg ;
8690 jobinfo_started (job );
87- /* This is going to be really slow. However, it should at least
88- * work for now. We wait for all imp's to start, then send input
89- */
90- if (job -> multiuser && !config_use_imp_helper ()) {
91- char * input = NULL ;
92- json_t * o = json_pack ("{s:s}" , "J" , job -> J );
93- if (!o || !(input = json_dumps (o , JSON_COMPACT ))) {
94- jobinfo_fatal_error (job , errno , "Failed to get input to IMP" );
95- goto out ;
96- }
97- if (bulk_exec_write (exec , "stdin" , input , strlen (input )) < 0 )
98- jobinfo_fatal_error (job ,
99- errno ,
100- "Failed to write %ld bytes input to IMP" ,
101- strlen (input ));
102- (void ) bulk_exec_close (exec , "stdin" );
103- out :
104- json_decref (o );
105- free (input );
106- }
107-
10891}
10992
11093static void complete_cb (struct bulk_exec * exec , void * arg )
@@ -118,13 +101,11 @@ static void complete_cb (struct bulk_exec *exec, void *arg)
118101static int exec_barrier_enter (struct bulk_exec * exec )
119102{
120103 struct exec_ctx * ctx = bulk_exec_aux_get (exec , "ctx" );
121- const char * stream = config_use_imp_helper () ?
122- "stdin" :
123- "FLUX_EXEC_PROTOCOL_FD" ;
104+
124105 if (!ctx )
125106 return -1 ;
126107 if (++ ctx -> barrier_enter_count == bulk_exec_total (exec )) {
127- if (bulk_exec_write (exec , stream , "exit=0\n" , 7 ) < 0 )
108+ if (bulk_exec_write (exec , "stdin" , "exit=0\n" , 7 ) < 0 )
128109 return -1 ;
129110 ctx -> barrier_enter_count = 0 ;
130111 ctx -> barrier_completion_count ++ ;
@@ -136,7 +117,7 @@ static int exec_barrier_enter (struct bulk_exec *exec)
136117 * case where a shell exits while a barrier is already in progress
137118 * is handled in exit_cb().
138119 */
139- if (bulk_exec_write (exec , stream , "exit=1\n" , 7 ) < 0 )
120+ if (bulk_exec_write (exec , "stdin" , "exit=1\n" , 7 ) < 0 )
140121 return -1 ;
141122 }
142123 return 0 ;
@@ -151,8 +132,7 @@ static void output_cb (struct bulk_exec *exec, flux_subprocess_t *p,
151132 struct jobinfo * job = arg ;
152133 const char * cmd = flux_cmd_arg (flux_subprocess_get_cmd (p ), 0 );
153134
154- if (streq (stream , "FLUX_EXEC_PROTOCOL_FD" )
155- || (config_use_imp_helper () && streq (stream , "stdout" ))) {
135+ if (streq (stream , "stdout" )) {
156136 if (streq (data , "enter\n" )
157137 && exec_barrier_enter (exec ) < 0 ) {
158138 jobinfo_fatal_error (job ,
@@ -292,10 +272,7 @@ static void exit_cb (struct bulk_exec *exec,
292272 */
293273 if (ctx -> barrier_completion_count == 0
294274 || ctx -> barrier_enter_count > 0 ) {
295- const char * stream = config_use_imp_helper () ?
296- "stdin" :
297- "FLUX_EXEC_PROTOCOL_FD" ;
298- if (bulk_exec_write (exec , stream , "exit=1\n" , 7 ) < 0 )
275+ if (bulk_exec_write (exec , "stdin" , "exit=1\n" , 7 ) < 0 )
299276 jobinfo_fatal_error (job , 0 ,
300277 "failed to terminate barrier: %s" ,
301278 strerror (errno ));
@@ -338,6 +315,7 @@ static int exec_init (struct jobinfo *job)
338315 }
339316 if (bulk_exec_aux_set (exec , "ctx" , ctx ,
340317 (flux_free_f ) exec_ctx_destroy ) < 0 ) {
318+ exec_ctx_destroy (ctx );
341319 flux_log_error (job -> h , "exec_init: bulk_exec_aux_set" );
342320 goto err ;
343321 }
@@ -350,12 +328,11 @@ static int exec_init (struct jobinfo *job)
350328 goto err ;
351329 }
352330 if (job -> multiuser ) {
353- if (config_use_imp_helper ()
354- && flux_cmd_setenvf (cmd ,
355- 1 ,
356- "FLUX_IMP_EXEC_HELPER" ,
357- "flux imp-exec-helper %ju" ,
358- (uintmax_t ) job -> id ) < 0 ) {
331+ if (flux_cmd_setenvf (cmd ,
332+ 1 ,
333+ "FLUX_IMP_EXEC_HELPER" ,
334+ "flux imp-exec-helper %ju" ,
335+ (uintmax_t ) job -> id ) < 0 ) {
359336 flux_log_error (job -> h , "exec_init: flux_cmd_setenvf" );
360337 goto err ;
361338 }
@@ -370,19 +347,6 @@ static int exec_init (struct jobinfo *job)
370347 flux_log_error (job -> h , "exec_init: flux_cmd_argv_append" );
371348 goto err ;
372349 }
373-
374- /* If more than one shell is involved in this job, set up a channel
375- * for exec system based barrier:
376- */
377- if (idset_count (ranks ) > 1 && !config_use_imp_helper ()) {
378- if (flux_cmd_add_channel (cmd , "FLUX_EXEC_PROTOCOL_FD" ) < 0
379- || flux_cmd_setopt (cmd ,
380- "FLUX_EXEC_PROTOCOL_FD_LINE_BUFFER" ,
381- "true" ) < 0 ) {
382- flux_log_error (job -> h , "exec_init: flux_cmd_add_channel" );
383- goto err ;
384- }
385- }
386350 if (bulk_exec_push_cmd (exec , ranks , cmd , 0 ) < 0 ) {
387351 flux_log_error (job -> h , "exec_init: bulk_exec_push_cmd" );
388352 goto err ;
0 commit comments