Add more connect debug info, as Carlos suggested.
authorWayne Davison <wayned@samba.org>
Tue, 12 Jul 2011 22:58:11 +0000 (15:58 -0700)
committerWayne Davison <wayned@samba.org>
Tue, 12 Jul 2011 23:01:59 +0000 (16:01 -0700)
socket.c

index f2f79f72f0b6720d4472fc2952d5f74dae5d091e..855fc09f1aebd4fef660dab93c2fc2680d193e75 100644 (file)
--- a/socket.c
+++ b/socket.c
@@ -297,10 +297,17 @@ int open_socket_out(char *host, int port, const char *bind_addr,
                        s = -1;
                        continue;
                }
+               if (verbose >= 3) {
+                       char buf[2048];
+                       if ((error = getnameinfo(res->ai_addr, res->ai_addrlen, buf, sizeof buf, NULL, 0, NI_NUMERICHOST) != 0))
+                               rprintf(FINFO, "error in getnameinfo: %s\n", gai_strerror(error));
+                       else
+                               rprintf(FINFO, "Connected to %s (%s)\n", h, buf);
+               }
                break;
        }
 
-       if (s < 0) {
+       if (s < 0 || verbose >= 3) {
                char buf[2048];
                for (res = res0, j = 0; res; res = res->ai_next, j++) {
                        if (errnos[j] == 0)
@@ -309,7 +316,8 @@ int open_socket_out(char *host, int port, const char *bind_addr,
                                strlcpy(buf, "*inet_ntop failed*", sizeof buf);
                        rsyserr(FERROR, errnos[j], "failed to connect to %s (%s)", h, buf);
                }
-               s = -1;
+               if (s < 0)
+                       s = -1;
        }
 
        freeaddrinfo(res0);