From 8026e7acc769a21fe67c538631adfffa89163c59 Mon Sep 17 00:00:00 2001 From: "hrushikesh.bhosale" Date: Mon, 2 Jun 2025 17:19:24 +0530 Subject: [PATCH] docs(http_server): Updated the http_server doc regarding thread safety Updated the http_server documentation mentioning that, APIs used in http_server aren't thread safe Closes https://github.com/espressif/esp-idf/issues/15877 --- docs/en/api-reference/protocols/esp_http_server.rst | 2 ++ docs/en/api-reference/protocols/esp_https_server.rst | 2 ++ docs/zh_CN/api-reference/protocols/esp_http_server.rst | 2 ++ docs/zh_CN/api-reference/protocols/esp_https_server.rst | 2 ++ 4 files changed, 8 insertions(+) diff --git a/docs/en/api-reference/protocols/esp_http_server.rst b/docs/en/api-reference/protocols/esp_http_server.rst index 05ade6d866..458ed327e2 100644 --- a/docs/en/api-reference/protocols/esp_http_server.rst +++ b/docs/en/api-reference/protocols/esp_http_server.rst @@ -12,6 +12,8 @@ The HTTP Server component provides an ability for running a lightweight web serv * :cpp:func:`httpd_stop`: This stops the server with the provided handle and frees up any associated memory/resources. This is a blocking function that first signals a halt to the server task and then waits for the task to terminate. While stopping, the task closes all open connections, removes registered URI handlers and resets all session context data to empty. * :cpp:func:`httpd_register_uri_handler`: A URI handler is registered by passing object of type ``httpd_uri_t`` structure which has members including ``uri`` name, ``method`` type (eg. ``HTTP_GET/HTTP_POST/HTTP_PUT`` etc.), function pointer of type ``esp_err_t *handler (httpd_req_t *req)`` and ``user_ctx`` pointer to user context data. +.. note:: APIs in the HTTP server are not thread-safe. If thread safety is required, it is the responsibility of the application layer to ensure proper synchronization between multiple tasks. + Application Examples -------------------- diff --git a/docs/en/api-reference/protocols/esp_https_server.rst b/docs/en/api-reference/protocols/esp_https_server.rst index 20fa05c996..072de49193 100644 --- a/docs/en/api-reference/protocols/esp_https_server.rst +++ b/docs/en/api-reference/protocols/esp_https_server.rst @@ -32,6 +32,8 @@ The following APIs of :doc:`esp_http_server` should not be used with :doc:`esp_h Everything else can be used without limitations. +.. note:: APIs in the HTTPS server are not thread-safe. If thread safety is required, it is the responsibility of the application layer to ensure proper synchronization between multiple tasks. + Usage ----- diff --git a/docs/zh_CN/api-reference/protocols/esp_http_server.rst b/docs/zh_CN/api-reference/protocols/esp_http_server.rst index 7fcefc568b..842719283e 100644 --- a/docs/zh_CN/api-reference/protocols/esp_http_server.rst +++ b/docs/zh_CN/api-reference/protocols/esp_http_server.rst @@ -12,6 +12,8 @@ HTTP Server 组件提供了在 ESP32 上运行轻量级 Web 服务器的功能 * :cpp:func:`httpd_stop`: 根据传入的句柄停止服务器,并释放相关联的内存和资源。这是一个阻塞函数,首先给服务器任务发送停止信号,然后等待其终止。期间服务器任务会关闭所有已打开的连接,删除已注册的 URI 处理程序,并将所有会话的上下文数据重置为空。 * :cpp:func:`httpd_register_uri_handler`: 通过传入 ``httpd_uri_t`` 结构体类型的对象来注册 URI 处理程序。该结构体包含如下成员:``uri`` 名字,``method`` 类型(比如 ``HTTP_GET/HTTP_POST/HTTP_PUT`` 等等), ``esp_err_t *handler (httpd_req_t *req)`` 类型的函数指针,指向用户上下文数据的 ``user_ctx`` 指针。 +.. note:: HTTP Server 组件的 API 并不是线程安全的。如果需要线程安全,应用层需自行确保在多个任务之间进行适当的同步。 + 应用示例 -------- diff --git a/docs/zh_CN/api-reference/protocols/esp_https_server.rst b/docs/zh_CN/api-reference/protocols/esp_https_server.rst index eb6ba23a9b..9b45adddbf 100644 --- a/docs/zh_CN/api-reference/protocols/esp_https_server.rst +++ b/docs/zh_CN/api-reference/protocols/esp_https_server.rst @@ -32,6 +32,8 @@ API 说明 其他 API 均可使用,没有其他限制。 +.. note:: HTTPS 服务器的 API 并不是线程安全的。如果需要线程安全,应用层需自行确保在多个任务之间进行适当的同步。 + 如何使用 ---------