void invalidateQueryInCache(struct module_qstate* qstate,
	struct query_info* qinfo)
{
	hashvalue_type h;
	struct lruhash_entry* e;
	struct reply_info *r;
	size_t i, j;

	h = query_info_hash(qinfo, qstate->query_flags);
	if ((e=slabhash_lookup(qstate->env->msg_cache, h, qinfo, 0))) {
		r = (struct reply_info*)(e->data);
		if (r) {
			r->ttl = 0;
			if(rrset_array_lock(r->ref, r->rrset_count, *qstate->env->now)) {
				for(i=0; i< r->rrset_count; i++) {
					struct packed_rrset_data* data =
						(struct packed_rrset_data*) r->ref[i].key->entry.data;
					if(i>0 && r->ref[i].key == r->ref[i-1].key)
						continue;

					data->ttl = r->ttl;
					for(j=0; j<data->count + data->rrsig_count; j++)
						data->rr_ttl[j] = r->ttl;
				}
				rrset_array_unlock(r->ref, r->rrset_count);
			}
		}
		lock_rw_unlock(&e->lock);
	} else {
		log_info("invalidateQueryInCache: qinfo is not in cache");
	}
}
void invalidateQueryInCache(struct module_qstate* qstate,
	struct query_info* qinfo)
{
	hashvalue_type h;
	struct lruhash_entry* e;
	struct reply_info *r;
	size_t i, j;

	h = query_info_hash(qinfo, qstate->query_flags);
	if ((e=slabhash_lookup(qstate->env->msg_cache, h, qinfo, 0))) {
		r = (struct reply_info*)(e->data);
		if (r) {
			r->ttl = 0;
			if(rrset_array_lock(r->ref, r->rrset_count, *qstate->env->now)) {
				for(i=0; i< r->rrset_count; i++) {
					struct packed_rrset_data* data =
						(struct packed_rrset_data*) r->ref[i].key->entry.data;
					if(i>0 && r->ref[i].key == r->ref[i-1].key)
						continue;

					data->ttl = r->ttl;
					for(j=0; j<data->count + data->rrsig_count; j++)
						data->rr_ttl[j] = r->ttl;
				}
				rrset_array_unlock(r->ref, r->rrset_count);
			}
		}
		lock_rw_unlock(&e->lock);
	} else {
		log_info("invalidateQueryInCache: qinfo is not in cache");
	}
}