Moved NUM_SOCKETS and struct lwip_sock to sockets_priv.h; added test case for fd_use count with select

This commit is contained in:
goldsimon
2017-06-13 21:07:34 +02:00
parent 85a85906d9
commit 35ba3a877d
3 changed files with 107 additions and 41 deletions

View File

@@ -48,6 +48,48 @@
extern "C" {
#endif
#define NUM_SOCKETS MEMP_NUM_NETCONN
/** This is overridable for the rare case where more than 255 threads
* select on the same socket...
*/
#ifndef SELWAIT_T
#define SELWAIT_T u8_t
#endif
union lwip_sock_lastdata {
struct netbuf *netbuf;
struct pbuf *pbuf;
};
/** Contains all internal pointers and states used for a socket */
struct lwip_sock {
/** sockets currently are built on netconns, each socket has one netconn */
struct netconn *conn;
/** data that was left from the previous read */
union lwip_sock_lastdata lastdata;
#if LWIP_SOCKET_SELECT
/** number of times data was received, set by event_callback(),
tested by the receive and select functions */
s16_t rcvevent;
/** number of times data was ACKed (free send buffer), set by event_callback(),
tested by select */
u16_t sendevent;
/** error happened for this socket, set by event_callback(), tested by select */
u16_t errevent;
/** counter of how many threads are waiting for this socket using select */
SELWAIT_T select_waiting;
#endif /* LWIP_SOCKET_SELECT */
#if LWIP_NETCONN_FULLDUPLEX
/* counter of how many threads are using a struct lwip_sock (not the 'int') */
u8_t fd_used;
/* status of pending close/delete actions */
u8_t fd_free_pending;
#define LWIP_SOCK_FD_FREE_TCP 1
#define LWIP_SOCK_FD_FREE_FREE 2
#endif
};
#if LWIP_SOCKET_SET_ERRNO
#ifndef set_errno
#define set_errno(err) do { if (err) { errno = (err); } } while(0)
@@ -92,6 +134,8 @@ struct lwip_setgetsockopt_data {
}
#endif
struct lwip_sock* lwip_socket_dbg_get_socket(int fd);
#endif /* LWIP_SOCKET */
#endif /* LWIP_HDR_SOCKETS_PRIV_H */