From 7203680146ff07ad651fc5901303abc0a1c5c4c7 Mon Sep 17 00:00:00 2001 From: goldsimon Date: Mon, 14 Mar 2011 21:21:26 +0000 Subject: [PATCH] fixed bug #31748 (Calling non-blocking connect more than once can render a socket useless) since it mainly involves changing "FATAL" classification of error codes: ERR_USE and ERR_ISCONN just aren't fatal. --- CHANGELOG | 5 +++++ src/api/api_msg.c | 7 +------ src/api/err.c | 16 ++++++++-------- src/api/sockets.c | 16 ++++++++-------- src/include/lwip/err.h | 19 +++++++++---------- 5 files changed, 31 insertions(+), 32 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 475a10cc..75c1495d 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -233,6 +233,11 @@ HISTORY ++ Bugfixes: + 2011-03-14: Simon Goldschmidt + * err.h/.c, sockets.c, api_msg.c: fixed bug #31748 (Calling non-blocking connect + more than once can render a socket useless) since it mainly involves changing + "FATAL" classification of error codes: ERR_USE and ERR_ISCONN just aren't fatal. + 2011-03-13: Simon Goldschmidt * sockets.c: fixed bug #32769 (ESHUTDOWN is linux-specific) by fixing err_to_errno_table (ERR_CLSD: ENOTCONN instead of ESHUTDOWN), ERR_ISCONN: diff --git a/src/api/api_msg.c b/src/api/api_msg.c index dcb07e9c..448f96dd 100644 --- a/src/api/api_msg.c +++ b/src/api/api_msg.c @@ -950,12 +950,7 @@ do_connected(void *arg, struct tcp_pcb *pcb, err_t err) conn->current_msg = NULL; conn->state = NETCONN_NONE; if (!was_blocking) { - SYS_ARCH_DECL_PROTECT(lev); - SYS_ARCH_PROTECT(lev); - if (conn->last_err == ERR_INPROGRESS) { - conn->last_err = ERR_OK; - } - SYS_ARCH_UNPROTECT(lev); + NETCONN_SET_SAFE_ERR(conn, ERR_OK); } API_EVENT(conn, NETCONN_EVT_SENDPLUS, 0); diff --git a/src/api/err.c b/src/api/err.c index b0a4eb3e..92fa8b7d 100644 --- a/src/api/err.c +++ b/src/api/err.c @@ -49,14 +49,14 @@ static const char *err_strerr[] = { "Operation in progress.", /* ERR_INPROGRESS -5 */ "Illegal value.", /* ERR_VAL -6 */ "Operation would block.", /* ERR_WOULDBLOCK -7 */ - "Connection aborted.", /* ERR_ABRT -8 */ - "Connection reset.", /* ERR_RST -9 */ - "Connection closed.", /* ERR_CLSD -10 */ - "Not connected.", /* ERR_CONN -11 */ - "Illegal argument.", /* ERR_ARG -12 */ - "Address in use.", /* ERR_USE -13 */ - "Low-level netif error.", /* ERR_IF -14 */ - "Already connected.", /* ERR_ISCONN -15 */ + "Address in use.", /* ERR_USE -8 */ + "Already connected.", /* ERR_ISCONN -9 */ + "Connection aborted.", /* ERR_ABRT -10 */ + "Connection reset.", /* ERR_RST -11 */ + "Connection closed.", /* ERR_CLSD -12 */ + "Not connected.", /* ERR_CONN -13 */ + "Illegal argument.", /* ERR_ARG -14 */ + "Low-level netif error.", /* ERR_IF -15 */ }; /** diff --git a/src/api/sockets.c b/src/api/sockets.c index 2b2fe604..9d44a408 100644 --- a/src/api/sockets.c +++ b/src/api/sockets.c @@ -141,14 +141,14 @@ static const int err_to_errno_table[] = { EINPROGRESS, /* ERR_INPROGRESS -5 Operation in progress */ EINVAL, /* ERR_VAL -6 Illegal value. */ EWOULDBLOCK, /* ERR_WOULDBLOCK -7 Operation would block. */ - ECONNABORTED, /* ERR_ABRT -8 Connection aborted. */ - ECONNRESET, /* ERR_RST -9 Connection reset. */ - ENOTCONN, /* ERR_CLSD -10 Connection closed. */ - ENOTCONN, /* ERR_CONN -11 Not connected. */ - EIO, /* ERR_ARG -12 Illegal argument. */ - EADDRINUSE, /* ERR_USE -13 Address in use. */ - -1, /* ERR_IF -14 Low-level netif error */ - EALREADY, /* ERR_ISCONN -15 Already connected. */ + EADDRINUSE, /* ERR_USE -8 Address in use. */ + EALREADY, /* ERR_ISCONN -9 Already connected. */ + ECONNABORTED, /* ERR_ABRT -10 Connection aborted. */ + ECONNRESET, /* ERR_RST -11 Connection reset. */ + ENOTCONN, /* ERR_CLSD -12 Connection closed. */ + ENOTCONN, /* ERR_CONN -13 Not connected. */ + EIO, /* ERR_ARG -14 Illegal argument. */ + -1, /* ERR_IF -15 Low-level netif error */ }; #define ERR_TO_ERRNO_TABLE_SIZE \ diff --git a/src/include/lwip/err.h b/src/include/lwip/err.h index 2e34561d..ac907729 100644 --- a/src/include/lwip/err.h +++ b/src/include/lwip/err.h @@ -57,20 +57,19 @@ typedef s8_t err_t; #define ERR_INPROGRESS -5 /* Operation in progress */ #define ERR_VAL -6 /* Illegal value. */ #define ERR_WOULDBLOCK -7 /* Operation would block. */ +#define ERR_USE -8 /* Address in use. */ +#define ERR_ISCONN -9 /* Already connected. */ -#define ERR_IS_FATAL(e) ((e) < ERR_WOULDBLOCK) +#define ERR_IS_FATAL(e) ((e) < ERR_ISCONN) -#define ERR_ABRT -8 /* Connection aborted. */ -#define ERR_RST -9 /* Connection reset. */ -#define ERR_CLSD -10 /* Connection closed. */ -#define ERR_CONN -11 /* Not connected. */ +#define ERR_ABRT -10 /* Connection aborted. */ +#define ERR_RST -11 /* Connection reset. */ +#define ERR_CLSD -12 /* Connection closed. */ +#define ERR_CONN -13 /* Not connected. */ -#define ERR_ARG -12 /* Illegal argument. */ +#define ERR_ARG -14 /* Illegal argument. */ -#define ERR_USE -13 /* Address in use. */ - -#define ERR_IF -14 /* Low-level netif error */ -#define ERR_ISCONN -15 /* Already connected. */ +#define ERR_IF -15 /* Low-level netif error */ #ifdef LWIP_DEBUG