From 4b815eece9825629588d18e8703a4fd3e148bf41 Mon Sep 17 00:00:00 2001 From: goldsimon Date: Mon, 3 Aug 2015 10:15:29 +0200 Subject: [PATCH] added lwip_socket_thread_init/cleanup to use LWIP_NETCONN_SEM_PER_THREAD/LWIP_NETCONN_FULLDUPLEX without including anything but sockets.h --- src/api/sockets.c | 16 +++++++++++++++- src/include/lwip/sockets.h | 2 ++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/api/sockets.c b/src/api/sockets.c index 165fbbaf..96abf448 100644 --- a/src/api/sockets.c +++ b/src/api/sockets.c @@ -276,7 +276,7 @@ static void lwip_socket_drop_registered_memberships(int s); static struct lwip_sock sockets[NUM_SOCKETS]; /** The global list of tasks waiting for select */ static struct lwip_select_cb *select_cb_list; -/** This counter is increased from lwip_select when the list is chagned +/** This counter is increased from lwip_select when the list is changed and checked in event_callback to see if it has changed. */ static volatile int select_cb_ctr; @@ -346,6 +346,20 @@ sockaddr_to_ipaddr_port(const struct sockaddr* sockaddr, ip_addr_t* ipaddr, u16_ } #endif /* LWIP_IPV4 && LWIP_IPV6 */ +/** LWIP_NETCONN_SEM_PER_THREAD==1: initialize thread-local semaphore */ +void +lwip_socket_thread_init(void) +{ + netconn_thread_init(); +} + +/** LWIP_NETCONN_SEM_PER_THREAD==1: destroy thread-local semaphore */ +void +lwip_socket_thread_cleanup(void) +{ + netconn_thread_cleanup(); +} + /** * Map a externally used socket index to the internal socket representation. * diff --git a/src/include/lwip/sockets.h b/src/include/lwip/sockets.h index 4321979b..f74fa096 100644 --- a/src/include/lwip/sockets.h +++ b/src/include/lwip/sockets.h @@ -421,6 +421,8 @@ struct timeval { #endif /* LWIP_TIMEVAL_PRIVATE */ #define lwip_socket_init() /* Compatibility define, no init needed. */ +void lwip_socket_thread_init(void); /* LWIP_NETCONN_SEM_PER_THREAD==1: initialize thread-local semaphore */ +void lwip_socket_thread_cleanup(void); /* LWIP_NETCONN_SEM_PER_THREAD==1: destroy thread-local semaphore */ int lwip_accept(int s, struct sockaddr *addr, socklen_t *addrlen); int lwip_bind(int s, const struct sockaddr *name, socklen_t namelen);