Merge pull request #9799 from VeijoPesonen/bugfix-esp8266-dns

Increase events.share-eventsize to 768B because of ESP8266 AT driver and asynchronous DNS
pull/9876/head
Martin Kojtal 2019-02-27 11:30:38 +01:00 committed by GitHub
commit 6bdbe754cd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 25 additions and 8 deletions

View File

@ -21,6 +21,7 @@ set(unittest-test-sources
stubs/mbed_critical_stub.c
stubs/equeue_stub.c
stubs/EventQueue_stub.cpp
stubs/mbed_error.c
stubs/mbed_shared_queues_stub.cpp
stubs/nsapi_dns_stub.cpp
stubs/EventFlags_stub.cpp

View File

@ -24,6 +24,7 @@ set(unittest-test-sources
stubs/mbed_assert_stub.c
stubs/equeue_stub.c
stubs/EventQueue_stub.cpp
stubs/mbed_error.c
stubs/mbed_shared_queues_stub.cpp
stubs/nsapi_dns_stub.cpp
stubs/EventFlags_stub.cpp

View File

@ -25,6 +25,7 @@ set(unittest-test-sources
stubs/mbed_critical_stub.c
stubs/equeue_stub.c
stubs/EventQueue_stub.cpp
stubs/mbed_error.c
stubs/mbed_shared_queues_stub.cpp
stubs/nsapi_dns_stub.cpp
stubs/EventFlags_stub.cpp

View File

@ -22,6 +22,7 @@ set(unittest-test-sources
stubs/mbed_critical_stub.c
stubs/equeue_stub.c
stubs/EventQueue_stub.cpp
stubs/mbed_error.c
stubs/mbed_shared_queues_stub.cpp
stubs/nsapi_dns_stub.cpp
stubs/EventFlags_stub.cpp

View File

@ -22,6 +22,7 @@ set(unittest-test-sources
stubs/mbed_critical_stub.c
stubs/equeue_stub.c
stubs/EventQueue_stub.cpp
stubs/mbed_error.c
stubs/mbed_shared_queues_stub.cpp
stubs/EventFlags_stub.cpp
stubs/nsapi_dns_stub.cpp

View File

@ -181,10 +181,9 @@ void ESP8266Interface::_connect_async()
} else {
// Postpone to give other stuff time to run
_connect_event_id = _global_event_queue->call_in(ESP8266_CONNECT_TIMEOUT, callback(this, &ESP8266Interface::_connect_async));
if (!_connect_event_id) {
MBED_ERROR(MBED_MAKE_ERROR(MBED_MODULE_DRIVER, MBED_ERROR_CODE_ENOMEM), \
"_connect_async(): unable to add event to queue");
"ESP8266Interface::_connect_async(): unable to add event to queue. Increase \"events.shared-eventsize\"\n");
}
}
_cmutex.unlock();
@ -228,7 +227,7 @@ int ESP8266Interface::connect()
if (!_connect_event_id) {
MBED_ERROR(MBED_MAKE_ERROR(MBED_MODULE_DRIVER, MBED_ERROR_CODE_ENOMEM), \
"connect(): unable to add event to queue");
"connect(): unable to add event to queue. Increase \"events.shared-eventsize\"\n");
}
while (_if_blocking && (_conn_status_to_error() != NSAPI_ERROR_IS_CONNECTED)
@ -586,7 +585,11 @@ int ESP8266Interface::socket_send(void *handle, const void *data, unsigned size)
&& socket->proto == NSAPI_TCP
&& core_util_atomic_cas_u8(&_cbs[socket->id].deferred, &expect_false, true)) {
tr_debug("Postponing SIGIO from the device");
_global_event_queue->call_in(50, callback(this, &ESP8266Interface::event_deferred));
if (!_global_event_queue->call_in(50, callback(this, &ESP8266Interface::event_deferred))) {
MBED_ERROR(MBED_MAKE_ERROR(MBED_MODULE_DRIVER, MBED_ERROR_CODE_ENOMEM), \
"socket_send(): unable to add event to queue. Increase \"events.shared-eventsize\"\n");
}
} else if (status == NSAPI_ERROR_WOULD_BLOCK && socket->proto == NSAPI_UDP) {
status = NSAPI_ERROR_DEVICE_ERROR;
}
@ -736,6 +739,10 @@ void ESP8266Interface::event()
if (!_oob_event_id) {
// Throttles event creation by using arbitrary small delay
_oob_event_id = _global_event_queue->call_in(50, callback(this, &ESP8266Interface::proc_oob_evnt));
if (!_oob_event_id) {
MBED_ERROR(MBED_MAKE_ERROR(MBED_MODULE_DRIVER, MBED_ERROR_CODE_ENOMEM), \
"ESP8266Interface::event(): unable to add event to queue. Increase \"events.shared-eventsize\"\n");
}
}
for (int i = 0; i < ESP8266_SOCKET_COUNT; i++) {

View File

@ -8,7 +8,7 @@
},
"shared-eventsize": {
"help": "Event buffer size (bytes) for shared event queue",
"value": 256
"value": 768
},
"shared-dispatch-from-application": {
"help": "No thread created for shared event queue - application will call dispatch from another thread (eg dispatch_forever at end of main)",

View File

@ -20,6 +20,7 @@
#include <new>
#include "EventQueue.h"
#include "mbed_shared_queues.h"
#include "platform/mbed_error.h"
// Default NetworkStack operations
@ -133,20 +134,24 @@ nsapi_error_t NetworkStack::call_in(int delay, mbed::Callback<void()> func)
static events::EventQueue *event_queue = mbed::mbed_event_queue();
if (!event_queue) {
return NSAPI_ERROR_NO_MEMORY;
goto NO_MEM;
}
if (delay > 0) {
if (event_queue->call_in(delay, func) == 0) {
return NSAPI_ERROR_NO_MEMORY;
goto NO_MEM;
}
} else {
if (event_queue->call(func) == 0) {
return NSAPI_ERROR_NO_MEMORY;
goto NO_MEM;
}
}
return NSAPI_ERROR_OK;
NO_MEM:
MBED_ERROR(MBED_MAKE_ERROR(MBED_MODULE_DRIVER, MBED_ERROR_CODE_ENOMEM), \
"NetworkStack::call_in() unable to add event to queue. Increase \"events.shared-eventsize\"\n");
}
call_in_callback_cb_t NetworkStack::get_call_in_callback()