Add more connect debug info, as Carlos suggested.

This commit is contained in:
Wayne Davison
2011-07-12 15:58:11 -07:00
parent fbf4c261f4
commit 7ae666d2a7
2 changed files with 12 additions and 4 deletions

View File

@@ -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)"),

View File

@@ -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);