Enable threaded async procedures whenever pthreads is available

Signed-off-by: Johannes Sixt <j6t@kdbg.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Johannes Sixt
2010-03-09 21:00:36 +01:00
committed by Junio C Hamano
parent 0ea1c89ba6
commit f6b6098316
4 changed files with 10 additions and 14 deletions

View File

@ -447,7 +447,7 @@ int run_command_v_opt_cd_env(const char **argv, int opt, const char *dir, const
return run_command(&cmd);
}
#ifdef ASYNC_AS_THREAD
#ifndef NO_PTHREADS
static pthread_t main_thread;
static int main_thread_set;
static pthread_key_t async_key;
@ -455,10 +455,10 @@ static pthread_key_t async_key;
static void *run_thread(void *data)
{
struct async *async = data;
intptr_t ret;
pthread_setspecific(async_key, async);
intptr_t ret = async->proc(async->proc_in, async->proc_out, async->data);
ret = async->proc(async->proc_in, async->proc_out, async->data);
return (void *)ret;
}
@ -521,7 +521,7 @@ int start_async(struct async *async)
else
proc_out = -1;
#ifndef ASYNC_AS_THREAD
#ifdef NO_PTHREADS
/* Flush stdio before fork() to avoid cloning buffers */
fflush(NULL);
@ -590,7 +590,7 @@ error:
int finish_async(struct async *async)
{
#ifndef ASYNC_AS_THREAD
#ifdef NO_PTHREADS
return wait_or_whine(async->pid, "child process", 0);
#else
void *ret = (void *)(intptr_t)(-1);