Browse code

- don't include expired entries in DNS cache view output

Vladimir Marek authored on 11/10/2007 06:07:02
Showing 1 changed files
... ...
@@ -3333,6 +3333,7 @@ static char *print_type(unsigned short type)
3333 3333
 void dns_cache_view(rpc_t* rpc, void* ctx)
3334 3334
 {
3335 3335
 	int h;
3336
+	int expires;
3336 3337
 	struct dns_hash_entry* e;
3337 3338
 	struct dns_rr* rr;
3338 3339
 	struct ip_addr ip;
... ...
@@ -3347,15 +3348,17 @@ void dns_cache_view(rpc_t* rpc, void* ctx)
3347 3347
 	LOCK_DNS_HASH();
3348 3348
 	for (h=0; h<DNS_HASH_SIZE; h++){
3349 3349
 		clist_foreach(&dns_hash[h], e, next){
3350
+			expires = (s_ticks_t)(e->expire-now)<0?-1: TICKS_TO_S(e->expire-now);
3351
+			if (expires < 0) {
3352
+				continue;
3353
+			}
3350 3354
 			rpc->printf(ctx, "{\n%sname: %s", SPACE_FORMAT, e->name);
3351 3355
 			rpc->printf(ctx, "%stype: %s", SPACE_FORMAT, print_type(e->type));
3352 3356
 			rpc->printf(ctx, "%ssize (bytes): %d", SPACE_FORMAT,
3353 3357
 								e->total_size);
3354 3358
 			rpc->printf(ctx, "%sreference counter: %d", SPACE_FORMAT,
3355 3359
 								e->refcnt.val);
3356
-			rpc->printf(ctx, "%sexpires in (s): %d", SPACE_FORMAT,
3357
-								(s_ticks_t)(e->expire-now)<0?-1:
3358
-								TICKS_TO_S(e->expire-now));
3360
+			rpc->printf(ctx, "%sexpires in (s): %d", SPACE_FORMAT, expires);
3359 3361
 			rpc->printf(ctx, "%slast used (s): %d", SPACE_FORMAT,
3360 3362
 								TICKS_TO_S(now-e->last_used));
3361 3363
 			rpc->printf(ctx, "%serror flags: %d", SPACE_FORMAT, e->err_flags);