made the "max connections" and "lock file" local rather than global
authorAndrew Tridgell <tridge@samba.org>
Fri, 8 Jan 1999 07:51:25 +0000 (07:51 +0000)
committerAndrew Tridgell <tridge@samba.org>
Fri, 8 Jan 1999 07:51:25 +0000 (07:51 +0000)
options so you can set them on a per-module basis (requested by
kernel.org mirror maintiner)

clientserver.c
loadparm.c
rsync.h
rsyncd.conf.yo

index b474568..49928d5 100644 (file)
@@ -138,16 +138,16 @@ static int rsync_module(int fd, int i)
                return -1;
        }
 
                return -1;
        }
 
-       if (!claim_connection(lp_lock_file(), lp_max_connections())) {
+       if (!claim_connection(lp_lock_file(i), lp_max_connections(i))) {
                if (errno) {
                        rprintf(FERROR,"failed to open lock file %s : %s\n",
                if (errno) {
                        rprintf(FERROR,"failed to open lock file %s : %s\n",
-                               lp_lock_file(), strerror(errno));
+                               lp_lock_file(i), strerror(errno));
                        io_printf(fd,"@ERROR: failed to open lock file %s : %s\n",
                        io_printf(fd,"@ERROR: failed to open lock file %s : %s\n",
-                                 lp_lock_file(), strerror(errno));
+                                 lp_lock_file(i), strerror(errno));
                } else {
                        rprintf(FERROR,"max connections (%d) reached\n",
                } else {
                        rprintf(FERROR,"max connections (%d) reached\n",
-                               lp_max_connections());
-                       io_printf(fd,"@ERROR: max connections (%d) reached - try again later\n", lp_max_connections());
+                               lp_max_connections(i));
+                       io_printf(fd,"@ERROR: max connections (%d) reached - try again later\n", lp_max_connections(i));
                }
                return -1;
        }
                }
                return -1;
        }
index 8bd5cf2..9b28c3b 100644 (file)
@@ -97,11 +97,9 @@ static BOOL bLoaded = False;
 typedef struct
 {
        char *motd_file;
 typedef struct
 {
        char *motd_file;
-       char *lock_file;
        char *log_file;
        char *pid_file;
        int syslog_facility;
        char *log_file;
        char *pid_file;
        int syslog_facility;
-       int max_connections;
        char *socket_options;
 } global;
 
        char *socket_options;
 } global;
 
@@ -117,6 +115,7 @@ typedef struct
        char *name;
        char *path;
        char *comment;
        char *name;
        char *path;
        char *comment;
+       char *lock_file;
        BOOL read_only;
        BOOL list;
        BOOL use_chroot;
        BOOL read_only;
        BOOL list;
        BOOL use_chroot;
@@ -135,6 +134,7 @@ typedef struct
        char *refuse_options;
        char *dont_compress;
        int timeout;
        char *refuse_options;
        char *dont_compress;
        int timeout;
+       int max_connections;
 } service;
 
 
 } service;
 
 
@@ -144,6 +144,7 @@ static service sDefault =
        NULL,    /* name */
        NULL,    /* path */
        NULL,    /* comment */
        NULL,    /* name */
        NULL,    /* path */
        NULL,    /* comment */
+       DEFAULT_LOCK_FILE,    /* lock file */
        True,    /* read only */
        True,    /* list */
        True,    /* use chroot */
        True,    /* read only */
        True,    /* list */
        True,    /* use chroot */
@@ -161,7 +162,8 @@ static service sDefault =
        "%o %h [%a] %m (%u) %f %l",    /* log format */
        NULL,    /* refuse options */
        "*.gz *.tgz *.zip *.z *.rpm *.deb",    /* dont compress */
        "%o %h [%a] %m (%u) %f %l",    /* log format */
        NULL,    /* refuse options */
        "*.gz *.tgz *.zip *.z *.rpm *.deb",    /* dont compress */
-       0        /* timeout */
+       0,        /* timeout */
+       0        /* max connections */
 };
 
 
 };
 
 
