configure --with-rsh=CMD and default blocking-IO support

Wayne Davison wayned at users.sourceforge.net
Thu Feb 7 09:56:38 EST 2002


On Wed, 6 Feb 2002, Dave Dykstra wrote:
> Of the proposed alternatives, I like this latter the best, changing
> --non-blocking-io to --no-blocking-io.

Cool.  I like that one as well.  Here's an implementation.  This patch
adds the configure option --with(out)-blocking-io and defines a new
variable that gets put into config.h:  DEFAULT_BLOCKING_IO.

The default for configure is just as before:  remsh or rsh gets used
with blocking IO on by default.  If the user specifies --with-rsh=CMD
then the default is --without-blocking-io unless the user also specifies
the --with-blocking-io configure option.

The code in main.c now uses the DEFAULT_BLOCKING_IO value, but only when
we use the default RSYNC_RSH (internal) value.  If the user specifies an
RSYNC_RSH environment variable (or a remote shell via the command-line),
the default is to use non-blocking IO.  (This is a slight change in
behavior if the user had set RSYNC_RSH=rsh in their environment -- is
this acceptable?)

The code now allows the remote shell value to contain a single prefixed
IO-blocking option.  If the string starts with "--" and it has a space
in it, the string must start with "--blocking-io ", "--no-blocking-io ",
or "-- " (the last item allows someone to use a program name that
matches one of our options -- just for completeness).

I also updated the main man page to mention the new RSYNC_RSH syntax,
and also to not talk like rsh is always the default remote shell.  In
the --blocking-io section, it used to say that ssh prefers blocking IO.
I've never used anything but non-blocking IO with ssh, so is this
statement backwards?  I tweaked the statement to say that only some
versions of ssh prefer blocking IO.

Don't forget to run autoconf and autoheader after applying this patch.

..wayne..

---8<------8<------8<------8<---cut here--->8------>8------>8------>8---
Index: rsync/configure.in
--- rsync/configure.in	6 Feb 2002 04:37:09 -0000	1.131
+++ rsync/configure.in	6 Feb 2002 22:45:04 -0000
@@ -102,6 +102,23 @@
 fi

 AC_DEFINE_UNQUOTED(RSYNC_RSH, "$RSYNC_RSH", [default -e command])
+
+AC_ARG_WITH(blocking-io,
+	AC_HELP_STRING([--with-blocking-io], [set blocking IO for your remote shell]))
+
+case "$with_blocking_io" in
+'')
+    if test x"$with_rsh" != x; then
+	    IO=0
+    else
+	    IO=1
+    fi
+    ;;
+no) IO=0 ;;
+*) IO=1 ;;
+esac
+
+AC_DEFINE_UNQUOTED(DEFAULT_BLOCKING_IO, $IO, [default to blocking IO])

 # arrgh. libc in the current debian stable screws up the largefile
 # stuff, getting byte range locking wrong
