diff --git a/CHANGELOG b/CHANGELOG index 0704a818..1c94375d 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -186,6 +186,11 @@ HISTORY ++ Bugfixes: + 2015-02-17: Simon Goldschmidt + * err.h, sockets.c, api_msg.c: fixed bug #38853 "connect() use a wrong errno": + return ERR_ALREADY/EALRADY during connect, ERR_ISCONN/EISCONN when already + connected + 2015-02-17: Simon Goldschmidt * tcp_impl.h, tcp_out.c, tcp.c, api_msg.c: fixed bug #37614 "Errors from ipX_output are not processed". Now tcp_output(_segment) checks for the return diff --git a/src/api/api_msg.c b/src/api/api_msg.c index 6663b8e9..26754887 100644 --- a/src/api/api_msg.c +++ b/src/api/api_msg.c @@ -1173,7 +1173,9 @@ lwip_netconn_do_connect(struct api_msg_msg *msg) #if LWIP_TCP case NETCONN_TCP: /* Prevent connect while doing any other action. */ - if (msg->conn->state != NETCONN_NONE) { + if (msg->conn->state == NETCONN_CONNECT) { + msg->err = ERR_ALREADY; + } else if (msg->conn->state != NETCONN_NONE) { msg->err = ERR_ISCONN; } else { setup_tcp(msg->conn); diff --git a/src/api/sockets.c b/src/api/sockets.c index c0f4e73b..6dfe57eb 100644 --- a/src/api/sockets.c +++ b/src/api/sockets.c @@ -258,13 +258,14 @@ static const int err_to_errno_table[] = { EINVAL, /* ERR_VAL -6 Illegal value. */ EWOULDBLOCK, /* ERR_WOULDBLOCK -7 Operation would block. */ EADDRINUSE, /* ERR_USE -8 Address in use. */ - EALREADY, /* ERR_ISCONN -9 Already connected. */ - ENOTCONN, /* ERR_CONN -10 Not connected. */ - ECONNABORTED, /* ERR_ABRT -11 Connection aborted. */ - ECONNRESET, /* ERR_RST -12 Connection reset. */ - ENOTCONN, /* ERR_CLSD -13 Connection closed. */ - EIO, /* ERR_ARG -14 Illegal argument. */ - -1, /* ERR_IF -15 Low-level netif error */ + EALREADY, /* ERR_ALREADY -9 Already connecting. */ + EISCONN, /* ERR_ISCONN -10 Conn already established.*/ + ENOTCONN, /* ERR_CONN -11 Not connected. */ + ECONNABORTED, /* ERR_ABRT -12 Connection aborted. */ + ECONNRESET, /* ERR_RST -13 Connection reset. */ + ENOTCONN, /* ERR_CLSD -14 Connection closed. */ + EIO, /* ERR_ARG -15 Illegal argument. */ + -1, /* ERR_IF -16 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 a48430d2..0f0087d8 100644 --- a/src/include/lwip/err.h +++ b/src/include/lwip/err.h @@ -58,20 +58,21 @@ typedef s8_t err_t; #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_ALREADY -9 /* Already connecting. */ +#define ERR_ISCONN -10 /* Conn already established.*/ #define ERR_IS_FATAL(e) ((e) < ERR_ISCONN) -#define ERR_CONN -10 /* Not connected. */ +#define ERR_CONN -11 /* Not connected. */ #define ERR_IS_FATAL_LISTENCONNECT(e) ((e) < ERR_CONN) -#define ERR_ABRT -11 /* Connection aborted. */ -#define ERR_RST -12 /* Connection reset. */ -#define ERR_CLSD -13 /* Connection closed. */ +#define ERR_ABRT -12 /* Connection aborted. */ +#define ERR_RST -13 /* Connection reset. */ +#define ERR_CLSD -14 /* Connection closed. */ -#define ERR_ARG -14 /* Illegal argument. */ +#define ERR_ARG -15 /* Illegal argument. */ -#define ERR_IF -15 /* Low-level netif error */ +#define ERR_IF -16 /* Low-level netif error */ #ifdef LWIP_DEBUG