Skip to content

Commit

Permalink
Fixing more bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
shannonklaus committed Jan 25, 2024
1 parent a8f8bc0 commit aa92db7
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 28 deletions.
32 changes: 4 additions & 28 deletions src/include/aerospike/aerospike_stats.h
Original file line number Diff line number Diff line change
Expand Up @@ -245,35 +245,11 @@ aerospike_event_loop_stats(as_event_loop* event_loop, as_event_loop_stats* stats
stats->queue_size = as_event_loop_get_queue_size(event_loop);
}

static inline void
as_sum_init(as_conn_stats* stats)
{
stats->in_pool = 0;
stats->in_use = 0;
stats->opened = 0;
stats->closed = 0;
}
void
as_sum_init(as_conn_stats* stats);

static inline void
as_sum_no_lock(as_async_conn_pool* pool, as_conn_stats* stats)
{
// Warning: cross-thread reference without a lock.
int tmp = as_queue_size(&pool->queue);

// Timing issues may cause values to go negative. Adjust.
if (tmp < 0) {
tmp = 0;
}
stats->in_pool += tmp;
tmp = pool->queue.total - tmp;

if (tmp < 0) {
tmp = 0;
}
stats->in_use += tmp;
stats->opened += pool->opened;
stats->closed += pool->closed;
}
void
as_sum_no_lock(as_async_conn_pool* pool, as_conn_stats* stats);

/**
* Return string representation of cluster statistics.
Expand Down
30 changes: 30 additions & 0 deletions src/main/aerospike/aerospike_stats.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,36 @@ as_conn_stats_tostring(as_string_builder* sb, const char* title, as_conn_stats*
* FUNCTIONS
*****************************************************************************/

void
as_sum_init(as_conn_stats* stats)
{
stats->in_pool = 0;
stats->in_use = 0;
stats->opened = 0;
stats->closed = 0;
}

void
as_sum_no_lock(as_async_conn_pool* pool, as_conn_stats* stats)
{
// Warning: cross-thread reference without a lock.
int tmp = as_queue_size(&pool->queue);

// Timing issues may cause values to go negative. Adjust.
if (tmp < 0) {
tmp = 0;
}
stats->in_pool += tmp;
tmp = pool->queue.total - tmp;

if (tmp < 0) {
tmp = 0;
}
stats->in_use += tmp;
stats->opened += pool->opened;
stats->closed += pool->closed;
}

void
aerospike_cluster_stats(as_cluster* cluster, as_cluster_stats* stats)
{
Expand Down

0 comments on commit aa92db7

Please sign in to comment.