Moved (and expanded) a verbose message from clientserver.c to socket.c
authorWayne Davison <wayned@samba.org>
Wed, 14 Apr 2004 16:51:48 +0000 (16:51 +0000)
committerWayne Davison <wayned@samba.org>
Wed, 14 Apr 2004 16:51:48 +0000 (16:51 +0000)
to solve an old FIXME comment.

clientserver.c
socket.c

index 13e52f3..6c2e6d9 100644 (file)
@@ -87,18 +87,10 @@ int start_socket_client(char *host, char *path, int argc, char *argv[])
                *p = 0;
        }
 
-       if (verbose >= 2) {
-               /* FIXME: If we're going to use a socket program for
-                * testing, then this message is wrong.  We need to
-                * say something like "(except really using %s)" */
-               rprintf(FINFO, "opening tcp connection to %s port %d\n",
-                       host, rsync_port);
-       }
        fd = open_socket_out_wrapped(host, rsync_port, bind_address,
                                     default_af_hint);
-       if (fd == -1) {
+       if (fd == -1)
                exit_cleanup(RERR_SOCKETIO);
-       }
 
        ret = start_inband_exchange(user, path, fd, fd, argc);
 
index 140480b..264c532 100644 (file)
--- a/socket.c
+++ b/socket.c
@@ -299,9 +299,14 @@ int open_socket_out(char *host, int port, const char *bind_address,
 int open_socket_out_wrapped(char *host, int port, const char *bind_address,
                            int af_hint)
 {
-       char *prog;
+       char *prog = getenv("RSYNC_CONNECT_PROG");
 
-       if ((prog = getenv("RSYNC_CONNECT_PROG")) != NULL)
+       if (verbose >= 2) {
+               rprintf(FINFO, "%sopening tcp connection to %s port %d\n",
+                       prog ? "Using RSYNC_CONNECT_PROG instead of " : "",
+                       host, port);
+       }
+       if (prog)
                return sock_exec(prog);
        return open_socket_out(host, port, bind_address, af_hint);
 }
@@ -769,18 +774,14 @@ int sock_exec(const char *prog)
                        strerror(errno));
                return -1;
        }
+       if (verbose >= 2)
+               rprintf(FINFO, "Running socket program: \"%s\"\n", prog);
        if (fork() == 0) {
                close(fd[0]);
                close(0);
                close(1);
                dup(fd[1]);
                dup(fd[1]);
-               if (verbose > 3) {
-                       /* Can't use rprintf because we've forked. */
-                       fprintf(stderr,
-                               RSYNC_NAME ": execute socket program \"%s\"\n",
-                               prog);
-               }
                exit(system(prog));
        }
        close(fd[1]);