Index: rsync/main.c
--- rsync/main.c	5 Feb 2002 23:05:32 -0000	1.139
+++ rsync/main.c	6 Feb 2002 22:45:08 -0000
@@ -178,10 +178,25 @@
 	extern int read_batch;

 	if (!read_batch && !local_server) { /* dw -- added read_batch */
+		int def_io = DEFAULT_BLOCKING_IO;
 		if (!cmd)
 			cmd = getenv(RSYNC_RSH_ENV);
 		if (!cmd)
 			cmd = RSYNC_RSH;
+		else
+			def_io = 0;
+		if (*cmd == '-' && cmd[1] == '-' && (tok = strchr(cmd, ' '))) {
+			if (strncmp(cmd+2, "blocking-io ", 12) == 0)
+				def_io = 1;
+			else if (strncmp(cmd+2, "no-blocking-io ", 15) == 0)
+				def_io = 0;
+			else if (cmd[2] != ' ') {
+				rprintf(FERROR,"Invalid remote-shell-IO option: %s\n",
+					cmd);
+				exit_cleanup(RERR_SYNTAX);
+			}
+			cmd = tok + 1;
+		}
 		cmd = strdup(cmd);
 		if (!cmd)
 			goto oom;
@@ -207,8 +222,8 @@

 		args[argc++] = rsync_path;

-		if ((blocking_io == -1) && (strcmp(cmd, RSYNC_RSH) == 0))
-			blocking_io = 1;
+		if (blocking_io < 0)
+			blocking_io = def_io;

 		server_options(args,&argc);

Index: rsync/options.c
--- rsync/options.c	5 Feb 2002 23:05:32 -0000	1.78
+++ rsync/options.c	6 Feb 2002 22:45:09 -0000
@@ -206,7 +206,7 @@
   rprintf(F,"     --no-whole-file         turn off --whole-file\n");
   rprintf(F," -x, --one-file-system       don't cross filesystem boundaries\n");
   rprintf(F," -B, --block-size=SIZE       checksum blocking size (default %d)\n",BLOCK_SIZE);
-  rprintf(F," -e, --rsh=COMMAND           specify rsh replacement\n");
+  rprintf(F," -e, --rsh=COMMAND           specify the remote shell\n");
   rprintf(F,"     --rsync-path=PATH       specify path to rsync on the remote machine\n");
   rprintf(F," -C, --cvs-exclude           auto ignore files in the same way CVS does\n");
   rprintf(F,"     --existing              only update files that already exist\n");
Index: rsync/rsync.yo
--- rsync/rsync.yo	5 Feb 2002 23:05:33 -0000	1.94
+++ rsync/rsync.yo	6 Feb 2002 22:45:13 -0000
@@ -77,11 +77,13 @@

 See the file README for installation instructions.

-Once installed you can use rsync to any machine that you can use rsh
-to.  rsync uses rsh for its communications, unless both the source and
-destination are local.
+Once installed you can use rsync to any machine that you can access via
+a remote shell (as well as some that you can access using the rsync
+daemon-mode protocol).  For remote transfers, rsync typically uses rsh
+for its communications, but it may have been configured to use a
+different remote shell by default, such as ssh.

-You can also specify an alternative to rsh, either by using the -e
+You can also specify any remote shell you like, either by using the -e
 command line option, or by setting the RSYNC_RSH environment variable.

 One common substitute is to use ssh, which offers a high degree of
@@ -135,7 +137,7 @@

 manpagesection(CONNECTING TO AN RSYNC SERVER)

-It is also possible to use rsync without using rsh or ssh as the
+It is also possible to use rsync without a remote shell as the
 transport. In this case you will connect to a remote rsync server
 running on TCP port 873.

@@ -144,7 +146,7 @@
 your web proxy.  Note that your web proxy's configuration must allow
 proxying to port 873.

-Using rsync in this way is the same as using it with rsh or ssh except
+Using rsync in this way is the same as using it with a remote shell except
 that:

 itemize(
@@ -242,7 +244,7 @@
      --no-whole-file         turn off --whole-file
  -x, --one-file-system       don't cross filesystem boundaries
  -B, --block-size=SIZE       checksum blocking size (default 700)
- -e, --rsh=COMMAND           specify rsh replacement
+ -e, --rsh=COMMAND           specify the remote shell to use
      --rsync-path=PATH       specify path to rsync on the remote machine
  -C, --cvs-exclude           auto ignore files in the same way CVS does
      --existing              only update files that already exist
@@ -503,14 +505,15 @@
 the rsync algorithm. See the technical report for details.

 dit(bf(-e, --rsh=COMMAND)) This option allows you to choose an alternative
-remote shell program to use for communication between the local and
-remote copies of rsync. By default, rsync will use rsh, but you may
-like to instead use ssh because of its high security.
+remote shell program to use for communication between the local and remote
+copies of rsync. rsync typically is configured to use rsh by default, but
+you may like to instead use ssh because of its high security.

 You can also choose the remote shell program using the RSYNC_RSH
 environment variable.

-See also the --blocking-io option which is affected by this option.
+See also the RSYNC_RSH environment variable for a discussion of how this
+value affects the default blocking-IO setting.

 dit(bf(--rsync-path=PATH)) Use this to specify the path to the copy of
 rsync on the remote machine. Useful when it's not in your path. Note
@@ -657,14 +660,23 @@
 rather than the default port 873.

 dit(bf(--blocking-io)) This tells rsync to use blocking IO when launching
-a remote shell transport.  If -e or --rsh are not specified or are set to
-the default "rsh", this defaults to blocking IO, otherwise it defaults to
-non-blocking IO.  You may find the --blocking-io option is needed for some
-remote shells that can't handle non-blocking IO.  Ssh prefers blocking IO.
+a remote shell transport.  You may find the --blocking-io option is needed
+for some remote shells that can't handle non-blocking IO (such as some
+versions of ssh).
+
+The default value for this was set when rsync was configured, but
+overriding the default remote shell in any way (either via RSYNC_RSH, or
+on the command-line) changes the default to be non-blocking IO.
+
+See the RSYNC_RSH environment variable for a way to set the blocking-IO
+value via the environment.

 dit(bf(--no-blocking-io)) Turn off --blocking-io, for use when it is the
 default.

+See the RSYNC_RSH environment variable for a way to set the blocking-IO
+value via the environment.
+
 dit(bf(--log-format=FORMAT)) This allows you to specify exactly what the
 rsync client logs to stdout on a per-file basis. The log format is
 specified using the same format conventions as the log format option in
@@ -910,7 +922,21 @@

 dit(bf(RSYNC_RSH)) The RSYNC_RSH environment variable allows you to
 override the default shell used as the transport for rsync. This can
-be used instead of the -e option.
+be used instead of the -e option, and can also be used to set the
+blocking-IO value.
+
+If the remote shell is specified in any manner (either via RSYNC_RSH,
+or on the command-line), the default IO mode becomes non-blocking.  You
+can override this by putting a --blocking-io or a --no-blocking-io option
+at the start of the string.  For instance:
+
+quote(
+    export RSYNC_RSH="--blocking-io rsh"
+)
+
+For those truly rare cases where you need to run a program that has the
+same name as one of these options, feel free to start the string with
+two dashes and a space.

 dit(bf(RSYNC_PROXY)) The RSYNC_PROXY environment variable allows you to
 redirect your rsync client to use a web proxy when connecting to a
---8<------8<------8<------8<---cut here--->8------>8------>8------>8---





More information about the rsync mailing list