task #10102: "netconn: clean up conn->err threading issues" by adding error return value to struct api_msg_msg

This commit is contained in:
goldsimon 2010-01-17 18:28:56 +00:00
parent 0e3c256667
commit 3e1cca65bd
3 changed files with 22 additions and 4 deletions

View File

@ -50,6 +50,10 @@ HISTORY
++ 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
* api.h, api_lib.c, sockets.c: Changed netconn_recv() and netconn_accept()
to return err_t (bugs #27709 and #28087)

View File

@ -101,6 +101,7 @@ struct tcp_pcb;
struct udp_pcb;
struct raw_pcb;
struct netconn;
struct api_msg_msg;
/** A callback prototype to inform about events for a netconn */
typedef void (* netconn_callback)(struct netconn *, enum netconn_evt, u16_t len);
@ -119,7 +120,7 @@ struct netconn {
struct raw_pcb *raw;
} pcb;
/** 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 */
sys_sem_t op_completed;
/** mbox where received packets are stored until they are fetched
@ -142,8 +143,9 @@ struct netconn {
s16_t recv_avail;
#if LWIP_TCP
/** TCP: when data passed to netconn_write doesn't fit into the send buffer,
this temporarily stores the message. */
struct api_msg_msg *write_msg;
this temporarily stores the message.
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,
this temporarily stores how much is already sent. */
size_t write_offset;
@ -158,11 +160,21 @@ struct netconn {
netconn_callback callback;
};
/* Register an Network connection event */
/** Register an Network connection event */
#define API_EVENT(c,e,l) if (c->callback) { \
(*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: */
#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)

View File

@ -58,6 +58,8 @@ struct api_msg_msg {
/** The netconn which to process - always needed: it includes the semaphore
which is used to block the application thread until the function finished. */
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 */
union {
/** used for do_send */