send-pack.c: move async's #ifdef NO_PTHREADS back to run-command.c

On systems that do not support multithread, start_async() is
implemented with fork(). This implementation details unfortunately
leak out at least in send-pack.c [1].

To keep the code base clean of NO_PTHREADS, move the this #ifdef back
to run-command.c. The new wrapper function async_with_fork() at least
helps suggest that this special "close()" is related to async in fork

[1] 09c9957cf7 (send-pack: avoid deadlock when pack-object dies early
    - 2011-04-25)

Signed-off-by: Nguyễn Thái Ngọc Duy <>
Signed-off-by: Junio C Hamano <>
This commit is contained in:
Nguyễn Thái Ngọc Duy 2018-11-03 09:48:39 +01:00 committed by Junio C Hamano
parent 10bc232d0f
commit c0e40a2d66
3 changed files with 12 additions and 3 deletions

View File

@ -1246,6 +1246,15 @@ int finish_async(struct async *async)
int async_with_fork(void)
return 1;
return 0;
const char *find_hook(const char *name)
static struct strbuf path = STRBUF_INIT;

View File

@ -141,6 +141,7 @@ struct async {
int start_async(struct async *async);
int finish_async(struct async *async);
int in_async(void);
int async_with_fork(void);
void check_pipe(int err);

View File

@ -203,9 +203,8 @@ static int receive_status(int in, struct ref *refs)
static int sideband_demux(int in, int out, void *data)
int *fd = data, ret;
if (async_with_fork())
ret = recv_sideband("send-pack", fd[0], out);
return ret;