Add support for deleting per-network DNS resolver caches.

This is required when the possible range of NetIds is large to
prevent netd consuming excessive amounts of memory.
This required replacing the per-cache locks in favor of a single
global lock to prevent accesses to deleted caches.

Change-Id: I99d058bafea5de743e56075dbed74031da4df63f
This commit is contained in:
Paul Jensen
2014-04-08 15:43:41 -04:00
committed by Lorenzo Colitti
parent 7fbc7481cc
commit 41d9a50371
4 changed files with 100 additions and 73 deletions

View File

@@ -32,11 +32,6 @@
#include <sys/cdefs.h>
struct __res_state;
struct resolv_cache; /* forward */
/* Gets the cache for a network. Returned cache might be NULL. */
__LIBC_HIDDEN__
extern struct resolv_cache* __get_res_cache(unsigned netid);
/* sets the name server addresses to the provided res_state structure. The
* name servers are retrieved from the cache which is associated
@@ -53,7 +48,7 @@ typedef enum {
__LIBC_HIDDEN__
extern ResolvCacheStatus
_resolv_cache_lookup( struct resolv_cache* cache,
_resolv_cache_lookup( unsigned netid,
const void* query,
int querylen,
void* answer,
@@ -65,7 +60,7 @@ _resolv_cache_lookup( struct resolv_cache* cache,
*/
__LIBC_HIDDEN__
extern void
_resolv_cache_add( struct resolv_cache* cache,
_resolv_cache_add( unsigned netid,
const void* query,
int querylen,
const void* answer,
@@ -74,7 +69,7 @@ _resolv_cache_add( struct resolv_cache* cache,
/* Notify the cache a request failed */
__LIBC_HIDDEN__
extern void
_resolv_cache_query_failed( struct resolv_cache* cache,
_resolv_cache_query_failed( unsigned netid,
const void* query,
int querylen);

View File

@@ -65,6 +65,9 @@ extern void _resolv_set_nameservers_for_net(unsigned netid,
/* flush the cache associated with a certain network */
extern void _resolv_flush_cache_for_net(unsigned netid);
/* delete the cache associated with a certain network */
extern void _resolv_delete_cache_for_net(unsigned netid);
__END_DECLS
#endif /* _RESOLV_NETID_H */