Skip to content

Commit 2e5d1d9

Browse files
author
Veijo Pesonen
committed
ESP8266: halts if unable to add an event to the event queue
1 parent 517799f commit 2e5d1d9

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

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++) {

0 commit comments

Comments
 (0)