mirror of
https://github.com/NLnetLabs/unbound.git
synced 2025-12-20 23:00:56 -05:00
Answers from the cache work.
git-svn-id: file:///svn/unbound/trunk@192 be551aaa-1e26-0410-a405-d3ace91eadb9
This commit is contained in:
parent
fdfe51464b
commit
ea25707cb9
5 changed files with 11 additions and 7 deletions
|
|
@ -119,7 +119,7 @@ daemon_init()
|
||||||
daemon->need_to_exit = 0;
|
daemon->need_to_exit = 0;
|
||||||
daemon->msg_cache = lruhash_create(HASH_DEFAULT_STARTARRAY,
|
daemon->msg_cache = lruhash_create(HASH_DEFAULT_STARTARRAY,
|
||||||
HASH_DEFAULT_MAXMEM, msgreply_sizefunc, query_info_compare,
|
HASH_DEFAULT_MAXMEM, msgreply_sizefunc, query_info_compare,
|
||||||
query_info_delete, reply_info_delete, NULL);
|
query_entry_delete, reply_info_delete, NULL);
|
||||||
if(!daemon->msg_cache) {
|
if(!daemon->msg_cache) {
|
||||||
free(daemon);
|
free(daemon);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
|
||||||
|
|
@ -288,6 +288,7 @@ worker_handle_request(struct comm_point* c, void* arg, int error,
|
||||||
if((e=lruhash_lookup(worker->daemon->msg_cache, h, &worker->qinfo,
|
if((e=lruhash_lookup(worker->daemon->msg_cache, h, &worker->qinfo,
|
||||||
0))) {
|
0))) {
|
||||||
/* answer from cache */
|
/* answer from cache */
|
||||||
|
log_info("answer from the cache");
|
||||||
query_info_clear(&worker->qinfo);
|
query_info_clear(&worker->qinfo);
|
||||||
/* id is still in the buffer, no need to touch it */
|
/* id is still in the buffer, no need to touch it */
|
||||||
reply_info_answer((struct reply_info*)e->data,
|
reply_info_answer((struct reply_info*)e->data,
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,7 @@
|
||||||
23 March 2007: Wouter
|
23 March 2007: Wouter
|
||||||
- review of yesterday's commits.
|
- review of yesterday's commits.
|
||||||
|
- covered up memory leak of the entry locks.
|
||||||
|
- answers from the cache correctly. Copies flags correctly.
|
||||||
|
|
||||||
22 March 2007: Wouter
|
22 March 2007: Wouter
|
||||||
- AIX configure check.
|
- AIX configure check.
|
||||||
|
|
|
||||||
|
|
@ -140,10 +140,11 @@ size_t msgreply_sizefunc(void* k, void* d)
|
||||||
+ r->replysize + q->qnamesize;
|
+ r->replysize + q->qnamesize;
|
||||||
}
|
}
|
||||||
|
|
||||||
void query_info_delete(void *k, void* ATTR_UNUSED(arg))
|
void query_entry_delete(void *k, void* ATTR_UNUSED(arg))
|
||||||
{
|
{
|
||||||
struct query_info* q = (struct query_info*)k;
|
struct msgreply_entry* q = (struct msgreply_entry*)k;
|
||||||
query_info_clear(q);
|
lock_rw_destroy(&q->entry.lock);
|
||||||
|
query_info_clear(&q->key);
|
||||||
free(q);
|
free(q);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -170,7 +171,7 @@ void reply_info_answer(struct reply_info* rep, uint16_t qflags,
|
||||||
uint16_t flags;
|
uint16_t flags;
|
||||||
ldns_buffer_clear(buffer);
|
ldns_buffer_clear(buffer);
|
||||||
ldns_buffer_skip(buffer, 2); /* ID */
|
ldns_buffer_skip(buffer, 2); /* ID */
|
||||||
flags = ldns_read_uint16(rep->reply+2);
|
flags = ldns_read_uint16(rep->reply);
|
||||||
flags |= (qflags & 0x0100); /* copy RD bit */
|
flags |= (qflags & 0x0100); /* copy RD bit */
|
||||||
log_info("flags %x", flags);
|
log_info("flags %x", flags);
|
||||||
ldns_buffer_write_u16(buffer, flags);
|
ldns_buffer_write_u16(buffer, flags);
|
||||||
|
|
|
||||||
|
|
@ -116,8 +116,8 @@ void reply_info_clear(struct reply_info* m);
|
||||||
/** calculate size of struct query_info + reply_info */
|
/** calculate size of struct query_info + reply_info */
|
||||||
size_t msgreply_sizefunc(void* k, void* d);
|
size_t msgreply_sizefunc(void* k, void* d);
|
||||||
|
|
||||||
/** delete query_info key structure */
|
/** delete msgreply_entry key structure */
|
||||||
void query_info_delete(void *q, void* arg);
|
void query_entry_delete(void *q, void* arg);
|
||||||
|
|
||||||
/** delete reply_info data structure */
|
/** delete reply_info data structure */
|
||||||
void reply_info_delete(void* d, void* arg);
|
void reply_info_delete(void* d, void* arg);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue