Skip to content

ESP8266: prevent WOULD BLOCK from TX if UDP #9331

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 17, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions components/wifi/esp8266-driver/ESP8266Interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -505,9 +505,11 @@ int ESP8266Interface::socket_send(void *handle, const void *data, unsigned size)
} while ((sendStartTime - rtos::Kernel::get_ms_count() < 50)
&& (status != NSAPI_ERROR_OK));

if (status == NSAPI_ERROR_WOULD_BLOCK) {
debug("Enqueuing the event call");
if (status == NSAPI_ERROR_WOULD_BLOCK && socket->proto == NSAPI_TCP) {
tr_debug("ESP8266Interface::socket_send(): enqueuing the event call");
_global_event_queue->call_in(100, callback(this, &ESP8266Interface::event));
} else if (status == NSAPI_ERROR_WOULD_BLOCK && socket->proto == NSAPI_UDP) {
status = NSAPI_ERROR_DEVICE_ERROR;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need to modify the NSAPI_ERROR_WOULD_BLOCK to become NSAPI_ERROR_DEVICE_ERROR?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think because UDP sending should never fail.

}

return status != NSAPI_ERROR_OK ? status : size;
Expand Down