Skip to content

Commit

Permalink
Fix connection refused detection under Cygwin
Browse files Browse the repository at this point in the history
Found by: michaelortmann
Patch by: michaelortmann
  • Loading branch information
michaelortmann authored Oct 1, 2023
1 parent 43f2675 commit 9dec748
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/dcc.c
Original file line number Diff line number Diff line change
Expand Up @@ -1421,6 +1421,9 @@ static void dcc_telnet_hostresolved(int i)
strcpy(dcc[j].nick, "*");
dcc[j].u.ident_sock = dcc[i].sock;
dcc[j].timeval = now;
#ifdef CYGWIN_HACKS
threaddata()->socklist[findsock(dcc[j].sock)].flags = SOCK_CONNECT;
#endif
dprintf(j, "%d, %d\n", dcc[i].port, dcc[idx].port);
}

Expand Down
15 changes: 15 additions & 0 deletions src/net.c
Original file line number Diff line number Diff line change
Expand Up @@ -1410,6 +1410,21 @@ void dequeue_sockets()
for (i = 0; i < threaddata()->MAXSOCKS; i++) {
if (!(socklist[i].flags & (SOCK_UNUSED | SOCK_TCL)) &&
(socklist[i].handler.sock.outbuf != NULL) && (FD_ISSET(socklist[i].sock, &wfds))) {
#ifdef CYGWIN_HACKS
int res;
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 (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 ;
}
}
#endif
/* Trick tputs into doing the work */
errno = 0;
#ifdef TLS
Expand Down

0 comments on commit 9dec748

Please sign in to comment.