@@ -244,17 +246,17 @@ static struct enum_list enum_facilities[] = {
 /* note that we do not initialise the defaults union - it is not allowed in ANSI C */
 static struct parm_struct parm_table[] =
 {
 /* note that we do not initialise the defaults union - it is not allowed in ANSI C */
 static struct parm_struct parm_table[] =
 {
-  {"max connections",  P_INTEGER, P_GLOBAL, &Globals.max_connections,NULL, 0},
   {"motd file",        P_STRING,  P_GLOBAL, &Globals.motd_file,    NULL,   0},
   {"motd file",        P_STRING,  P_GLOBAL, &Globals.motd_file,    NULL,   0},
-  {"lock file",        P_STRING,  P_GLOBAL, &Globals.lock_file,    NULL,   0},
   {"syslog facility",  P_ENUM,    P_GLOBAL, &Globals.syslog_facility, enum_facilities,0},
   {"socket options",   P_STRING,  P_GLOBAL, &Globals.socket_options,NULL,  0},
   {"log file",         P_STRING,  P_GLOBAL, &Globals.log_file,      NULL,  0},
   {"pid file",         P_STRING,  P_GLOBAL, &Globals.pid_file,      NULL,  0},
 
   {"timeout",          P_INTEGER, P_LOCAL,  &sDefault.timeout,     NULL,  0},
   {"syslog facility",  P_ENUM,    P_GLOBAL, &Globals.syslog_facility, enum_facilities,0},
   {"socket options",   P_STRING,  P_GLOBAL, &Globals.socket_options,NULL,  0},
   {"log file",         P_STRING,  P_GLOBAL, &Globals.log_file,      NULL,  0},
   {"pid file",         P_STRING,  P_GLOBAL, &Globals.pid_file,      NULL,  0},
 
   {"timeout",          P_INTEGER, P_LOCAL,  &sDefault.timeout,     NULL,  0},
+  {"max connections",  P_INTEGER, P_LOCAL,  &sDefault.max_connections,NULL, 0},
   {"name",             P_STRING,  P_LOCAL,  &sDefault.name,        NULL,   0},
   {"comment",          P_STRING,  P_LOCAL,  &sDefault.comment,     NULL,   0},
   {"name",             P_STRING,  P_LOCAL,  &sDefault.name,        NULL,   0},
   {"comment",          P_STRING,  P_LOCAL,  &sDefault.comment,     NULL,   0},
+  {"lock file",        P_STRING,  P_LOCAL,  &sDefault.lock_file,   NULL,   0},
   {"path",             P_STRING,  P_LOCAL,  &sDefault.path,        NULL,   0},
   {"read only",        P_BOOL,    P_LOCAL,  &sDefault.read_only,   NULL,   0},
   {"list",             P_BOOL,    P_LOCAL,  &sDefault.list,        NULL,   0},
   {"path",             P_STRING,  P_LOCAL,  &sDefault.path,        NULL,   0},
   {"read only",        P_BOOL,    P_LOCAL,  &sDefault.read_only,   NULL,   0},
   {"list",             P_BOOL,    P_LOCAL,  &sDefault.list,        NULL,   0},
@@ -286,7 +288,6 @@ static void init_globals(void)
 #ifdef LOG_DAEMON
        Globals.syslog_facility = LOG_DAEMON;
 #endif
 #ifdef LOG_DAEMON
        Globals.syslog_facility = LOG_DAEMON;
 #endif
-       Globals.lock_file = "/var/run/rsyncd.lock";
 }
 
 /***************************************************************************
 }
 
 /***************************************************************************
@@ -322,16 +323,15 @@ static void init_locals(void)
 
 
 FN_GLOBAL_STRING(lp_motd_file, &Globals.motd_file)
 
 
 FN_GLOBAL_STRING(lp_motd_file, &Globals.motd_file)
-FN_GLOBAL_STRING(lp_lock_file, &Globals.lock_file)
 FN_GLOBAL_STRING(lp_log_file, &Globals.log_file)
 FN_GLOBAL_STRING(lp_pid_file, &Globals.pid_file)
 FN_GLOBAL_STRING(lp_socket_options, &Globals.socket_options)
 FN_GLOBAL_STRING(lp_log_file, &Globals.log_file)
 FN_GLOBAL_STRING(lp_pid_file, &Globals.pid_file)
 FN_GLOBAL_STRING(lp_socket_options, &Globals.socket_options)
-FN_GLOBAL_INTEGER(lp_max_connections, &Globals.max_connections)
 FN_GLOBAL_INTEGER(lp_syslog_facility, &Globals.syslog_facility)
 
 FN_LOCAL_STRING(lp_name, name)
 FN_LOCAL_STRING(lp_comment, comment)
 FN_LOCAL_STRING(lp_path, path)
 FN_GLOBAL_INTEGER(lp_syslog_facility, &Globals.syslog_facility)
 
 FN_LOCAL_STRING(lp_name, name)
 FN_LOCAL_STRING(lp_comment, comment)
 FN_LOCAL_STRING(lp_path, path)
+FN_LOCAL_STRING(lp_lock_file, lock_file)
 FN_LOCAL_BOOL(lp_read_only, read_only)
 FN_LOCAL_BOOL(lp_list, list)
 FN_LOCAL_BOOL(lp_use_chroot, use_chroot)
 FN_LOCAL_BOOL(lp_read_only, read_only)
 FN_LOCAL_BOOL(lp_list, list)
 FN_LOCAL_BOOL(lp_use_chroot, use_chroot)
@@ -350,6 +350,7 @@ FN_LOCAL_STRING(lp_log_format, log_format)
 FN_LOCAL_STRING(lp_refuse_options, refuse_options)
 FN_LOCAL_STRING(lp_dont_compress, dont_compress)
 FN_LOCAL_INTEGER(lp_timeout, timeout)
 FN_LOCAL_STRING(lp_refuse_options, refuse_options)
 FN_LOCAL_STRING(lp_dont_compress, dont_compress)
 FN_LOCAL_INTEGER(lp_timeout, timeout)
+FN_LOCAL_INTEGER(lp_max_connections, max_connections)
 
 /* local prototypes */
 static int    strwicmp( char *psz1, char *psz2 );
 
 /* local prototypes */
 static int    strwicmp( char *psz1, char *psz2 );
diff --git a/rsync.h b/rsync.h
index af76aac..d24cdf7 100644 (file)
--- a/rsync.h
+++ b/rsync.h
@@ -23,6 +23,7 @@
 #define RSYNC_NAME "rsync"
 #define RSYNCD_CONF "/etc/rsyncd.conf"
 
 #define RSYNC_NAME "rsync"
 #define RSYNCD_CONF "/etc/rsyncd.conf"
 
+#define DEFAULT_LOCK_FILE "/var/run/rsyncd.lock"
 #define URL_PREFIX "rsync://"
 
 #define BACKUP_SUFFIX "~"
 #define URL_PREFIX "rsync://"
 
 #define BACKUP_SUFFIX "~"
index 8e2ca39..dae328e 100644 (file)
@@ -80,17 +80,6 @@ dit(bf(motd file)) The "motd file" option allows you to specify a
 usually contains site information and any legal notices. The default
 is no motd file.
 
 usually contains site information and any legal notices. The default
 is no motd file.
 
-dit(bf(max connections)) The "max connections" option allows you to
-specify the maximum number of simultaneous connections you will allow
-to your rsync server. Any clients connecting when the maximum has
-been reached will receive a message telling them to try later. 
-The default is 0 which means no limit.
-
-dit(bf(lock file)) The "lock file" option specifies the file to use to
-support the "max connections" option. The rsync server uses record
-locking on this file to ensure that the max connections limit is not
-exceeded. The default is tt(/var/run/rsyncd.lock).
-
 dit(bf(log file)) The "log file" option tells the rsync daemon to log
 messages to that file rather than using syslog. This is particularly
 useful on systems (such as AIX) where syslog() doesn't work for
 dit(bf(log file)) The "log file" option tells the rsync daemon to log
 messages to that file rather than using syslog. This is particularly
 useful on systems (such as AIX) where syslog() doesn't work for
@@ -141,6 +130,17 @@ holes, but it has the disadvantages of requiring super-user privileges and
 of not being able to follow symbolic links outside of the new root path.
 The default is to use chroot.
 
 of not being able to follow symbolic links outside of the new root path.
 The default is to use chroot.
 
+dit(bf(max connections)) The "max connections" option allows you to
+specify the maximum number of simultaneous connections you will allow
+to this module of your rsync server. Any clients connecting when the
+maximum has been reached will receive a message telling them to try
+later.  The default is 0 which means no limit.
+
+dit(bf(lock file)) The "lock file" option specifies the file to use to
+support the "max connections" option. The rsync server uses record
+locking on this file to ensure that the max connections limit is not
+exceeded. The default is tt(/var/run/rsyncd.lock).
+
 dit(bf(read only)) The "read only" option determines whether clients
 will be able to upload files or not. If "read only" is true then any
 attempted uploads will fail. If "read only" is false then uploads will
 dit(bf(read only)) The "read only" option determines whether clients
 will be able to upload files or not. If "read only" is true then any
 attempted uploads will fail. If "read only" is false then uploads will