Commit 504b15de authored by Michael Sawyer's avatar Michael Sawyer
Browse files

Use zone lock instead of zmgr lock on counters

Clean up global and local count adders.
parent f00075e7
......@@ -15,7 +15,7 @@
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
/* $Id: server.c,v 1.257 2000/11/27 22:08:06 gson Exp $ */
/* $Id: server.c,v 1.258 2000/11/28 01:59:24 mws Exp $ */
#include <config.h>
......@@ -2251,19 +2251,8 @@ ns_server_querycount(dns_zone_t *zone, isc_boolean_t is_zone,
REQUIRE(counter < DNS_ZONE_COUNTSIZE);
ns_g_server->globalcount[counter]++;
if (!is_zone || zone == NULL || !dns_zone_hascounts(zone)) {
isc_log_write(dns_lctx, NS_LOGCATEGORY_GENERAL, NS_LOGMODULE_QUERY,
1, "global counter %s set to %ld",
dns_zonecount_names[counter],
(long)ns_g_server->globalcount[counter]);
return;
}
dns_zone_count(zone, counter);
isc_log_write(dns_lctx, NS_LOGCATEGORY_GENERAL, NS_LOGMODULE_QUERY,
1, "zone counter %s set to %ld, global %ld",
dns_zonecount_names[counter],
(long)dns_zone_getcounts(zone, counter),
(long)ns_g_server->globalcount[counter]);
if (is_zone && zone != NULL && !dns_zone_hascounts(zone))
dns_zone_count(zone, counter);
}
/*
......
......@@ -15,7 +15,7 @@
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
/* $Id: zone.c,v 1.259 2000/11/25 02:43:45 marka Exp $ */
/* $Id: zone.c,v 1.260 2000/11/28 01:59:25 mws Exp $ */
#include <config.h>
......@@ -5726,10 +5726,10 @@ void
dns_zone_count(dns_zone_t *zone, dns_zonecount_t counter) {
REQUIRE(counter < DNS_ZONE_COUNTSIZE);
RWLOCK(&zone->zmgr->rwlock, isc_rwlocktype_write);
LOCK(&zone->lock);
if (zone->counters != NULL)
zone->counters[counter]++;
RWUNLOCK(&zone->zmgr->rwlock, isc_rwlocktype_write);
UNLOCK(&zone->lock);
}
isc_uint64_t
......@@ -5738,10 +5738,10 @@ dns_zone_getcounts(dns_zone_t *zone, dns_zonecount_t counter) {
REQUIRE(DNS_ZONE_VALID(zone));
REQUIRE(counter < DNS_ZONE_COUNTSIZE);
RWLOCK(&zone->zmgr->rwlock, isc_rwlocktype_read);
LOCK(&zone->lock);
if (zone->counters != NULL)
count = zone->counters[counter];
RWUNLOCK(&zone->zmgr->rwlock, isc_rwlocktype_read);
UNLOCK(&zone->lock);
return (count);
}
......@@ -5756,11 +5756,11 @@ dns_zone_resetcounts(dns_zone_t *zone) {
REQUIRE(DNS_ZONE_VALID(zone));
RWLOCK(&zone->zmgr->rwlock, isc_rwlocktype_write);
LOCK(&zone->lock);
if (zone->counters != NULL)
for (i = 0; i < DNS_ZONE_COUNTSIZE; i++)
zone->counters[i] = 0;
RWUNLOCK(&zone->zmgr->rwlock, isc_rwlocktype_write);
UNLOCK(&zone->lock);
}
isc_boolean_t
......@@ -5768,10 +5768,10 @@ dns_zone_hascounts(dns_zone_t *zone) {
isc_boolean_t hascount = ISC_FALSE;
REQUIRE(DNS_ZONE_VALID(zone));
RWLOCK(&zone->zmgr->rwlock, isc_rwlocktype_read);
LOCK(&zone->lock);
if (zone->counters != NULL)
hascount = ISC_TRUE;
RWUNLOCK(&zone->zmgr->rwlock, isc_rwlocktype_read);
UNLOCK(&zone->lock);
return (hascount);
}
......@@ -5782,7 +5782,7 @@ dns_zone_startcounting(dns_zone_t *zone) {
REQUIRE(DNS_ZONE_VALID(zone));
RWLOCK(&zone->zmgr->rwlock, isc_rwlocktype_write);
LOCK(&zone->lock);
if (zone->counters != NULL)
goto done;
......@@ -5794,7 +5794,7 @@ dns_zone_startcounting(dns_zone_t *zone) {
for (i = 0; i < DNS_ZONE_COUNTSIZE; i++)
zone->counters[i] = 0;
done:
RWUNLOCK(&zone->zmgr->rwlock, isc_rwlocktype_write);
UNLOCK(&zone->lock);
return (ISC_R_SUCCESS);
}
......@@ -5802,7 +5802,7 @@ void
dns_zone_stopcounting(dns_zone_t *zone) {
REQUIRE(DNS_ZONE_VALID(zone));
RWLOCK(&zone->zmgr->rwlock, isc_rwlocktype_write);
LOCK(&zone->lock);
if (zone->counters == NULL)
goto done;
......@@ -5810,7 +5810,7 @@ dns_zone_stopcounting(dns_zone_t *zone) {
sizeof(isc_uint64_t) * DNS_ZONE_COUNTSIZE);
zone->counters = NULL;
done:
RWUNLOCK(&zone->zmgr->rwlock, isc_rwlocktype_write);
UNLOCK(&zone->lock);
return;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment