Skip to content

Commit 5252163

Browse files
authored
Merge pull request #9900 from michalpasztamobica/dns_async_handle_would_block
DNS send returning WOULD_BLOCK forces delayed retry
2 parents 943254c + ee056da commit 5252163

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

features/netsocket/nsapi_dns.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1021,7 +1021,14 @@ static void nsapi_dns_query_async_send(void *ptr)
10211021
err = query->socket->sendto(dns_addr, packet, len);
10221022

10231023
if (err < 0) {
1024-
query->dns_server++;
1024+
if (err == NSAPI_ERROR_WOULD_BLOCK) {
1025+
nsapi_dns_call_in(query->call_in_cb, DNS_TIMER_TIMEOUT, mbed::callback(nsapi_dns_query_async_send, ptr));
1026+
free(packet);
1027+
dns_mutex->unlock();
1028+
return; // Timeout handler will retry the connection if possible
1029+
} else {
1030+
query->dns_server++;
1031+
}
10251032
} else {
10261033
break;
10271034
}

0 commit comments

Comments
 (0)