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:02:31 +0000 (16:02 -0700)
options.c
socket.c

index a8c5b49..6ba6669 100644 (file)
--- a/options.c
+++ b/options.c
@@ -206,7 +206,7 @@ static const char *debug_verbosity[] = {
        /*0*/ NULL,
        /*1*/ NULL,
        /*2*/ "BIND,CMD,CONNECT,DEL,DELTASUM,DUP,FILTER,FLIST,ICONV",
-       /*3*/ "ACL,BACKUP,DELTASUM2,DEL2,EXIT,FILTER2,FLIST2,FUZZY,GENR,OWN,RECV,SEND,TIME",
+       /*3*/ "ACL,BACKUP,CONNECT2,DELTASUM2,DEL2,EXIT,FILTER2,FLIST2,FUZZY,GENR,OWN,RECV,SEND,TIME",
        /*4*/ "CMD2,DELTASUM3,DEL3,EXIT2,FLIST3,ICONV2,OWN2,PROTO,TIME2",
        /*5*/ "CHDIR,DELTASUM4,FLIST4,FUZZY2,HASH,HLINK",
 };
@@ -267,7 +267,7 @@ static struct output_struct debug_words[COUNT_DEBUG+1] = {
        DEBUG_WORD(BACKUP, W_REC, "Debug backup actions (levels 1-2)"),
        DEBUG_WORD(BIND, W_CLI, "Debug socket bind actions"),
        DEBUG_WORD(CHDIR, W_CLI|W_SRV, "Debug when the current directory changes"),
-       DEBUG_WORD(CONNECT, W_CLI, "Debug connection events"),
+       DEBUG_WORD(CONNECT, W_CLI, "Debug connection events (levels 1-2)"),
        DEBUG_WORD(CMD, W_CLI, "Debug commands+options that are issued (levels 1-2)"),
        DEBUG_WORD(DEL, W_REC, "Debug delete actions (levels 1-3)"),
        DEBUG_WORD(DELTASUM, W_SND|W_REC, "Debug delta-transfer checksumming (levels 1-4)"),
index 86e62f9..a43385e 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 (DEBUG_GTE(CONNECT, 2)) {
+                       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 || DEBUG_GTE(CONNECT, 2)) {
                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);