mirror of
https://github.com/espressif/esp-idf.git
synced 2025-08-04 13:14:32 +02:00
esp-tls: Separate timeout_ms conditional judgement from keep alive
This commit is contained in:
@@ -196,16 +196,18 @@ static void ms_to_timeval(int timeout_ms, struct timeval *tv)
|
||||
|
||||
static esp_err_t esp_tls_set_socket_options(int fd, const esp_tls_cfg_t *cfg)
|
||||
{
|
||||
if (cfg && cfg->timeout_ms >= 0) {
|
||||
struct timeval tv;
|
||||
ms_to_timeval(cfg->timeout_ms, &tv);
|
||||
if (setsockopt(fd, SOL_SOCKET, SO_RCVTIMEO, &tv, sizeof(tv)) != 0) {
|
||||
ESP_LOGE(TAG, "Fail to setsockopt SO_RCVTIMEO");
|
||||
return ESP_ERR_ESP_TLS_SOCKET_SETOPT_FAILED;
|
||||
}
|
||||
if (setsockopt(fd, SOL_SOCKET, SO_SNDTIMEO, &tv, sizeof(tv)) != 0) {
|
||||
ESP_LOGE(TAG, "Fail to setsockopt SO_SNDTIMEO");
|
||||
return ESP_ERR_ESP_TLS_SOCKET_SETOPT_FAILED;
|
||||
if (cfg) {
|
||||
if (cfg->timeout_ms >= 0) {
|
||||
struct timeval tv;
|
||||
ms_to_timeval(cfg->timeout_ms, &tv);
|
||||
if (setsockopt(fd, SOL_SOCKET, SO_RCVTIMEO, &tv, sizeof(tv)) != 0) {
|
||||
ESP_LOGE(TAG, "Fail to setsockopt SO_RCVTIMEO");
|
||||
return ESP_ERR_ESP_TLS_SOCKET_SETOPT_FAILED;
|
||||
}
|
||||
if (setsockopt(fd, SOL_SOCKET, SO_SNDTIMEO, &tv, sizeof(tv)) != 0) {
|
||||
ESP_LOGE(TAG, "Fail to setsockopt SO_SNDTIMEO");
|
||||
return ESP_ERR_ESP_TLS_SOCKET_SETOPT_FAILED;
|
||||
}
|
||||
}
|
||||
if (cfg->keep_alive_cfg && cfg->keep_alive_cfg->keep_alive_enable) {
|
||||
int keep_alive_enable = 1;
|
||||
|
Reference in New Issue
Block a user