mirror of
https://github.com/lwip-tcpip/lwip.git
synced 2025-02-19 03:39:54 +00:00
Changed error handling: ERR_MEM, ERR_BUF and ERR_RTE are seen as non-fatal, all other errors are fatal. netconns and sockets block most operations once they have seen a fatal error.
This commit is contained in:
parent
b4741332e0
commit
03777ccb21
@ -499,6 +499,11 @@ HISTORY
|
|||||||
|
|
||||||
++ Bug fixes:
|
++ Bug fixes:
|
||||||
|
|
||||||
|
2007-11-27 Simon Goldschmidt
|
||||||
|
* err.h, api_lib.c, api_msg.c, sockets.c: Changed error handling: ERR_MEM, ERR_BUF
|
||||||
|
and ERR_RTE are seen as non-fatal, all other errors are fatal. netconns and
|
||||||
|
sockets block most operations once they have seen a fatal error.
|
||||||
|
|
||||||
2007-11-27 Simon Goldschmidt
|
2007-11-27 Simon Goldschmidt
|
||||||
* udp.h, udp.c, dhcp.c: Implemented new function udp_sendto_if which takes the
|
* udp.h, udp.c, dhcp.c: Implemented new function udp_sendto_if which takes the
|
||||||
netif to send as an argument (to be able to send on netifs that are down).
|
netif to send as an argument (to be able to send on netifs that are down).
|
||||||
|
@ -355,18 +355,21 @@ netconn_recv(struct netconn *conn)
|
|||||||
|
|
||||||
if (conn->recvmbox == SYS_MBOX_NULL) {
|
if (conn->recvmbox == SYS_MBOX_NULL) {
|
||||||
if ((conn->recvmbox = sys_mbox_new()) == SYS_MBOX_NULL) {
|
if ((conn->recvmbox = sys_mbox_new()) == SYS_MBOX_NULL) {
|
||||||
|
/* @todo: should calling netconn_recv on a TCP listen conn be fatal?? */
|
||||||
|
/* TCP listen conn don't have a recvmbox! */
|
||||||
conn->err = ERR_CONN;
|
conn->err = ERR_CONN;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (conn->err != ERR_OK) {
|
if (ERR_IS_FATAL(conn->err)) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (conn->type == NETCONN_TCP) {
|
if (conn->type == NETCONN_TCP) {
|
||||||
#if LWIP_TCP
|
#if LWIP_TCP
|
||||||
if (conn->state == NETCONN_LISTEN) {
|
if (conn->state == NETCONN_LISTEN) {
|
||||||
|
/* @todo: should calling netconn_recv on a TCP listen conn be fatal?? */
|
||||||
conn->err = ERR_CONN;
|
conn->err = ERR_CONN;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -546,7 +546,7 @@ do_delconn(struct api_msg_msg *msg)
|
|||||||
void
|
void
|
||||||
do_bind(struct api_msg_msg *msg)
|
do_bind(struct api_msg_msg *msg)
|
||||||
{
|
{
|
||||||
if (msg->conn->err == ERR_OK) {
|
if (!ERR_IS_FATAL(msg->conn->err)) {
|
||||||
if (msg->conn->pcb.tcp != NULL) {
|
if (msg->conn->pcb.tcp != NULL) {
|
||||||
switch (NETCONNTYPE_GROUP(msg->conn->type)) {
|
switch (NETCONNTYPE_GROUP(msg->conn->type)) {
|
||||||
#if LWIP_RAW
|
#if LWIP_RAW
|
||||||
@ -596,7 +596,7 @@ do_connected(void *arg, struct tcp_pcb *pcb, err_t err)
|
|||||||
}
|
}
|
||||||
|
|
||||||
conn->err = err;
|
conn->err = err;
|
||||||
if (conn->type == NETCONN_TCP && err == ERR_OK) {
|
if ((conn->type == NETCONN_TCP) && (err == ERR_OK)) {
|
||||||
setup_tcp(conn);
|
setup_tcp(conn);
|
||||||
}
|
}
|
||||||
conn->state = NETCONN_NONE;
|
conn->state = NETCONN_NONE;
|
||||||
@ -676,7 +676,7 @@ void
|
|||||||
do_listen(struct api_msg_msg *msg)
|
do_listen(struct api_msg_msg *msg)
|
||||||
{
|
{
|
||||||
#if LWIP_TCP
|
#if LWIP_TCP
|
||||||
if (msg->conn->err == ERR_OK) {
|
if (!ERR_IS_FATAL(msg->conn->err)) {
|
||||||
if (msg->conn->pcb.tcp != NULL) {
|
if (msg->conn->pcb.tcp != NULL) {
|
||||||
if (msg->conn->type == NETCONN_TCP) {
|
if (msg->conn->type == NETCONN_TCP) {
|
||||||
if (msg->conn->pcb.tcp->state == CLOSED) {
|
if (msg->conn->pcb.tcp->state == CLOSED) {
|
||||||
@ -715,7 +715,7 @@ do_listen(struct api_msg_msg *msg)
|
|||||||
void
|
void
|
||||||
do_send(struct api_msg_msg *msg)
|
do_send(struct api_msg_msg *msg)
|
||||||
{
|
{
|
||||||
if (msg->conn->err == ERR_OK) {
|
if (!ERR_IS_FATAL(msg->conn->err)) {
|
||||||
if (msg->conn->pcb.tcp != NULL) {
|
if (msg->conn->pcb.tcp != NULL) {
|
||||||
switch (NETCONNTYPE_GROUP(msg->conn->type)) {
|
switch (NETCONNTYPE_GROUP(msg->conn->type)) {
|
||||||
#if LWIP_RAW
|
#if LWIP_RAW
|
||||||
@ -754,7 +754,7 @@ void
|
|||||||
do_recv(struct api_msg_msg *msg)
|
do_recv(struct api_msg_msg *msg)
|
||||||
{
|
{
|
||||||
#if LWIP_TCP
|
#if LWIP_TCP
|
||||||
if (msg->conn->err == ERR_OK) {
|
if (!ERR_IS_FATAL(msg->conn->err)) {
|
||||||
if (msg->conn->pcb.tcp != NULL) {
|
if (msg->conn->pcb.tcp != NULL) {
|
||||||
if (msg->conn->type == NETCONN_TCP) {
|
if (msg->conn->type == NETCONN_TCP) {
|
||||||
tcp_recved(msg->conn->pcb.tcp, msg->msg.r.len);
|
tcp_recved(msg->conn->pcb.tcp, msg->msg.r.len);
|
||||||
@ -828,10 +828,9 @@ do_writemore(struct netconn *conn)
|
|||||||
conn->write_delayed = 1;
|
conn->write_delayed = 1;
|
||||||
#endif
|
#endif
|
||||||
} else {
|
} else {
|
||||||
/* if ERR_MEM, we wait for sent_tcp or poll_tcp to be called */
|
/* if ERR_MEM, we wait for sent_tcp or poll_tcp to be called
|
||||||
|
on other errors we don't try writing any more */
|
||||||
conn->err = err;
|
conn->err = err;
|
||||||
/* since we've had an error (except temporary running out of memory,
|
|
||||||
we don't try writing any more */
|
|
||||||
write_finished = 1;
|
write_finished = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -863,7 +862,7 @@ do_writemore(struct netconn *conn)
|
|||||||
void
|
void
|
||||||
do_write(struct api_msg_msg *msg)
|
do_write(struct api_msg_msg *msg)
|
||||||
{
|
{
|
||||||
if (msg->conn->err == ERR_OK) {
|
if (!ERR_IS_FATAL(msg->conn->err)) {
|
||||||
if ((msg->conn->pcb.tcp != NULL) && (msg->conn->type == NETCONN_TCP)) {
|
if ((msg->conn->pcb.tcp != NULL) && (msg->conn->type == NETCONN_TCP)) {
|
||||||
#if LWIP_TCP
|
#if LWIP_TCP
|
||||||
msg->conn->state = NETCONN_WRITE;
|
msg->conn->state = NETCONN_WRITE;
|
||||||
@ -937,7 +936,7 @@ do_getaddr(struct api_msg_msg *msg)
|
|||||||
#endif /* LWIP_TCP */
|
#endif /* LWIP_TCP */
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
msg->conn->err =ERR_CONN;
|
msg->conn->err = ERR_CONN;
|
||||||
}
|
}
|
||||||
TCPIP_APIMSG_ACK(msg);
|
TCPIP_APIMSG_ACK(msg);
|
||||||
}
|
}
|
||||||
@ -974,7 +973,7 @@ do_close(struct api_msg_msg *msg)
|
|||||||
void
|
void
|
||||||
do_join_leave_group(struct api_msg_msg *msg)
|
do_join_leave_group(struct api_msg_msg *msg)
|
||||||
{
|
{
|
||||||
if (msg->conn->err == ERR_OK) {
|
if (!ERR_IS_FATAL(msg->conn->err)) {
|
||||||
if (msg->conn->pcb.tcp != NULL) {
|
if (msg->conn->pcb.tcp != NULL) {
|
||||||
if (NETCONNTYPE_GROUP(msg->conn->type) == NETCONN_UDP) {
|
if (NETCONNTYPE_GROUP(msg->conn->type) == NETCONN_UDP) {
|
||||||
#if LWIP_UDP
|
#if LWIP_UDP
|
||||||
|
@ -127,13 +127,13 @@ static const int err_to_errno_table[] = {
|
|||||||
0, /* ERR_OK 0 No error, everything OK. */
|
0, /* ERR_OK 0 No error, everything OK. */
|
||||||
ENOMEM, /* ERR_MEM -1 Out of memory error. */
|
ENOMEM, /* ERR_MEM -1 Out of memory error. */
|
||||||
ENOBUFS, /* ERR_BUF -2 Buffer error. */
|
ENOBUFS, /* ERR_BUF -2 Buffer error. */
|
||||||
ECONNABORTED, /* ERR_ABRT -3 Connection aborted. */
|
EHOSTUNREACH, /* ERR_RTE -3 Routing problem. */
|
||||||
ECONNRESET, /* ERR_RST -4 Connection reset. */
|
ECONNABORTED, /* ERR_ABRT -4 Connection aborted. */
|
||||||
ESHUTDOWN, /* ERR_CLSD -5 Connection closed. */
|
ECONNRESET, /* ERR_RST -5 Connection reset. */
|
||||||
ENOTCONN, /* ERR_CONN -6 Not connected. */
|
ESHUTDOWN, /* ERR_CLSD -6 Connection closed. */
|
||||||
EINVAL, /* ERR_VAL -7 Illegal value. */
|
ENOTCONN, /* ERR_CONN -7 Not connected. */
|
||||||
EIO, /* ERR_ARG -8 Illegal argument. */
|
EINVAL, /* ERR_VAL -8 Illegal value. */
|
||||||
EHOSTUNREACH, /* ERR_RTE -9 Routing problem. */
|
EIO, /* ERR_ARG -9 Illegal argument. */
|
||||||
EADDRINUSE, /* ERR_USE -10 Address in use. */
|
EADDRINUSE, /* ERR_USE -10 Address in use. */
|
||||||
-1, /* ERR_IF -11 Low-level netif error */
|
-1, /* ERR_IF -11 Low-level netif error */
|
||||||
-1, /* ERR_ISCONN -12 Already connected. */
|
-1, /* ERR_ISCONN -12 Already connected. */
|
||||||
|
@ -45,18 +45,18 @@ typedef s8_t err_t;
|
|||||||
#define ERR_OK 0 /* No error, everything OK. */
|
#define ERR_OK 0 /* No error, everything OK. */
|
||||||
#define ERR_MEM -1 /* Out of memory error. */
|
#define ERR_MEM -1 /* Out of memory error. */
|
||||||
#define ERR_BUF -2 /* Buffer error. */
|
#define ERR_BUF -2 /* Buffer error. */
|
||||||
|
#define ERR_RTE -3 /* Routing problem. */
|
||||||
|
|
||||||
|
#define ERR_IS_FATAL(e) ((e) < ERR_TIMEOUT)
|
||||||
|
|
||||||
#define ERR_ABRT -3 /* Connection aborted. */
|
#define ERR_ABRT -4 /* Connection aborted. */
|
||||||
#define ERR_RST -4 /* Connection reset. */
|
#define ERR_RST -5 /* Connection reset. */
|
||||||
#define ERR_CLSD -5 /* Connection closed. */
|
#define ERR_CLSD -6 /* Connection closed. */
|
||||||
#define ERR_CONN -6 /* Not connected. */
|
#define ERR_CONN -7 /* Not connected. */
|
||||||
|
|
||||||
#define ERR_VAL -7 /* Illegal value. */
|
#define ERR_VAL -8 /* Illegal value. */
|
||||||
|
|
||||||
#define ERR_ARG -8 /* Illegal argument. */
|
#define ERR_ARG -9 /* Illegal argument. */
|
||||||
|
|
||||||
#define ERR_RTE -9 /* Routing problem. */
|
|
||||||
|
|
||||||
#define ERR_USE -10 /* Address in use. */
|
#define ERR_USE -10 /* Address in use. */
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user