Skip to content

Commit 20cf435

Browse files
committed
Merge branch 'feature/config_to_disable_solink_at_socket_mt' into 'master'
Add configuration to enable/disable setting SO_LINGER default See merge request sdk/ESP8266_RTOS_SDK!693
2 parents cc8d13f + ac29fd2 commit 20cf435

File tree

3 files changed

+16
-2
lines changed

3 files changed

+16
-2
lines changed

components/lwip/Kconfig

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,17 @@ config LWIP_SOCKET_MULTITHREAD
6363
Enable the option can enable LWIP socket multithread and all
6464
function will be thread safe.
6565

66+
config SET_SOLINGER_DEFAULT
67+
bool "set socket SO_LINGER default"
68+
default y
69+
depends on LWIP_SOCKET_MULTITHREAD
70+
help
71+
The function is only used by socket multi-thread.
72+
73+
Enable this option can set the target socket to enable the "SO_LINGER" and config timeout to be "0" when it is created.
74+
It means that if close the socket, all send queue will be dropped, so heap memory can be collected immediately,
75+
but some packets which are waiting to be sent will lost.
76+
6677
config ESP_UDP_SYNC_SEND
6778
bool "LWIP socket UDP sync send"
6879
default y

components/lwip/apps/multi-threads/sockets_mt.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -522,6 +522,7 @@ static void lwip_sync_mt(int s, int how)
522522
} while (lock < SOCK_MT_LOCK_MAX);
523523
}
524524

525+
#if SET_SOLINGER_DEFAULT
525526
#if LWIP_SO_LINGER
526527
static void lwip_socket_set_so_link(int s, int linger)
527528
{
@@ -538,8 +539,8 @@ static void lwip_socket_set_so_link(int s, int linger)
538539
}
539540
#else
540541
#error "LWIP_SO_LINGER must be enable"
541-
#endif
542-
542+
#endif /* LWIP_SO_LINGER */
543+
#endif /* SET_SOLINGER_DEFAULT */
543544

544545
int lwip_socket(int domain, int type, int protocol)
545546
{

components/lwip/port/esp8266/include/lwipopts.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1452,6 +1452,8 @@ size_t memp_malloc_get_size(size_t type);
14521452
*/
14531453
#define LWIP_SO_LINGER 1
14541454

1455+
#define SET_SOLINGER_DEFAULT CONFIG_SET_SOLINGER_DEFAULT
1456+
14551457
/**
14561458
* If LWIP_SO_RCVBUF is used, this is the default value for recv_bufsize.
14571459
*/

0 commit comments

Comments
 (0)