mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
Merge branch 'bugfix/add_so_linger_to_httpd_config' into 'master'
esp_http_server: Add struct linger in httpd_config_t Closes IDFGH-8004 See merge request espressif/esp-idf!20142
This commit is contained in:
commit
787c69a2cc
@ -40,6 +40,8 @@ initializer that should be kept in sync
|
|||||||
.global_user_ctx_free_fn = NULL, \
|
.global_user_ctx_free_fn = NULL, \
|
||||||
.global_transport_ctx = NULL, \
|
.global_transport_ctx = NULL, \
|
||||||
.global_transport_ctx_free_fn = NULL, \
|
.global_transport_ctx_free_fn = NULL, \
|
||||||
|
.enable_so_linger = false, \
|
||||||
|
.linger_timeout = 0, \
|
||||||
.open_fn = NULL, \
|
.open_fn = NULL, \
|
||||||
.close_fn = NULL, \
|
.close_fn = NULL, \
|
||||||
.uri_match_fn = NULL \
|
.uri_match_fn = NULL \
|
||||||
@ -185,6 +187,9 @@ typedef struct httpd_config {
|
|||||||
*/
|
*/
|
||||||
httpd_free_ctx_fn_t global_transport_ctx_free_fn;
|
httpd_free_ctx_fn_t global_transport_ctx_free_fn;
|
||||||
|
|
||||||
|
bool enable_so_linger; /*!< bool to enable/disable linger */
|
||||||
|
int linger_timeout; /*!< linger timeout (in seconds) */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Custom session opening callback.
|
* Custom session opening callback.
|
||||||
*
|
*
|
||||||
|
@ -354,6 +354,13 @@ void httpd_sess_delete(struct httpd_data *hd, struct sock_db *session)
|
|||||||
}
|
}
|
||||||
|
|
||||||
ESP_LOGD(TAG, LOG_FMT("fd = %d"), session->fd);
|
ESP_LOGD(TAG, LOG_FMT("fd = %d"), session->fd);
|
||||||
|
if (hd->config.enable_so_linger) {
|
||||||
|
struct linger so_linger = {
|
||||||
|
.l_onoff = true,
|
||||||
|
.l_linger = hd->config.linger_timeout,
|
||||||
|
};
|
||||||
|
setsockopt(session->fd, SOL_SOCKET, SO_LINGER, &so_linger, sizeof(struct linger));
|
||||||
|
}
|
||||||
|
|
||||||
// Call close function if defined
|
// Call close function if defined
|
||||||
if (hd->config.close_fn) {
|
if (hd->config.close_fn) {
|
||||||
|
Loading…
Reference in New Issue
Block a user