nodemcu-firmware/components/modules
Johny Mattsson f44e6e9639 Fix net module data loss & RTOS task unsafety (#2829)
To avoid races between the lwIP callbacks (lwIP RTOS task) and the Lua
handlers (LVM RTOS task), the data flow and ownership has been simplified
and cleaned up.

lwIP callbacks now have no visibility of the userdata struct. They are
limited to creating small event objects and task_post()ing them over
to the LVM "thread", passing ownership in doing so. The shared identifier
then becomes the struct netconn*.

On the LVM side, we keep a linked list of active userdata objects. This
allows us to retrieve the correct userdata when we get an event with
a netconn pointer. Because this list is only ever used within the LVM
task, no locking is necessary.

The old approach of stashing a userdata pointer into the 'socket' field
on the netconn has been removed entirely, as this was both not
thread/RTOS-task safe, and also interfered with the IDFs internal use
of the socket field (even when using only the netconn layer). As an
added benefit, this removed the need for all the SYS_ARCH_PROTECT()
locking stuff.

The need to track receive events before the corresponding userdata object
has been established has been removed by virtue of not reordering the
"accept" and the "recv" events any more (previously accepts were posted
with medium priority, while the receives where high priority, leading
to the observed reordering and associated headaches).

The workaround for IDF issue 784 has been removed as it is now not needed
and is in fact directly harmful as it results in a double-free. Yay for
getting rid of old workarounds!

DNS resolution code paths were merged for the two instances of "socket"
initiated resolves (connect/dns functions).

Also fixed an instance of using a stack variable for receiving the resolved
IP address, with said variable going out of scope before the DNS resolution
necessarily completed (hello, memory corruption!).

Where possible, moved to use the Lua allocator rather than plain malloc.

Finally, the NodeMCU task posting mechanism got a polish and an adjustment.
Given all the Bad(tm) that tends to happen if something fails task posting,
I went through a couple of iterations on how to avoid that. Alas, the
preferred solution of blocking non-LVM RTOS tasks until a slot is free
turned out to not be viable, as this easily resulted in deadlocks with the
lwIP stack. After much deliberation I settled on increasing the number of
available queue slots for the task_post() mechanism, but in the interest
of user control also now made it user configurable via Kconfig.
2019-07-14 23:20:20 +02:00
..
Kconfig OTA support for ESP32 (#2812) 2019-07-06 14:21:08 +02:00
adc.c ADC extension for ESP32 (#1927) 2017-04-24 21:36:01 +02:00
bit.c Imported 'bit' module from dev branch. 2016-11-17 21:56:51 +11:00
bthci.c Updated ESP-IDF to latest. 2018-10-07 12:33:40 +02:00
can.c ESP32: CAN module (#1958) 2017-05-07 09:35:17 +02:00
common.c Port i2s, spi_master, and ledc to helper functions for option tables (#2577) 2018-12-02 16:20:45 +01:00
common.h Port i2s, spi_master, and ledc to helper functions for option tables (#2577) 2018-12-02 16:20:45 +01:00
component.mk Add ucg module. 2018-10-07 16:31:28 +02:00
crypto.c Improved crypto module for ESP32, now with HMAC (#2815) 2019-07-04 23:24:59 +02:00
dac.c add dac module 2018-10-14 12:29:30 +02:00
dht.c fix unitialized value error in release build 2017-04-21 14:53:54 +02:00
encoder.c ESP32: fix memory leak in encoder.fromHex and avoid use luaM_free (#2610) 2019-01-17 12:09:09 +01:00
file.c fix unref default file descriptor while still in use 2019-07-03 23:54:08 +02:00
gpio.c Fix gpio pin mask generation and clarify available gpios. (#1965) 2017-05-12 11:10:44 +10:00
http.c fix memory leak in http one-shot requests (#2615) 2019-01-16 21:22:07 +01:00
i2c.c first draft implementation of i2c slave 2017-03-02 21:37:13 +01:00
i2c_common.h first draft implementation of i2c slave 2017-03-02 21:37:13 +01:00
i2c_hw_master.c refine ack handling for i2c hw master 2017-03-08 16:38:43 +01:00
i2c_hw_slave.c correct portYIELD 2017-03-02 21:37:32 +01:00
i2s.c Port i2s, spi_master, and ledc to helper functions for option tables (#2577) 2018-12-02 16:20:45 +01:00
ledc.c Port i2s, spi_master, and ledc to helper functions for option tables (#2577) 2018-12-02 16:20:45 +01:00
mqtt.c mqtt: add ceritificate handling to support server verification and mutual authentication (#2657) 2019-02-12 23:10:25 +01:00
net.c Fix net module data loss & RTOS task unsafety (#2829) 2019-07-14 23:20:20 +02:00
node.c node: node.output() (#2637) 2019-01-31 22:03:41 +01:00
otaupgrade.c OTA support for ESP32 (#2812) 2019-07-06 14:21:08 +02:00
ow.c Add ow module. 2017-03-17 07:50:31 +01:00
pulsecnt.c ESP32: Pulse counter module released (#2739) 2019-06-12 22:34:24 +02:00
qrcodegen.c Adding qrcodegen module for generating QR Codes (#2543) 2018-11-15 22:17:43 +01:00
sdmmc.c add support for sdmmc cards in sd-spi mode (#2644) 2019-02-10 10:11:13 +01:00
sigma_delta.c fix sigma_delta component naming 2017-03-07 23:05:09 +01:00
sjson.c ESP32: Add SJSON module (#2562) 2018-11-22 20:58:27 +01:00
sodium.c ESP32: Add Sodium module (#2550) 2018-11-15 18:04:00 +01:00
spi.c Add spi master. 2017-05-14 18:00:40 +02:00
spi_common.h Add u8g2 module. 2017-06-13 18:38:09 +02:00
spi_master.c add support for sdmmc cards in sd-spi mode (#2644) 2019-02-10 10:11:13 +01:00
struct.c Unbreak integer build. 2016-11-17 21:59:56 +11:00
time.c ESP32: Add time module (#2561) 2018-11-26 21:03:23 +01:00
tmr.c fix tmr.interval() 2017-03-09 23:31:02 +01:00
u8g2.c update to u8g2 2.25.10 2019-04-28 22:26:37 +02:00
ucg.c fix ucg compile for u8g2 & !ucg 2019-04-28 16:18:43 +02:00
uppercase.mk Successfully boot barebones NodeMCU on ESP32 (only). 2016-09-20 13:35:56 +10:00
wifi.c WiFi module documentation and updates. 2017-01-03 12:57:45 +11:00
wifi_ap.c fix compile warnings for ipaddr_aton 2019-06-21 18:01:20 +02:00
wifi_common.c Added functions wifi.sta.getmac() and wifi.ap.getmac() 2017-06-30 23:55:43 +02:00
wifi_common.h Added functions wifi.sta.getmac() and wifi.ap.getmac() 2017-06-30 23:55:43 +02:00
wifi_sta.c fix compile warnings for ipaddr_aton 2019-06-21 18:01:20 +02:00
ws2812.c fix ws2812 doc 2017-04-27 22:42:10 +02:00