aboutsummaryrefslogtreecommitdiff
path: root/daemon.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@g5.osdl.org>2005-07-15 09:27:05 -0700
committerLinus Torvalds <torvalds@g5.osdl.org>2005-07-15 09:27:05 -0700
commit7d80694af1a68ee1915e36bad9b26fa9fe054f06 (patch)
tree3a3d0d7cc4f7449950ee1d13845893a348411be8 /daemon.c
parente68b6f1525c670f474d735009fec419473df0962 (diff)
downloadgit-7d80694af1a68ee1915e36bad9b26fa9fe054f06.tar.gz
git-7d80694af1a68ee1915e36bad9b26fa9fe054f06.tar.xz
git-daemon: re-organize code a bit for --inetd flag
Alexey Nezhdanov sent a patch that made git-daemon usable from inetd (ie where inetd has already done the accept on the new connection, the fork, and the setup of stdin/stdout). I wanted to organize the thing slightly differently, though.
Diffstat (limited to 'daemon.c')
-rw-r--r--daemon.c20
1 files changed, 10 insertions, 10 deletions
diff --git a/daemon.c b/daemon.c
index 315a74bf1..c5a46b73f 100644
--- a/daemon.c
+++ b/daemon.c
@@ -28,8 +28,16 @@ static int upload(char *dir, int dirlen)
return -1;
}
-static int execute(char *line, int len)
+static int execute(void)
{
+ static char line[1000];
+ int len;
+
+ len = packet_read_line(0, line, sizeof(line));
+
+ if (len && line[len-1] == '\n')
+ line[--len] = 0;
+
if (!strncmp("git-upload-pack /", line, 17))
return upload(line + 16, len - 16);
@@ -39,9 +47,6 @@ static int execute(char *line, int len)
static void handle(int incoming, struct sockaddr_in *addr, int addrlen)
{
- static char line[1000];
- int len;
-
if (fork()) {
close(incoming);
return;
@@ -50,12 +55,7 @@ static void handle(int incoming, struct sockaddr_in *addr, int addrlen)
dup2(incoming, 0);
dup2(incoming, 1);
close(incoming);
- len = packet_read_line(0, line, sizeof(line));
-
- if (len && line[len-1] == '\n')
- line[--len] = 0;
-
- exit(execute(line, len));
+ exit(execute());
}
static int serve(int port)