Fix crash with fast ping on espressif #7938
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
espressif: check return value from esp_ping_new_session
esp_ping_new_session can fail, particularly if ping is called quickly many times in succession.
This is because
esp_ping_new_session
has to do a bunch of stuff including creating a task and a socket. Callingesp_ping_delete_session
doesn't clean up these resources immediately. Instead, it signals the task to clean up resources and exit 'soon', but 'soon' is defined as 1 second.When the calls are frequent, the in-use sockets and tasks fill up available slots—I didn't actually check which resource gets used up first.
With this change, the ping call will raise an exception instead of continuing with a call to esp_ping_start that crashes:
Closes #5980 based on my testing on an ESP32S3-N8R2.