Skip to content

Commit bbe90e7

Browse files
committed
Merge branch 'sb/submodule-parallel-fetch'
Simplify the two callback functions that are triggered when the child process terminates to avoid misuse of the child-process structure that has already been cleaned up. * sb/submodule-parallel-fetch: run-command: do not pass child process data into callbacks
2 parents 6dd0a37 + 2a73b3d commit bbe90e7

File tree

4 files changed

+9
-32
lines changed

4 files changed

+9
-32
lines changed

run-command.c

Lines changed: 3 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -902,35 +902,18 @@ struct parallel_processes {
902902
struct strbuf buffered_output; /* of finished children */
903903
};
904904

905-
static int default_start_failure(struct child_process *cp,
906-
struct strbuf *err,
905+
static int default_start_failure(struct strbuf *err,
907906
void *pp_cb,
908907
void *pp_task_cb)
909908
{
910-
int i;
911-
912-
strbuf_addstr(err, "Starting a child failed:");
913-
for (i = 0; cp->argv[i]; i++)
914-
strbuf_addf(err, " %s", cp->argv[i]);
915-
916909
return 0;
917910
}
918911

919912
static int default_task_finished(int result,
920-
struct child_process *cp,
921913
struct strbuf *err,
922914
void *pp_cb,
923915
void *pp_task_cb)
924916
{
925-
int i;
926-
927-
if (!result)
928-
return 0;
929-
930-
strbuf_addf(err, "A child failed with return code %d:", result);
931-
for (i = 0; cp->argv[i]; i++)
932-
strbuf_addf(err, " %s", cp->argv[i]);
933-
934917
return 0;
935918
}
936919

@@ -1048,8 +1031,7 @@ static int pp_start_one(struct parallel_processes *pp)
10481031
pp->children[i].process.no_stdin = 1;
10491032

10501033
if (start_command(&pp->children[i].process)) {
1051-
code = pp->start_failure(&pp->children[i].process,
1052-
&pp->children[i].err,
1034+
code = pp->start_failure(&pp->children[i].err,
10531035
pp->data,
10541036
&pp->children[i].data);
10551037
strbuf_addbuf(&pp->buffered_output, &pp->children[i].err);
@@ -1117,7 +1099,7 @@ static int pp_collect_finished(struct parallel_processes *pp)
11171099

11181100
code = finish_command(&pp->children[i].process);
11191101

1120-
code = pp->task_finished(code, &pp->children[i].process,
1102+
code = pp->task_finished(code,
11211103
&pp->children[i].err, pp->data,
11221104
&pp->children[i].data);
11231105

run-command.h

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -159,8 +159,7 @@ typedef int (*get_next_task_fn)(struct child_process *cp,
159159
* To send a signal to other child processes for abortion, return
160160
* the negative signal number.
161161
*/
162-
typedef int (*start_failure_fn)(struct child_process *cp,
163-
struct strbuf *err,
162+
typedef int (*start_failure_fn)(struct strbuf *err,
164163
void *pp_cb,
165164
void *pp_task_cb);
166165

@@ -179,7 +178,6 @@ typedef int (*start_failure_fn)(struct child_process *cp,
179178
* the negative signal number.
180179
*/
181180
typedef int (*task_finished_fn)(int result,
182-
struct child_process *cp,
183181
struct strbuf *err,
184182
void *pp_cb,
185183
void *pp_task_cb);
@@ -193,9 +191,8 @@ typedef int (*task_finished_fn)(int result,
193191
* (both stdout and stderr) is routed to stderr in a manner that output
194192
* from different tasks does not interleave.
195193
*
196-
* If start_failure_fn or task_finished_fn are NULL, default handlers
197-
* will be used. The default handlers will print an error message on
198-
* error without issuing an emergency stop.
194+
* start_failure_fn and task_finished_fn can be NULL to omit any
195+
* special handling.
199196
*/
200197
int run_processes_parallel(int n,
201198
get_next_task_fn,

submodule.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -705,8 +705,7 @@ static int get_next_submodule(struct child_process *cp,
705705
return 0;
706706
}
707707

708-
static int fetch_start_failure(struct child_process *cp,
709-
struct strbuf *err,
708+
static int fetch_start_failure(struct strbuf *err,
710709
void *cb, void *task_cb)
711710
{
712711
struct submodule_parallel_fetch *spf = cb;
@@ -716,8 +715,8 @@ static int fetch_start_failure(struct child_process *cp,
716715
return 0;
717716
}
718717

719-
static int fetch_finish(int retvalue, struct child_process *cp,
720-
struct strbuf *err, void *cb, void *task_cb)
718+
static int fetch_finish(int retvalue, struct strbuf *err,
719+
void *cb, void *task_cb)
721720
{
722721
struct submodule_parallel_fetch *spf = cb;
723722

test-run-command.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ static int no_job(struct child_process *cp,
4141
}
4242

4343
static int task_finished(int result,
44-
struct child_process *cp,
4544
struct strbuf *err,
4645
void *pp_cb,
4746
void *pp_task_cb)

0 commit comments

Comments
 (0)