On Tue, Nov 01, 2005 at 01:03:39PM -0500, Lawrence D. Dunn
wrote:> I'd like to request/suggest that cli options to set TCP send/receive
> buffers be added to rsync client-side.
That's simple enough to do. The attached patch adds the option
--sockopts=OPTIONS that accepts the same option names as the daemon's
"socket options" config-file setting. For example:
rsync -av --sockopts=SO_SNDBUF=1234,SO_RCVBUF=1234 host::module
The patch also makes the new option accepted by the daemon's command-
line parser, allowing whomever starts the daemon to override the config
file's "socket option" settings via the command-line.
Also note that popt's aliases can be used to make that easier to type.
For instance, if you put a line like this into your ~/.popt file:
rsync alias --fast --sockopts=SO_SNDBUF=1234,SO_RCVBUF=1234
That will allow you to specify --fast as an rsync option.
..wayne..
-------------- next part --------------
--- clientserver.c 24 Oct 2005 21:03:50 -0000 1.165
+++ clientserver.c 2 Nov 2005 03:19:40 -0000
@@ -45,6 +45,7 @@ extern int orig_umask;
extern int no_detach;
extern int default_af_hint;
extern char *bind_address;
+extern char *sockopts;
extern struct filter_list_struct server_filter_list;
extern char *config_file;
extern char *files_from;
@@ -100,6 +101,8 @@ int start_socket_client(char *host, char
if (fd == -1)
exit_cleanup(RERR_SOCKETIO);
+ set_socket_options(fd, sockopts);
+
ret = start_inband_exchange(user, path, fd, fd, argc);
return ret ? ret : client_run(fd, fd, -1, argc, argv);
@@ -687,6 +690,7 @@ int start_daemon(int f_in, int f_out)
if (!am_server) {
set_socket_options(f_in, "SO_KEEPALIVE");
set_socket_options(f_in, lp_socket_options());
+ set_socket_options(f_in, sockopts);
set_nonblocking(f_in);
}
--- options.c 26 Oct 2005 16:47:15 -0000 1.287
+++ options.c 2 Nov 2005 03:19:41 -0000
@@ -145,6 +145,7 @@ char *password_file = NULL;
char *rsync_path = RSYNC_PATH;
char *backup_dir = NULL;
char backup_dir_buf[MAXPATHLEN];
+char *sockopts = NULL;
int rsync_port = 0;
int compare_dest = 0;
int copy_dest = 0;
@@ -339,6 +340,7 @@ void usage(enum logcode F)
rprintf(F," -0, --from0 all *-from/filter files are
delimited by 0s\n");
rprintf(F," --address=ADDRESS bind address for outgoing socket
to daemon\n");
rprintf(F," --port=PORT specify double-colon alternate
port number\n");
+ rprintf(F," --sockopts=OPTIONS specify custom TCP
options\n");
rprintf(F," --blocking-io use blocking I/O for the remote
shell\n");
rprintf(F," --stats give some file-transfer
stats\n");
rprintf(F," --progress show progress during
transfer\n");
@@ -486,6 +488,7 @@ static struct poptOption long_options[]
#endif
{"address", 0, POPT_ARG_STRING, &bind_address, 0, 0,
0 },
{"port", 0, POPT_ARG_INT, &rsync_port, 0, 0, 0
},
+ {"sockopts", 0, POPT_ARG_STRING, &sockopts, 0, 0, 0 },
{"password-file", 0, POPT_ARG_STRING, &password_file, 0, 0,
0 },
{"blocking-io", 0, POPT_ARG_VAL, &blocking_io, 1, 0, 0
},
{"no-blocking-io", 0, POPT_ARG_VAL, &blocking_io, 0, 0, 0
},
@@ -511,6 +514,7 @@ static void daemon_usage(enum logcode F)
rprintf(F," --config=FILE specify alternate rsyncd.conf
file\n");
rprintf(F," --no-detach do not detach from the
parent\n");
rprintf(F," --port=PORT listen on alternate port
number\n");
+ rprintf(F," --sockopts=OPTIONS specify custom TCP
options\n");
rprintf(F," -v, --verbose increase verbosity\n");
#ifdef INET6
rprintf(F," -4, --ipv4 prefer IPv4\n");
@@ -535,6 +539,7 @@ static struct poptOption long_daemon_opt
{"detach", 0, POPT_ARG_VAL, &no_detach, 0, 0, 0
},
{"no-detach", 0, POPT_ARG_VAL, &no_detach, 1, 0, 0
},
{"port", 0, POPT_ARG_INT, &rsync_port, 0, 0, 0
},
+ {"sockopts", 0, POPT_ARG_STRING, &sockopts, 0, 0, 0 },
{"protocol", 0, POPT_ARG_INT, &protocol_version, 0,
0, 0 },
{"server", 0, POPT_ARG_NONE, &am_server, 0, 0, 0
},
{"temp-dir", 'T', POPT_ARG_STRING, &tmpdir, 0,
0, 0 },