esp_http_server: Add lru_socket flag in sock_db to indicate httpd_sess_close is called from httpd_sess_close_lru

This commit is contained in:
Shubham Kulkarni
2020-11-30 12:33:31 +05:30
committed by bot
parent b94c99a033
commit 00876a8946
3 changed files with 5 additions and 3 deletions

View File

@@ -350,6 +350,8 @@ esp_err_t httpd_sess_close_lru(struct httpd_data *hd)
}
}
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);
}
@@ -380,11 +382,12 @@ static void httpd_sess_close(void *arg)
{
struct sock_db *sock_db = (struct sock_db *)arg;
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);
return;
}
int fd = sock_db->fd;
sock_db->lru_socket = false;
struct httpd_data *hd = (struct httpd_data *) sock_db->handle;
httpd_sess_delete(hd, fd);
close(fd);