Skip to content

Commit 6bdbe75

Browse files
authored
Merge pull request #9799 from VeijoPesonen/bugfix-esp8266-dns
Increase events.share-eventsize to 768B because of ESP8266 AT driver and asynchronous DNS
2 parents c123b98 + 5caed17 commit 6bdbe75

File tree

8 files changed

+25
-8
lines changed

8 files changed

+25
-8
lines changed

UNITTESTS/features/netsocket/InternetSocket/unittest.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ set(unittest-test-sources
2121
stubs/mbed_critical_stub.c
2222
stubs/equeue_stub.c
2323
stubs/EventQueue_stub.cpp
24+
stubs/mbed_error.c
2425
stubs/mbed_shared_queues_stub.cpp
2526
stubs/nsapi_dns_stub.cpp
2627
stubs/EventFlags_stub.cpp

UNITTESTS/features/netsocket/NetworkStack/unittest.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ set(unittest-test-sources
2424
stubs/mbed_assert_stub.c
2525
stubs/equeue_stub.c
2626
stubs/EventQueue_stub.cpp
27+
stubs/mbed_error.c
2728
stubs/mbed_shared_queues_stub.cpp
2829
stubs/nsapi_dns_stub.cpp
2930
stubs/EventFlags_stub.cpp

UNITTESTS/features/netsocket/TCPServer/unittest.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ set(unittest-test-sources
2525
stubs/mbed_critical_stub.c
2626
stubs/equeue_stub.c
2727
stubs/EventQueue_stub.cpp
28+
stubs/mbed_error.c
2829
stubs/mbed_shared_queues_stub.cpp
2930
stubs/nsapi_dns_stub.cpp
3031
stubs/EventFlags_stub.cpp

UNITTESTS/features/netsocket/TCPSocket/unittest.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ set(unittest-test-sources
2222
stubs/mbed_critical_stub.c
2323
stubs/equeue_stub.c
2424
stubs/EventQueue_stub.cpp
25+
stubs/mbed_error.c
2526
stubs/mbed_shared_queues_stub.cpp
2627
stubs/nsapi_dns_stub.cpp
2728
stubs/EventFlags_stub.cpp

UNITTESTS/features/netsocket/UDPSocket/unittest.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ set(unittest-test-sources
2222
stubs/mbed_critical_stub.c
2323
stubs/equeue_stub.c
2424
stubs/EventQueue_stub.cpp
25+
stubs/mbed_error.c
2526
stubs/mbed_shared_queues_stub.cpp
2627
stubs/EventFlags_stub.cpp
2728
stubs/nsapi_dns_stub.cpp

components/wifi/esp8266-driver/ESP8266Interface.cpp

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -181,10 +181,9 @@ void ESP8266Interface::_connect_async()
181181
} else {
182182
// Postpone to give other stuff time to run
183183
_connect_event_id = _global_event_queue->call_in(ESP8266_CONNECT_TIMEOUT, callback(this, &ESP8266Interface::_connect_async));
184-
185184
if (!_connect_event_id) {
186185
MBED_ERROR(MBED_MAKE_ERROR(MBED_MODULE_DRIVER, MBED_ERROR_CODE_ENOMEM), \
187-
"_connect_async(): unable to add event to queue");
186+
"ESP8266Interface::_connect_async(): unable to add event to queue. Increase \"events.shared-eventsize\"\n");
188187
}
189188
}
190189
_cmutex.unlock();
@@ -228,7 +227,7 @@ int ESP8266Interface::connect()
228227

229228
if (!_connect_event_id) {
230229
MBED_ERROR(MBED_MAKE_ERROR(MBED_MODULE_DRIVER, MBED_ERROR_CODE_ENOMEM), \
231-
"connect(): unable to add event to queue");
230+
"connect(): unable to add event to queue. Increase \"events.shared-eventsize\"\n");
232231
}
233232

234233
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)
586585
&& socket->proto == NSAPI_TCP
587586
&& core_util_atomic_cas_u8(&_cbs[socket->id].deferred, &expect_false, true)) {
588587
tr_debug("Postponing SIGIO from the device");
589-
_global_event_queue->call_in(50, callback(this, &ESP8266Interface::event_deferred));
588+
if (!_global_event_queue->call_in(50, callback(this, &ESP8266Interface::event_deferred))) {
589+
MBED_ERROR(MBED_MAKE_ERROR(MBED_MODULE_DRIVER, MBED_ERROR_CODE_ENOMEM), \
590+
"socket_send(): unable to add event to queue. Increase \"events.shared-eventsize\"\n");
591+
}
592+
590593
} else if (status == NSAPI_ERROR_WOULD_BLOCK && socket->proto == NSAPI_UDP) {
591594
status = NSAPI_ERROR_DEVICE_ERROR;
592595
}
@@ -736,6 +739,10 @@ void ESP8266Interface::event()
736739
if (!_oob_event_id) {
737740
// Throttles event creation by using arbitrary small delay
738741
_oob_event_id = _global_event_queue->call_in(50, callback(this, &ESP8266Interface::proc_oob_evnt));
742+
if (!_oob_event_id) {
743+
MBED_ERROR(MBED_MAKE_ERROR(MBED_MODULE_DRIVER, MBED_ERROR_CODE_ENOMEM), \
744+
"ESP8266Interface::event(): unable to add event to queue. Increase \"events.shared-eventsize\"\n");
745+
}
739746
}
740747

741748
for (int i = 0; i < ESP8266_SOCKET_COUNT; i++) {

events/mbed_lib.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
},
99
"shared-eventsize": {
1010
"help": "Event buffer size (bytes) for shared event queue",
11-
"value": 256
11+
"value": 768
1212
},
1313
"shared-dispatch-from-application": {
1414
"help": "No thread created for shared event queue - application will call dispatch from another thread (eg dispatch_forever at end of main)",

features/netsocket/NetworkStack.cpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include <new>
2121
#include "EventQueue.h"
2222
#include "mbed_shared_queues.h"
23+
#include "platform/mbed_error.h"
2324

2425
// Default NetworkStack operations
2526

@@ -133,20 +134,24 @@ nsapi_error_t NetworkStack::call_in(int delay, mbed::Callback<void()> func)
133134
static events::EventQueue *event_queue = mbed::mbed_event_queue();
134135

135136
if (!event_queue) {
136-
return NSAPI_ERROR_NO_MEMORY;
137+
goto NO_MEM;
137138
}
138139

139140
if (delay > 0) {
140141
if (event_queue->call_in(delay, func) == 0) {
141-
return NSAPI_ERROR_NO_MEMORY;
142+
goto NO_MEM;
142143
}
143144
} else {
144145
if (event_queue->call(func) == 0) {
145-
return NSAPI_ERROR_NO_MEMORY;
146+
goto NO_MEM;
146147
}
147148
}
148149

149150
return NSAPI_ERROR_OK;
151+
152+
NO_MEM:
153+
MBED_ERROR(MBED_MAKE_ERROR(MBED_MODULE_DRIVER, MBED_ERROR_CODE_ENOMEM), \
154+
"NetworkStack::call_in() unable to add event to queue. Increase \"events.shared-eventsize\"\n");
150155
}
151156

152157
call_in_callback_cb_t NetworkStack::get_call_in_callback()

0 commit comments

Comments
 (0)