Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(WIP) Enhance debug error logging #1665

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -1155,7 +1155,8 @@ int main(int arg_c, char **arg_v)
putlog(LOG_MISC, "*", "Error renaming stderr file handle: %s", strerror(errno));
}
#ifdef CYGWIN_HACKS
FreeConsole();
if (!FreeConsole())
putlog(LOG_MISC, "*", "FreeConsole() failed with error %lu", GetLastError());
#endif
}

Expand Down
16 changes: 11 additions & 5 deletions src/net.c
Original file line number Diff line number Diff line change
Expand Up @@ -588,7 +588,9 @@ int open_telnet_raw(int sock, sockname_t *addr)
FD_SET(sock, &sockset);
select(sock + 1, &sockset, NULL, NULL, &tv);
res_len = sizeof(res);
getsockopt(sock, SOL_SOCKET, SO_ERROR, &res, &res_len);
if (getsockopt(sock, SOL_SOCKET, SO_ERROR, &res, &res_len) < 0)
debug2("net: open_telnet_raw(): getsockopt() s %i level SOL_SOCKET optname SO_ERROR error %s",
sock, strerror(errno));
if (res == EINPROGRESS) /* Operation now in progress */
return sock; /* This could probably fail somewhere */
if (res == ECONNREFUSED) { /* Connection refused */
Expand Down Expand Up @@ -652,7 +654,9 @@ int open_address_listen(sockname_t *addr)
#if defined IPV6 && IPV6_V6ONLY
if (addr->family == AF_INET6) {
int on = 0;
setsockopt(sock, IPPROTO_IPV6, IPV6_V6ONLY, (char *) &on, sizeof(on));
if (setsockopt(sock, IPPROTO_IPV6, IPV6_V6ONLY, (char *) &on, sizeof on))
debug2("net: open_address_listen(): setsockopt() s %i level IPPROTO_IPV6 optname IPV6_V6ONLY error %s",
sock, strerror(errno));
}
#endif
if (bind(sock, &addr->addr.sa, addr->addrlen) < 0) {
Expand Down Expand Up @@ -1243,7 +1247,7 @@ int sockgets(char *s, int *len)
}
}
/* Look for EOL marker; if it's there, i have something to show */
for (p = xx; *p != 0 ; p++) {
for (p = xx; *p != 0; p++) {
if ((*p == '\r') || (*p == '\n')) {
memcpy(s, xx, p - xx);
s[p - xx] = 0;
Expand Down Expand Up @@ -1427,13 +1431,15 @@ void dequeue_sockets()
socklen_t res_len;
if (socklist[i].flags == SOCK_CONNECT) {
res_len = sizeof(res);
getsockopt(socklist[i].sock, SOL_SOCKET, SO_ERROR, &res, &res_len);
if (getsockopt(socklist[i].sock, SOL_SOCKET, SO_ERROR, &res, &res_len) < 0)
debug2("net: dequeue_sockets(): getsockopt() s %i level SOL_SOCKET optname SO_ERROR error %s",
socklist[i].sock, strerror(errno));
if (res == ECONNREFUSED) { /* Connection refused */
int idx = findanyidx(socklist[i].sock);
putlog(LOG_MISC, "*", "Connection refused: %s:%i", dcc[idx].host,
dcc[idx].port);
socklist[i].flags |= SOCK_EOFD;
return ;
return;
}
}
#endif
Expand Down