* [PATCH 0/4] Minor git-daemon enhancements
@ 2005-09-24 14:12 Petr Baudis
2005-09-24 14:12 ` [PATCH 1/4] Fix git-daemon's pid_t logging Petr Baudis
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: Petr Baudis @ 2005-09-24 14:12 UTC (permalink / raw
To: Junio C Hamano; +Cc: git
The following series contains some minor git-daemon enhancements,
based on the input from the mailing list.
And I'm also playing with StGIT. ;-)
--
And on the eigth day, God started debugging.
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 1/4] Fix git-daemon's pid_t logging
2005-09-24 14:12 [PATCH 0/4] Minor git-daemon enhancements Petr Baudis
@ 2005-09-24 14:12 ` Petr Baudis
2005-09-24 14:12 ` [PATCH 2/4] Update git-daemon documentation wrt. the --verbose parameter Petr Baudis
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Petr Baudis @ 2005-09-24 14:12 UTC (permalink / raw
To: Junio C Hamano; +Cc: git
git-daemon's logging code did not properly printf() pid_t - we need
to explicitly typecast it, since it might not be int. Pointed out
by Morten Welinder.
Signed-off-by: Petr Baudis <pasky@suse.cz>
---
daemon.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/daemon.c b/daemon.c
--- a/daemon.c
+++ b/daemon.c
@@ -22,7 +22,7 @@ static void logreport(const char *err, v
int maxlen, msglen;
/* sizeof(buf) should be big enough for "[pid] \n" */
- buflen = snprintf(buf, sizeof(buf), "[%d] ", getpid());
+ buflen = snprintf(buf, sizeof(buf), "[%ld] ", (long) getpid());
maxlen = sizeof(buf) - buflen - 1; /* -1 for our own LF */
msglen = vsnprintf(buf + buflen, maxlen, err, params);
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 2/4] Update git-daemon documentation wrt. the --verbose parameter
2005-09-24 14:12 [PATCH 0/4] Minor git-daemon enhancements Petr Baudis
2005-09-24 14:12 ` [PATCH 1/4] Fix git-daemon's pid_t logging Petr Baudis
@ 2005-09-24 14:12 ` Petr Baudis
2005-09-24 14:13 ` [PATCH 3/4] git-daemon --syslog to log through syslog Petr Baudis
2005-09-24 14:13 ` [PATCH 4/4] Rename daemon.c's lognotice() to loginfo() Petr Baudis
3 siblings, 0 replies; 5+ messages in thread
From: Petr Baudis @ 2005-09-24 14:12 UTC (permalink / raw
To: Junio C Hamano; +Cc: git
Signed-off-by: Petr Baudis <pasky@suse.cz>
---
Documentation/git-daemon.txt | 5 ++++-
1 files changed, 4 insertions(+), 1 deletions(-)
diff --git a/Documentation/git-daemon.txt b/Documentation/git-daemon.txt
--- a/Documentation/git-daemon.txt
+++ b/Documentation/git-daemon.txt
@@ -7,7 +7,7 @@ git-daemon - A really simple server for
SYNOPSIS
--------
-'git-daemon' [--inetd | --port=n]
+'git-daemon' [--verbose] [--inetd | --port=n]
DESCRIPTION
-----------
@@ -32,6 +32,9 @@ OPTIONS
--port::
Listen on an alternative port.
+--verbose::
+ Log details about the incoming connections and requested files.
+
Author
------
Written by Linus Torvalds <torvalds@osdl.org> and YOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org>
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 3/4] git-daemon --syslog to log through syslog
2005-09-24 14:12 [PATCH 0/4] Minor git-daemon enhancements Petr Baudis
2005-09-24 14:12 ` [PATCH 1/4] Fix git-daemon's pid_t logging Petr Baudis
2005-09-24 14:12 ` [PATCH 2/4] Update git-daemon documentation wrt. the --verbose parameter Petr Baudis
@ 2005-09-24 14:13 ` Petr Baudis
2005-09-24 14:13 ` [PATCH 4/4] Rename daemon.c's lognotice() to loginfo() Petr Baudis
3 siblings, 0 replies; 5+ messages in thread
From: Petr Baudis @ 2005-09-24 14:13 UTC (permalink / raw
To: Junio C Hamano; +Cc: git
Well, this makes it even more clear that we need the packet reader and
friends to use the daemon logging code. :/ Therefore, we at least indicate
in the "Disconnect" log message if the child process exitted with an error
code or not.
Idea by Linus.
Signed-off-by: Petr Baudis <pasky@suse.cz>
---
Documentation/git-daemon.txt | 6 +++++-
daemon.c | 34 +++++++++++++++++++++++++++-------
2 files changed, 32 insertions(+), 8 deletions(-)
diff --git a/Documentation/git-daemon.txt b/Documentation/git-daemon.txt
--- a/Documentation/git-daemon.txt
+++ b/Documentation/git-daemon.txt
@@ -7,7 +7,7 @@ git-daemon - A really simple server for
SYNOPSIS
--------
-'git-daemon' [--verbose] [--inetd | --port=n]
+'git-daemon' [--verbose] [--syslog] [--inetd | --port=n]
DESCRIPTION
-----------
@@ -32,6 +32,10 @@ OPTIONS
--port::
Listen on an alternative port.
+--syslog::
+ Log to syslog instead of stderr. Note that this option does not imply
+ --verbose, thus by default only error conditions will be logged.
+
--verbose::
Log details about the incoming connections and requested files.
diff --git a/daemon.c b/daemon.c
--- a/daemon.c
+++ b/daemon.c
@@ -7,13 +7,15 @@
#include <netdb.h>
#include <netinet/in.h>
#include <arpa/inet.h>
+#include <syslog.h>
+static int log_syslog;
static int verbose;
-static const char daemon_usage[] = "git-daemon [--verbose] [--inetd | --port=n]";
+static const char daemon_usage[] = "git-daemon [--verbose] [--syslog] [--inetd | --port=n]";
-static void logreport(const char *err, va_list params)
+static void logreport(int priority, const char *err, va_list params)
{
/* We should do a single write so that it is atomic and output
* of several processes do not get intermingled. */
@@ -27,6 +29,11 @@ static void logreport(const char *err, v
maxlen = sizeof(buf) - buflen - 1; /* -1 for our own LF */
msglen = vsnprintf(buf + buflen, maxlen, err, params);
+ if (log_syslog) {
+ syslog(priority, "%s", buf);
+ return;
+ }
+
/* maxlen counted our own LF but also counts space given to
* vsnprintf for the terminating NUL. We want to make sure that
* we have space for our own LF and NUL after the "meat" of the
@@ -48,7 +55,7 @@ void logerror(const char *err, ...)
{
va_list params;
va_start(params, err);
- logreport(err, params);
+ logreport(LOG_ERR, err, params);
va_end(params);
}
@@ -58,7 +65,7 @@ void lognotice(const char *err, ...)
if (!verbose)
return;
va_start(params, err);
- logreport(err, params);
+ logreport(LOG_INFO, err, params);
va_end(params);
}
@@ -285,15 +292,23 @@ static void handle(int incoming, struct
static void child_handler(int signo)
{
for (;;) {
- pid_t pid = waitpid(-1, NULL, WNOHANG);
+ int status;
+ pid_t pid = waitpid(-1, &status, WNOHANG);
if (pid > 0) {
unsigned reaped = children_reaped;
dead_child[reaped % MAX_CHILDREN] = pid;
children_reaped = reaped + 1;
/* XXX: Custom logging, since we don't wanna getpid() */
- if (verbose)
- fprintf(stderr, "[%d] Disconnected\n", pid);
+ if (verbose) {
+ char *dead = "";
+ if (!WIFEXITED(status) || WEXITSTATUS(status) > 0)
+ dead = " (with error)";
+ if (log_syslog)
+ syslog(LOG_INFO, "[%d] Disconnected%s", pid, dead);
+ else
+ fprintf(stderr, "[%d] Disconnected%s\n", pid, dead);
+ }
continue;
}
break;
@@ -435,6 +450,11 @@ int main(int argc, char **argv)
verbose = 1;
continue;
}
+ if (!strcmp(arg, "--syslog")) {
+ log_syslog = 1;
+ openlog("git-daemon", 0, LOG_DAEMON);
+ continue;
+ }
usage(daemon_usage);
}
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 4/4] Rename daemon.c's lognotice() to loginfo()
2005-09-24 14:12 [PATCH 0/4] Minor git-daemon enhancements Petr Baudis
` (2 preceding siblings ...)
2005-09-24 14:13 ` [PATCH 3/4] git-daemon --syslog to log through syslog Petr Baudis
@ 2005-09-24 14:13 ` Petr Baudis
3 siblings, 0 replies; 5+ messages in thread
From: Petr Baudis @ 2005-09-24 14:13 UTC (permalink / raw
To: Junio C Hamano; +Cc: git
The syslog code logs with severity LOG_INFO in the loginfo() function, so make
things less confusing.
Signed-off-by: Petr Baudis <pasky@suse.cz>
---
daemon.c | 6 +++---
1 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/daemon.c b/daemon.c
--- a/daemon.c
+++ b/daemon.c
@@ -59,7 +59,7 @@ void logerror(const char *err, ...)
va_end(params);
}
-void lognotice(const char *err, ...)
+void loginfo(const char *err, ...)
{
va_list params;
if (!verbose)
@@ -72,7 +72,7 @@ void lognotice(const char *err, ...)
static int upload(char *dir, int dirlen)
{
- lognotice("Request for '%s'", dir);
+ loginfo("Request for '%s'", dir);
if (chdir(dir) < 0) {
logerror("Cannot chdir('%s'): %s", dir, strerror(errno));
return -1;
@@ -284,7 +284,7 @@ static void handle(int incoming, struct
port = sin6_addr->sin6_port;
}
- lognotice("Connection from %s:%d", addrbuf, port);
+ loginfo("Connection from %s:%d", addrbuf, port);
exit(execute());
}
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2005-09-24 14:13 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-09-24 14:12 [PATCH 0/4] Minor git-daemon enhancements Petr Baudis
2005-09-24 14:12 ` [PATCH 1/4] Fix git-daemon's pid_t logging Petr Baudis
2005-09-24 14:12 ` [PATCH 2/4] Update git-daemon documentation wrt. the --verbose parameter Petr Baudis
2005-09-24 14:13 ` [PATCH 3/4] git-daemon --syslog to log through syslog Petr Baudis
2005-09-24 14:13 ` [PATCH 4/4] Rename daemon.c's lognotice() to loginfo() Petr Baudis
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).