@@ -111,12 +111,15 @@ static nsapi_addr_t dns_servers[DNS_SERVERS_SIZE] = {
111
111
0 ,0 , 0 ,0 , 0x1c ,0x04 , 0xb1 ,0x2f }},
112
112
};
113
113
114
+ #if (MBED_CONF_NSAPI_DNS_CACHE_SIZE > 0)
114
115
static DNS_CACHE *dns_cache[MBED_CONF_NSAPI_DNS_CACHE_SIZE];
116
+ // Protects cache shared between blocking and asynchronous calls
117
+ static SingletonPtr<PlatformMutex> dns_cache_mutex;
118
+ #endif
119
+
115
120
static uint16_t dns_message_id = 1 ;
116
121
static int dns_unique_id = 1 ;
117
122
static DNS_QUERY *dns_query_queue[DNS_QUERY_QUEUE_SIZE];
118
- // Protects cache shared between blocking and asynchronous calls
119
- static SingletonPtr<PlatformMutex> dns_cache_mutex;
120
123
// Protects from several threads running asynchronous DNS
121
124
static SingletonPtr<PlatformMutex> dns_mutex;
122
125
static SingletonPtr<call_in_callback_cb_t > dns_call_in;
@@ -306,6 +309,7 @@ static int dns_scan_response(const uint8_t *ptr, uint16_t exp_id, uint32_t *ttl,
306
309
307
310
static void nsapi_dns_cache_add (const char *host, nsapi_addr_t *address, uint32_t ttl)
308
311
{
312
+ #if (MBED_CONF_NSAPI_DNS_CACHE_SIZE > 0)
309
313
// RFC 1034: if TTL is zero, entry is not added to cache
310
314
if (ttl == 0 ) {
311
315
return ;
@@ -354,12 +358,14 @@ static void nsapi_dns_cache_add(const char *host, nsapi_addr_t *address, uint32_
354
358
}
355
359
356
360
dns_cache_mutex->unlock ();
361
+ #endif
357
362
}
358
363
359
364
static nsapi_error_t nsapi_dns_cache_find (const char *host, nsapi_version_t version, nsapi_addr_t *address)
360
365
{
361
366
nsapi_error_t ret_val = NSAPI_ERROR_NO_ADDRESS;
362
367
368
+ #if (MBED_CONF_NSAPI_DNS_CACHE_SIZE > 0)
363
369
dns_cache_mutex->lock ();
364
370
365
371
for (int i = 0 ; i < MBED_CONF_NSAPI_DNS_CACHE_SIZE; i++) {
@@ -382,6 +388,7 @@ static nsapi_error_t nsapi_dns_cache_find(const char *host, nsapi_version_t vers
382
388
}
383
389
384
390
dns_cache_mutex->unlock ();
391
+ #endif
385
392
386
393
return ret_val;
387
394
}
0 commit comments