Merge pull request #9331 from VeijoPesonen/bugfix-esp8266_udp_prevent_would_block

ESP8266: prevent WOULD BLOCK from TX if UDP
pull/9415/head
Martin Kojtal 2019-01-17 12:41:42 +01:00 committed by GitHub
commit b59b93e828
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 2 deletions

View File

@ -508,9 +508,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;
}
return status != NSAPI_ERROR_OK ? status : size;