8000 extmod/lwip-include: Increase number of lwIP timers when mDNS enabled. · sparkfun/micropython@aef6705 · GitHub
[go: up one dir, main page]

Skip to content

Commit aef6705

Browse files
tpwrulesdpgeorge
authored andcommitted
extmod/lwip-include: Increase number of lwIP timers when mDNS enabled.
Despite the code comments claiming one is sufficient, the mDNS application is capable of using up to twelve timers. Three per IP protocol are started at once in `mdns_start_multicast_timeouts_ipvX`, then another two per protocol can be started in `mdns_handle_question`. Further timers can be started for two additional callbacks. Having certain timers, such as `MDNS_MULTICAST_TIMEOUT`, fail to start due to none being free will break mDNS forever as the app will never realize it's safe to transmit a packet. Therefore, this commit goes somewhat overkill and allocates the maximal amount of timers; it's uncertain if all can run simultaneously, or how many callback timers are needed. Each timer struct is 16 bytes on standard 32 bit builds. Plus, say, 8 bytes of allocater overhead, that's 288 more bytes of RAM used which shouldn't be too horrible. Users who don't need mDNS can manually disable it to recover the RAM if necessary. This fixes mDNS on W5500_EVB_PICO (among other boards). Before, mDNS would work for a bit after connection until the host's cache expired a minute or two later. Then the board would never respond to further queries. With this patch, all works well. Signed-off-by: Thomas Watson <twatson52@icloud.com>
1 parent 842e361 commit aef6705

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

extmod/lwip-include/lwipopts_common.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,9 @@
6565

6666
#define LWIP_NUM_NETIF_CLIENT_DATA LWIP_MDNS_RESPONDER
6767
#define MEMP_NUM_UDP_PCB (4 + LWIP_MDNS_RESPONDER)
68-
#define MEMP_NUM_SYS_TIMEOUT (LWIP_NUM_SYS_TIMEOUT_INTERNAL + LWIP_MDNS_RESPONDER)
68+
69+
// The mDNS responder requires 5 timers per IP version plus 2 others. Not having enough silently breaks it.
70+
#define MEMP_NUM_SYS_TIMEOUT (LWIP_NUM_SYS_TIMEOUT_INTERNAL + (LWIP_MDNS_RESPONDER * (2 + (5 * (LWIP_IPV4 + LWIP_IPV6)))))
6971

7072
#define SO_REUSE 1
7173
#define TCP_LISTEN_BACKLOG 1

0 commit comments

Comments
 (0)
0