Skip to content

Commit d648bf8

Browse files
author
Mika Leppänen
committed
Corrected asynchronous DNS functionality
- Set network stack to store event queue so that mbed::mbed_event_queue() call is not needed every time call_in() is called - Added dns state variables and enum (states are: created, initiated and cancelled) - Corrected DNS response handling so that if DNS server returns that host name is unknown the DNS query is not tried again - Reorder mutexes in nsapi_dns_query_multiple_async() - Created nsapi_dns_query_async_initiate_next() function to initiate the next DNS query from the queue after delete of previous query - Added dsn_timer_running variable to supervise DNS timer start/stop - Changed cancel function to only mark query as deleted and moved deletion to timer function. This allows to run socket close on DNS thread - Added new nsapi error NSAPI_ERROR_TIMEOUT for DNS (and other) timeouts
1 parent 2eac96e commit d648bf8

File tree

4 files changed

+120
-72
lines changed

4 files changed

+120
-72
lines changed

features/FEATURE_LWIP/lwip-interface/LWIPStack.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ void LWIP::tcpip_thread_callback(void *ptr)
209209

210210
nsapi_error_t LWIP::call_in(int delay, mbed::Callback<void()> func)
211211
{
212-
lwip_callback *cb = new lwip_callback;
212+
lwip_callback *cb = new (std::nothrow) lwip_callback;
213213
if (!cb) {
214214
return NSAPI_ERROR_NO_MEMORY;
215215
}

features/netsocket/NetworkStack.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ nsapi_error_t NetworkStack::getsockopt(void *handle, int level, int optname, voi
114114

115115
nsapi_error_t NetworkStack::call_in(int delay, mbed::Callback<void()> func)
116116
{
117-
events::EventQueue *event_queue = mbed::mbed_event_queue();
117+
static events::EventQueue *event_queue = mbed::mbed_event_queue();
118118

119119
if (!event_queue) {
120120
return NSAPI_ERROR_NO_MEMORY;

0 commit comments

Comments
 (0)