dropbear: cherry-pick upstream patches
[openwrt/staging/robimarko.git] / package / network / services / dropbear / patches / 010-remove-SO_LINGER.patch
1 From 5040f21cb4ee6ade966e60c6d5a3c270d03de1f1 Mon Sep 17 00:00:00 2001
2 From: Matt Johnston <matt@ucc.asn.au>
3 Date: Mon, 1 May 2023 22:05:43 +0800
4 Subject: Remove SO_LINGER
5
6 It could cause channels to take up to 5 seconds to close(), which would block
7 the entire process. On busy TCP forwarding sessions this would result in
8 channels seeming stuck and new connections not being accepted.
9
10 We don't need to monitor for flushing failures since we can't report errors, so
11 SO_LINGER wasn't useful.
12
13 Thanks to GektorUA for reporting and testing
14
15 Fixes #230
16 ---
17 netio.c | 4 ----
18 1 file changed, 4 deletions(-)
19
20 --- a/netio.c
21 +++ b/netio.c
22 @@ -472,7 +472,6 @@ int dropbear_listen(const char* address,
23 struct addrinfo hints, *res = NULL, *res0 = NULL;
24 int err;
25 unsigned int nsock;
26 - struct linger linger;
27 int val;
28 int sock;
29 uint16_t *allocated_lport_p = NULL;
30 @@ -551,9 +550,6 @@ int dropbear_listen(const char* address,
31 val = 1;
32 /* set to reuse, quick timeout */
33 setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, (void*) &val, sizeof(val));
34 - linger.l_onoff = 1;
35 - linger.l_linger = 5;
36 - setsockopt(sock, SOL_SOCKET, SO_LINGER, (void*)&linger, sizeof(linger));
37
38 #if defined(IPPROTO_IPV6) && defined(IPV6_V6ONLY)
39 if (res->ai_family == AF_INET6) {