From owner-p4-projects@FreeBSD.ORG Sat Jul 21 19:22:19 2007 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id B33FE16A41F; Sat, 21 Jul 2007 19:22:19 +0000 (UTC) Delivered-To: perforce@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 7110D16A419 for ; Sat, 21 Jul 2007 19:22:19 +0000 (UTC) (envelope-from fli@FreeBSD.org) Received: from repoman.freebsd.org (repoman.freebsd.org [IPv6:2001:4f8:fff6::29]) by mx1.freebsd.org (Postfix) with ESMTP id 60BC413C459 for ; Sat, 21 Jul 2007 19:22:19 +0000 (UTC) (envelope-from fli@FreeBSD.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.14.1/8.14.1) with ESMTP id l6LJMJx9011149 for ; Sat, 21 Jul 2007 19:22:19 GMT (envelope-from fli@FreeBSD.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.14.1/8.14.1/Submit) id l6LJMJDc011146 for perforce@freebsd.org; Sat, 21 Jul 2007 19:22:19 GMT (envelope-from fli@FreeBSD.org) Date: Sat, 21 Jul 2007 19:22:19 GMT Message-Id: <200707211922.l6LJMJDc011146@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to fli@FreeBSD.org using -f From: Fredrik Lindberg To: Perforce Change Reviews Cc: Subject: PERFORCE change 123859 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 21 Jul 2007 19:22:19 -0000 http://perforce.freebsd.org/chv.cgi?CH=123859 Change 123859 by fli@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);