fix(esp_http_server): prevent concurrent access to socket used in async http requests (GitHub PR)
Closes IDFGH-13263 and IDFGH-13053
See merge request espressif/esp-idf!32267
UDP application sends packet using esp_netif, underlying transport such
as Wi-Fi may drop the packet due to higher load. New error code
represent transient, non-fatal packet drop error. udp application may
use such errtype, for example to rate limit.
While not useful for the HTTP parser itself, this is very useful for
memory-limited consumers of the HTTP server API.
Signed-off-by: Harshit Malpani <harshit.malpani@espressif.com>
Event posting to the event loop should not hinder the working of
HTTP Client or HTTP Server. This commit add a config option to set
the timeout for posting the events to the loop.
Closes https://github.com/espressif/esp-idf/issues/13641
This resolves bug #13430 by allocating a new copy of resp_hdrs
when calling httpd_req_async_handler_begin(), thus preventing
invalid access to memory from async tasks.
* Users can now use libbsd string.h and sys/cdefs.h functionality
(e.g., strlcpy, containerof) on Linux by just including
string.h or sys/cdefs.h. In other words, the includes are the same
on the Linux target as well as on chips targets (ESP32, etc.).
* libbsd linking is done by the linux component (belongs to common
components) now instead of handling it separately in each component
Only pull in direct dependencies for the test apps, reducing build time
as well making it possible for CI to determine if the test should run or not
when dependencies are changed.
The HTTP server is not a critical component, it would be nice if we can
control the task caps by using configuration.
Signed-off-by: Alon Bar-Lev <alon.barlev@gmail.com>
Signed-off-by: Harshit Malpani <harshit.malpani@espressif.com>
This commit adds support for handling multiple requests simultaneously by introducing two new functions: `httpd_req_async_handler_begin()` and `httpd_req_async_handler_complete()`. These functions allow creating an asynchronous copy of a request that can be used on a separate thread and marking the asynchronous request as completed, respectively.
Additionally, a new flag `for_async_req` has been added to the `httpd_sess_t` struct to indicate if a socket is being used for an asynchronous request and should not be purged from the LRU cache.
An example have been added to demonstrate the usage of these new functions.
Closes https://github.com/espressif/esp-idf/issues/10594
Signed-off-by: Harshit Malpani <harshit.malpani@espressif.com>
linux/lwip: Wrap some IO posix functions
* to workaourd the FreeRTOS EINTR issue (when building without lwip)
* to correctly choose the sub-system based on fd (when building with
lwip) -- passing control to either linux/system or to lwip
This commit also addapts tapio-if to provide DHCP client by default and
configurable settings for static IP
For simultaneous HTTP and HTTPS server use-case, default configurations
set same control socket port and hence one of the server initialization
fails with an error "error in creating control socket".
This commit modifies default initializers to use different control
socket port in HTTP vs HTTPS server case.
Closes https://github.com/espressif/esp-idf/issues/10160
Closes IDFGH-8719
- The callback `open_fn` is used for creating a new SSL session
with httpd_sess_new.
- If the call fails, the active socket count (httpd_data->hd_sd_active_count)
is not incremented. But, httpd_sess_delete is called, which decrements the
count, resulting in a negative value for several failed session creations
in a row.
Closes https://github.com/espressif/esp-idf/issues/9683