mirror of
https://github.com/espressif/esp-idf.git
synced 2025-07-30 18:57:19 +02:00
Merge branch 'bugfix/httpd_session_close_lru_v4.1' into 'release/v4.1'
esp_http_server: Add flag in sock_db to identify httpd_sess_close is called from httpd_session_close_lru (v4.1) See merge request espressif/esp-idf!12113
This commit is contained in:
@ -69,6 +69,7 @@ struct sock_db {
|
|||||||
httpd_recv_func_t recv_fn; /*!< Receive function for this socket */
|
httpd_recv_func_t recv_fn; /*!< Receive function for this socket */
|
||||||
httpd_pending_func_t pending_fn; /*!< Pending function for this socket */
|
httpd_pending_func_t pending_fn; /*!< Pending function for this socket */
|
||||||
uint64_t lru_counter; /*!< LRU Counter indicating when the socket was last used */
|
uint64_t lru_counter; /*!< LRU Counter indicating when the socket was last used */
|
||||||
|
bool lru_socket; /*!< Flag indicating LRU socket */
|
||||||
char pending_data[PARSER_BLOCK_SIZE]; /*!< Buffer for pending data to be received */
|
char pending_data[PARSER_BLOCK_SIZE]; /*!< Buffer for pending data to be received */
|
||||||
size_t pending_len; /*!< Length of pending data to be received */
|
size_t pending_len; /*!< Length of pending data to be received */
|
||||||
};
|
};
|
||||||
|
@ -67,8 +67,6 @@ static esp_err_t httpd_accept_conn(struct httpd_data *hd, int listen_fd)
|
|||||||
close(new_fd);
|
close(new_fd);
|
||||||
return ESP_FAIL;
|
return ESP_FAIL;
|
||||||
}
|
}
|
||||||
httpd_sess_update_lru_counter(hd->hd_sd->handle, new_fd);
|
|
||||||
|
|
||||||
ESP_LOGD(TAG, LOG_FMT("complete"));
|
ESP_LOGD(TAG, LOG_FMT("complete"));
|
||||||
return ESP_OK;
|
return ESP_OK;
|
||||||
}
|
}
|
||||||
|
@ -348,6 +348,8 @@ esp_err_t httpd_sess_close_lru(struct httpd_data *hd)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
ESP_LOGD(TAG, LOG_FMT("fd = %d"), lru_fd);
|
ESP_LOGD(TAG, LOG_FMT("fd = %d"), lru_fd);
|
||||||
|
struct sock_db *sd = httpd_sess_get(hd, lru_fd);
|
||||||
|
sd->lru_socket = true;
|
||||||
return httpd_sess_trigger_close(hd, lru_fd);
|
return httpd_sess_trigger_close(hd, lru_fd);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -378,11 +380,12 @@ static void httpd_sess_close(void *arg)
|
|||||||
{
|
{
|
||||||
struct sock_db *sock_db = (struct sock_db *)arg;
|
struct sock_db *sock_db = (struct sock_db *)arg;
|
||||||
if (sock_db) {
|
if (sock_db) {
|
||||||
if (sock_db->lru_counter == 0) {
|
if (sock_db->lru_counter == 0 && !sock_db->lru_socket) {
|
||||||
ESP_LOGD(TAG, "Skipping session close for %d as it seems to be a race condition", sock_db->fd);
|
ESP_LOGD(TAG, "Skipping session close for %d as it seems to be a race condition", sock_db->fd);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
int fd = sock_db->fd;
|
int fd = sock_db->fd;
|
||||||
|
sock_db->lru_socket = false;
|
||||||
struct httpd_data *hd = (struct httpd_data *) sock_db->handle;
|
struct httpd_data *hd = (struct httpd_data *) sock_db->handle;
|
||||||
httpd_sess_delete(hd, fd);
|
httpd_sess_delete(hd, fd);
|
||||||
close(fd);
|
close(fd);
|
||||||
|
@ -223,6 +223,7 @@ static httpd_handle_t start_webserver(void)
|
|||||||
{
|
{
|
||||||
httpd_handle_t server = NULL;
|
httpd_handle_t server = NULL;
|
||||||
httpd_config_t config = HTTPD_DEFAULT_CONFIG();
|
httpd_config_t config = HTTPD_DEFAULT_CONFIG();
|
||||||
|
config.lru_purge_enable = true;
|
||||||
|
|
||||||
// Start the httpd server
|
// Start the httpd server
|
||||||
ESP_LOGI(TAG, "Starting server on port: '%d'", config.server_port);
|
ESP_LOGI(TAG, "Starting server on port: '%d'", config.server_port);
|
||||||
|
Reference in New Issue
Block a user