mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
Merge branch 'bugfix/fix_ping_sock_return_error_v4.2' into 'release/v4.2'
ping_sock: Fix esp_ping_new_session may return ESP_OK when the error occured(backport v4.2) See merge request espressif/esp-idf!14846
This commit is contained in:
commit
6bb35ddf85
@ -208,7 +208,7 @@ static void esp_ping_thread(void *args)
|
||||
|
||||
esp_err_t esp_ping_new_session(const esp_ping_config_t *config, const esp_ping_callbacks_t *cbs, esp_ping_handle_t *hdl_out)
|
||||
{
|
||||
esp_err_t ret = ESP_OK;
|
||||
esp_err_t ret = ESP_FAIL;
|
||||
esp_ping_t *ep = NULL;
|
||||
PING_CHECK(config, "ping config can't be null", err, ESP_ERR_INVALID_ARG);
|
||||
PING_CHECK(hdl_out, "ping handle can't be null", err, ESP_ERR_INVALID_ARG);
|
||||
@ -259,10 +259,12 @@ esp_err_t esp_ping_new_session(const esp_ping_config_t *config, const esp_ping_c
|
||||
if(config->interface) {
|
||||
struct ifreq iface;
|
||||
if(netif_index_to_name(config->interface, iface.ifr_name) == NULL) {
|
||||
goto err;
|
||||
ESP_LOGE(TAG, "fail to find interface name with netif index %d", config->interface);
|
||||
goto err;
|
||||
}
|
||||
if(setsockopt(ep->sock, SOL_SOCKET, SO_BINDTODEVICE, &iface, sizeof(iface) !=0)) {
|
||||
goto err;
|
||||
ESP_LOGE(TAG, "fail to setsockopt SO_BINDTODEVICE");
|
||||
goto err;
|
||||
}
|
||||
}
|
||||
struct timeval timeout;
|
||||
|
Loading…
Reference in New Issue
Block a user