diff --git a/lib/isc/include/isc/stats.h b/lib/isc/include/isc/stats.h index 23a076eba9..f6520969c8 100644 --- a/lib/isc/include/isc/stats.h +++ b/lib/isc/include/isc/stats.h @@ -137,10 +137,10 @@ isc_stats_ncounters(isc_stats_t *stats); * */ -void +isc_statscounter_t isc_stats_increment(isc_stats_t *stats, isc_statscounter_t counter); /*%< - * Increment the counter-th counter of stats. + * Increment the counter-th counter of stats and return the old value. * * Requires: *\li 'stats' is a valid isc_stats_t. diff --git a/lib/isc/stats.c b/lib/isc/stats.c index 07a88fb6c9..2f7e8bcde1 100644 --- a/lib/isc/stats.c +++ b/lib/isc/stats.c @@ -97,12 +97,12 @@ isc_stats_create(isc_mem_t *mctx, isc_stats_t **statsp, int ncounters) { *statsp = stats; } -void +isc_statscounter_t isc_stats_increment(isc_stats_t *stats, isc_statscounter_t counter) { REQUIRE(ISC_STATS_VALID(stats)); REQUIRE(counter < stats->ncounters); - atomic_fetch_add_relaxed(&stats->counters[counter], 1); + return (atomic_fetch_add_relaxed(&stats->counters[counter], 1)); } void diff --git a/lib/ns/include/ns/stats.h b/lib/ns/include/ns/stats.h index d7e79443cf..c904d7f38c 100644 --- a/lib/ns/include/ns/stats.h +++ b/lib/ns/include/ns/stats.h @@ -124,7 +124,7 @@ ns_stats_detach(ns_stats_t **statsp); void ns_stats_create(isc_mem_t *mctx, int ncounters, ns_stats_t **statsp); -void +isc_statscounter_t ns_stats_increment(ns_stats_t *stats, isc_statscounter_t counter); void diff --git a/lib/ns/stats.c b/lib/ns/stats.c index 84dd0ab029..791c08a756 100644 --- a/lib/ns/stats.c +++ b/lib/ns/stats.c @@ -78,11 +78,11 @@ ns_stats_create(isc_mem_t *mctx, int ncounters, ns_stats_t **statsp) { /*% * Increment/Decrement methods */ -void +isc_statscounter_t ns_stats_increment(ns_stats_t *stats, isc_statscounter_t counter) { REQUIRE(NS_STATS_VALID(stats)); - isc_stats_increment(stats->counters, counter); + return (isc_stats_increment(stats->counters, counter)); } void