On Sat, Dec 12, 2020 at 07:07:20AM -0500, Daniel Moch wrote:
> A recent change to openrsync added the --timeout opt.  There's code to
> handle the (default) case of --timeout=0, which sets the poll_timeout
> to -1 (INFTIM).  Unfortunately that code doesn't run in the server
> process, meaning all of the relevant calls to poll(2) return
> immediately and the process fails.
> 
> The following patch addresses the issue by moving the code that
> handles --timeout=0 up to run before the rsync_server call.
> 
> Index: main.c
> ===================================================================
> RCS file: /cvs/src/usr.bin/rsync/main.c,v
> retrieving revision 1.50
> diff -r1.50 main.c
> 411a412,417
> >     /* by default and for --timeout=0 disable poll_timeout */
> >     if (poll_timeout == 0)
> >             poll_timeout = -1;
> >     else
> >             poll_timeout *= 1000;
> > 
> 420,425d425
> < 
> <     /* by default and for --timeout=0 disable poll_timeout */
> <     if (poll_timeout == 0)
> <             poll_timeout = -1;
> <     else
> <             poll_timeout *= 1000;
> 

Here the unified diff which moves the poll_timeout initalisation before
the rsync_server() call.

-- 
:wq Claudio

Index: main.c
===================================================================
RCS file: /cvs/src/usr.bin/rsync/main.c,v
retrieving revision 1.50
diff -u -p -r1.50 main.c
--- main.c      24 Nov 2020 16:54:44 -0000      1.50
+++ main.c      12 Dec 2020 12:33:07 -0000
@@ -409,6 +409,12 @@ main(int argc, char *argv[])
        if (opts.port == NULL)
                opts.port = "rsync";
 
+       /* by default and for --timeout=0 disable poll_timeout */
+       if (poll_timeout == 0)
+               poll_timeout = -1;
+       else
+               poll_timeout *= 1000;
+
        /*
         * This is what happens when we're started with the "hidden"
         * --server option, which is invoked for the rsync on the remote
@@ -417,12 +423,6 @@ main(int argc, char *argv[])
 
        if (opts.server)
                exit(rsync_server(&opts, (size_t)argc, argv));
-
-       /* by default and for --timeout=0 disable poll_timeout */
-       if (poll_timeout == 0)
-               poll_timeout = -1;
-       else
-               poll_timeout *= 1000;
 
        /*
         * Now we know that we're the client on the local machine

Reply via email to