sys_arch.txt, api.h, api_lib.c, api_msg.h, api_msg.c, tcpip.c, sys.h, opt.h: Introduce changes for task #7490 "Add return value to sys_mbox_post" with some modifications in the sys_mbox api: sys_mbox_new take a "size" parameters which indicate the number of pointers query by the mailbox. There is three defines in opt.h to indicate sizes for tcpip::mbox, netconn::recvmbox, and for the netconn::acceptmbox. Port maintainers, you can decide to just add this new parameter in your implementation, but to ignore it to keep the previous behavior. The new sys_mbox_trypost function return a value to know if the mailbox is full or if the message is posted. Take a look to sys_arch.txt for more details. This new function is used in tcpip_input (so, can be called in an interrupt context since the function is not blocking), and in recv_udp and recv_raw.

This commit is contained in:
fbernon
2008-01-05 21:10:32 +00:00
parent caa1834b70
commit 5941b3c86e
9 changed files with 87 additions and 22 deletions

View File

@@ -98,6 +98,10 @@ struct ip_pcb;
struct tcp_pcb;
struct udp_pcb;
struct raw_pcb;
struct netconn;
/** A callback prototype to inform about events for a netconn */
typedef void (* netconn_callback)(struct netconn *, enum netconn_evt, u16_t len);
/** A netconn descriptor */
struct netconn {
@@ -148,7 +152,7 @@ struct netconn {
u8_t write_delayed;
#endif /* LWIP_TCPIP_CORE_LOCKING */
/** A callback function that is informed about events for this netconn */
void (* callback)(struct netconn *, enum netconn_evt, u16_t len);
netconn_callback callback;
};
/* Register an Network connection event */
@@ -161,7 +165,7 @@ struct netconn {
#define netconn_new_with_callback(t, c) netconn_new_with_proto_and_callback(t, 0, c)
struct
netconn *netconn_new_with_proto_and_callback(enum netconn_type t, u8_t proto,
void (*callback)(struct netconn *, enum netconn_evt, u16_t len));
netconn_callback callback);
err_t netconn_delete (struct netconn *conn);
enum netconn_type netconn_type (struct netconn *conn);

View File

@@ -148,9 +148,7 @@ void do_join_leave_group( struct api_msg_msg *msg);
void do_gethostbyname(void *arg);
#endif /* LWIP_DNS */
struct netconn* netconn_alloc(
enum netconn_type t,
void (*callback)(struct netconn *, enum netconn_evt, u16_t len));
struct netconn* netconn_alloc(enum netconn_type t, netconn_callback callback);
#ifdef __cplusplus
}

View File

@@ -874,6 +874,15 @@
#define TCPIP_THREAD_PRIO 1
#endif
/**
* TCPIP_MBOX_SIZE: The mailbox size for the tcpip thread messages
* The queue size value itself is platform-dependent, but is passed to
* sys_mbox_new() when tcpip_init is called.
*/
#ifndef TCPIP_MBOX_SIZE
#define TCPIP_MBOX_SIZE 0
#endif
/**
* SLIPIF_THREAD_NAME: The name assigned to the slipif_loop thread.
*/
@@ -949,6 +958,24 @@
#define DEFAULT_THREAD_PRIO 1
#endif
/**
* DEFAULT_RECVMBOX_SIZE: The mailbox size for the incoming packets.
* The queue size value itself is platform-dependent, but is passed to
* sys_mbox_new() when the recvmbox is created.
*/
#ifndef DEFAULT_RECVMBOX_SIZE
#define DEFAULT_RECVMBOX_SIZE 0
#endif
/**
* DEFAULT_ACCEPTMBOX_SIZE: The mailbox size for the incoming connections.
* The queue size value itself is platform-dependent, but is passed to
* sys_mbox_new() when the acceptmbox is created.
*/
#ifndef DEFAULT_ACCEPTMBOX_SIZE
#define DEFAULT_ACCEPTMBOX_SIZE 0
#endif
/*
----------------------------------------------
---------- Sequential layer options ----------

View File

@@ -56,9 +56,11 @@ struct sys_timeo {u8_t dummy;};
#define sys_sem_wait_timeout(s,t)
#define sys_arch_sem_wait(s,t)
#define sys_sem_free(s)
#define sys_mbox_new() 0
#define sys_mbox_new(s) 0
#define sys_mbox_fetch(m,d)
#define sys_mbox_tryfetch(m,d)
#define sys_mbox_post(m,d)
#define sys_mbox_trypost(m,d)
#define sys_mbox_free(m)
#define sys_thread_new(n,t,a,s,p)
@@ -73,6 +75,7 @@ struct sys_timeo {u8_t dummy;};
*/
#define SYS_MBOX_EMPTY SYS_ARCH_TIMEOUT
#include "lwip/err.h"
#include "arch/sys_arch.h"
typedef void (* sys_timeout_handler)(void *arg);
@@ -121,8 +124,9 @@ u32_t sys_jiffies(void); /* since power up. */
#endif
/* Mailbox functions. */
sys_mbox_t sys_mbox_new(void);
sys_mbox_t sys_mbox_new(int size);
void sys_mbox_post(sys_mbox_t mbox, void *msg);
err_t sys_mbox_trypost(sys_mbox_t mbox, void *msg);
u32_t sys_arch_mbox_fetch(sys_mbox_t mbox, void **msg, u32_t timeout);
#ifndef sys_arch_mbox_tryfetch /* Allow port to override with a macro */
u32_t sys_arch_mbox_tryfetch(sys_mbox_t mbox, void **msg);