mirror of
https://github.com/lwip-tcpip/lwip.git
synced 2024-07-02 19:08:57 +00:00
task #10102: "netconn: clean up conn->err threading issues" by adding error return value to struct api_msg_msg
This commit is contained in:
parent
0e3c256667
commit
3e1cca65bd
|
@ -50,6 +50,10 @@ HISTORY
|
||||||
|
|
||||||
++ Bugfixes:
|
++ Bugfixes:
|
||||||
|
|
||||||
|
2010-01-17: Simon Goldschmidt
|
||||||
|
* api_lib.c, api_msg.c, (api_msg.h, api.h, sockets.c, tcpip.c):
|
||||||
|
task #10102: Netconn: clean up conn->err threading issues
|
||||||
|
|
||||||
2010-01-17: Simon Goldschmidt
|
2010-01-17: Simon Goldschmidt
|
||||||
* api.h, api_lib.c, sockets.c: Changed netconn_recv() and netconn_accept()
|
* api.h, api_lib.c, sockets.c: Changed netconn_recv() and netconn_accept()
|
||||||
to return err_t (bugs #27709 and #28087)
|
to return err_t (bugs #27709 and #28087)
|
||||||
|
|
|
@ -101,6 +101,7 @@ struct tcp_pcb;
|
||||||
struct udp_pcb;
|
struct udp_pcb;
|
||||||
struct raw_pcb;
|
struct raw_pcb;
|
||||||
struct netconn;
|
struct netconn;
|
||||||
|
struct api_msg_msg;
|
||||||
|
|
||||||
/** A callback prototype to inform about events for a netconn */
|
/** A callback prototype to inform about events for a netconn */
|
||||||
typedef void (* netconn_callback)(struct netconn *, enum netconn_evt, u16_t len);
|
typedef void (* netconn_callback)(struct netconn *, enum netconn_evt, u16_t len);
|
||||||
|
@ -119,7 +120,7 @@ struct netconn {
|
||||||
struct raw_pcb *raw;
|
struct raw_pcb *raw;
|
||||||
} pcb;
|
} pcb;
|
||||||
/** the last error this netconn had */
|
/** the last error this netconn had */
|
||||||
err_t err;
|
err_t last_err;
|
||||||
/** sem that is used to synchroneously execute functions in the core context */
|
/** sem that is used to synchroneously execute functions in the core context */
|
||||||
sys_sem_t op_completed;
|
sys_sem_t op_completed;
|
||||||
/** mbox where received packets are stored until they are fetched
|
/** mbox where received packets are stored until they are fetched
|
||||||
|
@ -142,8 +143,9 @@ struct netconn {
|
||||||
s16_t recv_avail;
|
s16_t recv_avail;
|
||||||
#if LWIP_TCP
|
#if LWIP_TCP
|
||||||
/** TCP: when data passed to netconn_write doesn't fit into the send buffer,
|
/** TCP: when data passed to netconn_write doesn't fit into the send buffer,
|
||||||
this temporarily stores the message. */
|
this temporarily stores the message.
|
||||||
struct api_msg_msg *write_msg;
|
Also used during connect and close. */
|
||||||
|
struct api_msg_msg *current_msg;
|
||||||
/** TCP: when data passed to netconn_write doesn't fit into the send buffer,
|
/** TCP: when data passed to netconn_write doesn't fit into the send buffer,
|
||||||
this temporarily stores how much is already sent. */
|
this temporarily stores how much is already sent. */
|
||||||
size_t write_offset;
|
size_t write_offset;
|
||||||
|
@ -158,11 +160,21 @@ struct netconn {
|
||||||
netconn_callback callback;
|
netconn_callback callback;
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Register an Network connection event */
|
/** Register an Network connection event */
|
||||||
#define API_EVENT(c,e,l) if (c->callback) { \
|
#define API_EVENT(c,e,l) if (c->callback) { \
|
||||||
(*c->callback)(c, e, l); \
|
(*c->callback)(c, e, l); \
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Set conn->last_err to err but don't overwrite fatal errors */
|
||||||
|
#define NETCONN_SET_SAFE_ERR(conn, err) do { \
|
||||||
|
SYS_ARCH_DECL_PROTECT(lev); \
|
||||||
|
SYS_ARCH_PROTECT(lev); \
|
||||||
|
if (!ERR_IS_FATAL((conn)->last_err)) { \
|
||||||
|
(conn)->last_err = err; \
|
||||||
|
} \
|
||||||
|
SYS_ARCH_UNPROTECT(lev); \
|
||||||
|
} while(0);
|
||||||
|
|
||||||
/* Network connection functions: */
|
/* Network connection functions: */
|
||||||
#define netconn_new(t) netconn_new_with_proto_and_callback(t, 0, NULL)
|
#define netconn_new(t) netconn_new_with_proto_and_callback(t, 0, NULL)
|
||||||
#define netconn_new_with_callback(t, c) netconn_new_with_proto_and_callback(t, 0, c)
|
#define netconn_new_with_callback(t, c) netconn_new_with_proto_and_callback(t, 0, c)
|
||||||
|
|
|
@ -58,6 +58,8 @@ struct api_msg_msg {
|
||||||
/** The netconn which to process - always needed: it includes the semaphore
|
/** The netconn which to process - always needed: it includes the semaphore
|
||||||
which is used to block the application thread until the function finished. */
|
which is used to block the application thread until the function finished. */
|
||||||
struct netconn *conn;
|
struct netconn *conn;
|
||||||
|
/** The return value of the function executed in tcpip_thread. */
|
||||||
|
err_t err;
|
||||||
/** Depending on the executed function, one of these union members is used */
|
/** Depending on the executed function, one of these union members is used */
|
||||||
union {
|
union {
|
||||||
/** used for do_send */
|
/** used for do_send */
|
||||||
|
|
Loading…
Reference in New Issue
Block a user