From 02199048604ad5abde9ab2c1eb751e9e02895151 Mon Sep 17 00:00:00 2001 From: Kevin Easton Date: Fri, 11 May 2012 12:03:10 +0000 Subject: [PATCH] Ensure that real errors from connect() (eg. EINVAL) are detected and acted on immmediately, even for nonblocking connects. git-svn-id: svn://svn.code.sf.net/p/bitchx/code/trunk@175 13b04d17-f746-0410-82c6-800466cd88b0 --- Changelog | 2 ++ source/network.c | 7 ++----- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/Changelog b/Changelog index 2c33c97..15708d1 100644 --- a/Changelog +++ b/Changelog @@ -1,5 +1,7 @@ [Changes 1.2c01] +* Improve connect() error handling. (caf) + * Remove obsolete .spec files. (caf) * configure - only create sig.inc if it's actually needed. (caf) diff --git a/source/network.c b/source/network.c index fa968f9..e1ed12b 100644 --- a/source/network.c +++ b/source/network.c @@ -611,13 +611,10 @@ int BX_connect_by_number(char *hostn, unsigned short *portnum, int service, int } #endif alarm(get_int_var(CONNECT_TIMEOUT_VAR)); - if (connect (fd, (struct sockaddr *)&server, sizeof(server)) < 0) + if (connect(fd, (struct sockaddr *)&server, sizeof(server)) < 0 && errno != EINPROGRESS) { alarm(0); -#ifdef NON_BLOCKING_CONNECTS - if (!nonblocking) -#endif - return close(fd), -4; + return close(fd), -4; } alarm(0); }