mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
ping_sock: Fix esp_ping_new_session may return ESP_OK when the error occured
Closes https://github.com/espressif/esp-idf/issues/7363
This commit is contained in:
parent
1fd56e0b87
commit
e9dab3203e
@ -214,7 +214,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);
|
||||
@ -272,10 +272,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…
x
Reference in New Issue
Block a user