netconn/socket api: fixed bug #44225 "closing TCP socket should time out eventually", implemented task #6930 "Implement SO_LINGER": closing TCP sockets times out after 20 seconds or after the configured SND_TIMEOUT or depending on the linger settings; fixed that netconn_close/netconn_delete still used message passing for LWIP_TCPIP_CORE_LOCKING==1

This commit is contained in:
sg
2015-02-10 22:15:54 +01:00
parent ee833ea594
commit 6c3f6cfd89
7 changed files with 258 additions and 53 deletions

View File

@@ -214,6 +214,10 @@ struct netconn {
for UDP and RAW, used for FIONREAD */
int recv_avail;
#endif /* LWIP_SO_RCVBUF */
#if LWIP_SO_LINGER
/** values <0 mean linger is disabled, values > 0 are seconds to linger */
s16_t linger;
#endif /* LWIP_SO_LINGER */
/** flags holding more netconn-internal state, see NETCONN_FLAG_* defines */
u8_t flags;
#if LWIP_TCP

View File

@@ -113,6 +113,11 @@ struct api_msg_msg {
/** used for lwip_netconn_do_close (/shutdown) */
struct {
u8_t shut;
#if LWIP_SO_SNDTIMEO || LWIP_SO_LINGER
u32_t time_started;
#else /* LWIP_SO_SNDTIMEO || LWIP_SO_LINGER */
u8_t polls_left;
#endif /* LWIP_SO_SNDTIMEO || LWIP_SO_LINGER */
} sd;
#if LWIP_IGMP || (LWIP_IPV6 && LWIP_IPV6_MLD)
/** used for lwip_netconn_do_join_leave_group */

View File

@@ -1573,6 +1573,13 @@
#define LWIP_SO_RCVBUF 0
#endif
/**
* LWIP_SO_LINGER==1: Enable SO_LINGER processing.
*/
#ifndef LWIP_SO_LINGER
#define LWIP_SO_LINGER 0
#endif
/**
* If LWIP_SO_RCVBUF is used, this is the default value for recv_bufsize.
*/
@@ -1580,6 +1587,13 @@
#define RECV_BUFSIZE_DEFAULT INT_MAX
#endif
/**
* By default, TCP socket/netconn close waits 20 seconds max to send the FIN
*/
#ifndef LWIP_TCP_CLOSE_TIMEOUT_MS_DEFAULT
#define LWIP_TCP_CLOSE_TIMEOUT_MS_DEFAULT 20000
#endif
/**
* SO_REUSE==1: Enable SO_REUSEADDR option.
*/