path: root/remote-curl.c
diff options
authorErik Faye-Lund <>2010-02-05 20:57:38 (GMT)
committerJunio C Hamano <>2010-02-06 04:57:22 (GMT)
commitae6a5609c025d9ac79e54a3a052704e25d885314 (patch)
treec74d50beebc5c7bfe2f5ca9e335c45c534243af7 /remote-curl.c
parent4f41b611481bad08319966f7787fc7c4c7bfaa52 (diff)
run-command: support custom fd-set in async
This patch adds the possibility to supply a set of non-0 file descriptors for async process communication instead of the default-created pipe. Additionally, we now support bi-directional communiction with the async procedure, by giving the async function both read and write file descriptors. To retain compatiblity and similar "API feel" with start_command, we require start_async callers to set .out = -1 to get a readable file descriptor. If either of .in or .out is 0, we supply no file descriptor to the async process. [sp: Note: Erik started this patch, and a huge bulk of it is his work. All bugs were introduced later by Shawn.] Signed-off-by: Erik Faye-Lund <> Signed-off-by: Shawn O. Pearce <> Signed-off-by: Junio C Hamano <>
Diffstat (limited to 'remote-curl.c')
1 files changed, 4 insertions, 3 deletions
diff --git a/remote-curl.c b/remote-curl.c
index 3edbf57..6bb3366 100644
--- a/remote-curl.c
+++ b/remote-curl.c
@@ -184,13 +184,13 @@ static struct discovery* discover_refs(const char *service)
return last;
-static int write_discovery(int fd, void *data)
+static int write_discovery(int in, int out, void *data)
struct discovery *heads = data;
int err = 0;
- if (write_in_full(fd, heads->buf, heads->len) != heads->len)
+ if (write_in_full(out, heads->buf, heads->len) != heads->len)
err = 1;
- close(fd);
+ close(out);
return err;
@@ -202,6 +202,7 @@ static struct ref *parse_git_refs(struct discovery *heads)
memset(&async, 0, sizeof(async));
async.proc = write_discovery; = heads;
+ async.out = -1;
if (start_async(&async))
die("cannot start thread to parse advertised refs");