[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

[RFC] Make svnserve require --inetd to use stdin/stdout

From: Tobias Ringström <tobias_at_ringstrom.mine.nu>
Date: 2004-01-03 17:16:25 CET

I'd like to make svserve require an -i/--inetd option in order to use
stdin/stdout. The default mode would simply be to print an error and a
nice usage message. I believe that most people who run svnserve really
intend to use the -d or -t options, and that it's better to be helpful
to them than to make the (as I believe) less common inetd mode the default.

I also threw in a little less controversion change, namely a
-F/--foreground option which makes svnserve stay in the foreground,
which is very useful for debugging, especially together with -T. The -X
option is next to useless, because most operations makes more than one
connection to the server which failes because -X only serves one.

This change breaks compatibility for inetd users of course. It's easy
to fix, of course.

What do you think?

[Another way would be to add daemon/inetd/tunnel/listen_once subcommands
to svnserve instead of options, but that would be much more disruptive.]


--------------------------- log message -------------------------------
Make svnserve show an error message and usage if it is run without any
arguments. Add a new -i/--inet option to make svnserve use
stdin/stdout (which was the old default). Add a new -F/--foreground
option to prevent svnserve from daemonizing (which is useful for

* subversion/svnserve/main.c

   (run_mode): New enum.

   (svnserve__options): Add -i/--inetd and -F/--foreground.

   (main): Use run_mode instead of several booleans. Show error message
   and usage if no mode is selected. Handle the new inetd and
   foreground options.

* subversion/svnserve/svnserve.8

   Updated to match the changes to subversion/svnserve/main.c.

Index: subversion/svnserve/svnserve.8
--- subversion/svnserve/svnserve.8 (revision 8142)
+++ subversion/svnserve/svnserve.8 (working copy)
@@ -9,16 +9,15 @@
 \fBsvnserve\fP [\fIoptions\fP]
 \fBsvnserve\fP allows access to Subversion repositories using the svn
-network protocol. By default, \fBsvnserve\fP serves a single
-connection using the stdin/stdout file descriptors, as is appropriate
-for a daemon running out of inetd, but this mode of operation can be
-altered by options. \fBsvnserve\FP accepts the following options:
+network protocol. It can both run as a standalone server process, or
+it can run out of inetd. You must choose a mode of operation when you
+start \fBsvnserve\fP. The following options are recognized:
 .TP 5
 \fB\-d\fP, \fB\-\-daemon\fP
 Causes \fBsvnserve\fP to run in daemon mode. \fBsvnserve\fP
-backgrounds itself and accepts and serves connections on the svn port
-(3690, by default).
+backgrounds itself and accepts and serves TCP/IP connections on the
+svn port (3690, by default).
 .TP 5
@@ -30,6 +29,17 @@
 which may be either a hostname or an IP address.
 .TP 5
+\fB\-F\fP, \fB\-\-foreground\fP
+When used together with \fB\-d\fP, this option causes \fBsvnserve\fP
+to stay in the foreground. This option is mainly useful for
+.TP 5
+\fB\-i\fP, \fB\-\-inetd\fP
+Causes \fBsvnserve\fP to use the stdin/stdout file descriptors, as is
+appropriate for a daemon running out of inetd.
+.TP 5
 \fB\-h\fP, \fB\-\-help\fP
 Displays a usage summary and exits.
@@ -42,7 +52,7 @@
 .TP 5
 \fB\-t\fP, \fB\-\-tunnel\fP
 Causes \fBsvnserve\fP to run in tunnel mode, which is just like the
-default mode of operation (serve one connection over stdin/stdout)
+inetd mode of operation (serve one connection over stdin/stdout)
 except that the connection is considered to be pre-authenticated with
 the username of the current uid. This flag is selected by the client
 when running over a tunnel agent.
Index: subversion/svnserve/main.c
--- subversion/svnserve/main.c (revision 8142)
+++ subversion/svnserve/main.c (working copy)
@@ -48,6 +48,15 @@
   connection_mode_single /* One connection at a time in this process */
+/* The mode in which to run svnserve */
+enum run_mode {
+ run_mode_none,
+ run_mode_inetd,
+ run_mode_daemon,
+ run_mode_tunnel,
+ run_mode_listen_once,
@@ -90,6 +99,8 @@
     {"listen-host", SVNSERVE_OPT_LISTEN_HOST, 1,
      "listen hostname or IP address (for daemon mode)"},
     {"help", 'h', 0, "display this help"},
+ {"inetd", 'i', 0, "inetd mode"},
+ {"foreground", 'F', 0, "foreground mode (useful for debugging)"},
     {"root", 'r', 1, "root of directory to serve"},
     {"read-only", 'R', 0, "deprecated; use repository config file"},
     {"tunnel", 't', 0, "tunnel mode"},
@@ -172,8 +183,8 @@
 int main(int argc, const char *const *argv)
- svn_boolean_t listen_once = FALSE, daemon_mode = FALSE, tunnel_mode = FALSE;
- svn_boolean_t read_only = FALSE;
+ enum run_mode run_mode = run_mode_none;
+ svn_boolean_t read_only = FALSE, foreground = FALSE;
   apr_socket_t *sock, *usock;
   apr_file_t *in_file, *out_file;
   apr_sockaddr_t *sa;
@@ -219,9 +230,17 @@
         case 'd':
- daemon_mode = TRUE;
+ run_mode = run_mode_daemon;
+ case 'F':
+ foreground = TRUE;
+ break;
+ case 'i':
+ run_mode = run_mode_inetd;
+ break;
           port = atoi(arg);
@@ -231,11 +250,11 @@
         case 't':
- tunnel_mode = TRUE;
+ run_mode = run_mode_tunnel;
         case 'X':
- listen_once = TRUE;
+ run_mode = run_mode_listen_once;
         case 'r':
@@ -263,14 +282,21 @@
   if (os->ind != argc)
- if (!daemon_mode && !listen_once)
+ if (run_mode == run_mode_none)
+ fprintf(stdout, "You must specify one of -d, -i, -t and -X!\n");
+ usage(argv[0]);
+ }
+ if (run_mode == run_mode_inetd || run_mode == run_mode_tunnel)
+ {
       apr_pool_cleanup_register(pool, pool, apr_pool_cleanup_null,
       apr_file_open_stdin(&in_file, pool);
       apr_file_open_stdout(&out_file, pool);
       conn = svn_ra_svn_create_conn(NULL, in_file, out_file, pool);
- svn_error_clear(serve(conn, root, tunnel_mode, read_only, pool));
+ svn_error_clear(serve(conn, root, run_mode == run_mode_tunnel,
+ read_only, pool));
@@ -304,7 +330,7 @@
   apr_socket_listen(sock, 7);
- if (!listen_once)
+ if (run_mode != run_mode_listen_once && !foreground)
   apr_signal(SIGCHLD, sigchld_handler);
@@ -344,12 +370,11 @@
       conn = svn_ra_svn_create_conn(usock, NULL, NULL, connection_pool);
- if (listen_once)
+ if (run_mode == run_mode_listen_once)
           err = serve(conn, root, FALSE, read_only, connection_pool);
- if (listen_once && err
- && err->apr_err != SVN_ERR_RA_SVN_CONNECTION_CLOSED)
+ if (err && err->apr_err != SVN_ERR_RA_SVN_CONNECTION_CLOSED)
             svn_handle_error(err, stdout, FALSE);

To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Sat Jan 3 17:17:04 2004

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.