PERFORCE change 123859 for review
Fredrik Lindberg
fli at FreeBSD.org
Sat Jul 21 19:22:19 UTC 2007
http://perforce.freebsd.org/chv.cgi?CH=123859
Change 123859 by fli at fli_nexus on 2007/07/21 19:21:40
- Hook up the cache system with the query system, notifies
consumers when a record expires.
- Fix a resource leak.
Affected files ...
.. //depot/projects/soc2007/fli-mdns_sd/mdnsd/cache.c#4 edit
Differences ...
==== //depot/projects/soc2007/fli-mdns_sd/mdnsd/cache.c#4 (text+ko) ====
@@ -81,11 +81,11 @@
}
void
-cache_init(struct cache *c)
+cache_init(struct cache *c, struct queries *q)
{
-
records_init(&c->c_recs, mdns_c_in);
TAILQ_INIT(&c->c_list);
+ c->c_queries = q;
}
void
@@ -129,9 +129,9 @@
* Adds a resource record to the cache
* c - initialized cache structure
* rrset - resource record to add
+ *
* If the record is already in cache, its TTL will be reset to the
* ttl value specified in the given `rrset'.
- * Returns a pointer to the cached resource record.
*/
int
cache_add(struct cache *c, struct mdns_rrset *rrset, struct record_res **new)
@@ -194,11 +194,12 @@
cache_del(struct cache *c, struct record_res *rr)
{
struct cache_res *cr;
-#ifdef DEBUG
struct record *r = rr->rr_type->rt_record;
struct record_type *rt = rr->rr_type;
+#ifdef DEBUG
time_t rtime = time(NULL);
#endif
+ struct mdns_rrset rs;
MDNS_INIT_ASSERT(rr, rr_magic);
cr = record_res_getparent(rr);
@@ -207,9 +208,20 @@
"attl=%d, rttl=%d, cached=%d", r->r_name, rt->rt_type, rr->rr_len,
cr->cr_ttl_abs, cr->cr_ttl_rel, rtime - cr->cr_ctime);
+ if (c->c_queries != NULL) {
+ mdns_rrset_name(&rs, r->r_name);
+ rs.r_ttl = 0;
+ rs.r_class = mdns_c_in;
+ rs.r_type = rt->rt_type;
+ rs.r_data = rr->rr_data;
+ rs.r_datalen = rr->rr_len;
+ query_notify(c->c_queries, &rs, 0, 0, 0);
+ }
+
MDNS_INIT_ASSERT(cr, cr_magic);
dequeue_ttl(c, cr);
record_res_del(rr);
+ record_release(r);
MDNS_INIT_UNSET(cr, cr_magic);
free(cr);
return (0);
More information about the p4-projects
mailing list