Git development
 help / color / mirror / Atom feed
From: Alexey Nezhdanov <snake@penza-gsm.ru>
To: Linus Torvalds <torvalds@osdl.org>
Cc: git@vger.kernel.org, snake@penza-gsm.ru
Subject: [PATCH] add inetd mode to git daemon
Date: Thu, 14 Jul 2005 11:31:33 +0400	[thread overview]
Message-ID: <20050714075726.9004.qmail@penza-gsm.ru> (raw)

Adds --inetd command line argument that makes server run in inetd mode.

Signed-off-by: Alexey Nezhdanov <snake@penza-gsm.ru>
---

diff --git a/daemon.c b/daemon.c
--- a/daemon.c
+++ b/daemon.c
@@ -3,7 +3,7 @@
 #include <sys/socket.h>
 #include <netinet/in.h>
 
-static const char daemon_usage[] = "git-daemon [--port=n]";
+static const char daemon_usage[] = "git-daemon [--inetd | --port=n]";
 
 static int upload(char *dir, int dirlen)
 {
@@ -37,11 +37,21 @@ static int execute(char *line, int len)
 	return -1;
 }
 
-static void handle(int incoming, struct sockaddr_in *addr, int addrlen)
+static int handle_stdio()
 {
 	static char line[1000];
 	int len;
 
+	len = packet_read_line(0, line, sizeof(line));
+
+	if (len && line[len-1] == '\n')
+		line[--len] = 0;
+
+	return execute(line, len);
+}
+
+static void handle(int incoming, struct sockaddr_in *addr, int addrlen)
+{
 	if (fork()) {
 		close(incoming);
 		return;
@@ -50,12 +60,8 @@ static void handle(int incoming, struct 
 	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(handle_stdio());
 }
 
 static int serve(int port)
@@ -97,6 +103,7 @@ int main(int argc, char **argv)
 {
 	int port = DEFAULT_GIT_PORT;
 	int i;
+	int inetd_mode = 0;
 
 	for (i = 1; i < argc; i++) {
 		char *arg = argv[i];
@@ -110,8 +117,17 @@ int main(int argc, char **argv)
 				continue;
 			}
 		}
+
+		if (!strncmp(arg, "--inetd", 7)) {
+			inetd_mode = 1;
+			continue;
+		}
+
 		usage(daemon_usage);
 	}
 
-	return serve(port);
+	if (inetd_mode)
+		return handle_stdio();
+	else
+		return serve(port);
 }

                 reply	other threads:[~2005-07-14  7:58 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20050714075726.9004.qmail@penza-gsm.ru \
    --to=snake@penza-gsm.ru \
    --cc=git@vger.kernel.org \
    --cc=torvalds@osdl.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox