Skip to content

Commit

Permalink
Fix compilation errors and warnings when NNG_ENABLE_STATS is OFF
Browse files Browse the repository at this point in the history
  • Loading branch information
robiwano authored and gdamore committed Dec 30, 2019
1 parent c973670 commit 3890f85
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/core/dialer.c
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ dialer_stats_init(nni_dialer *d)
void
nni_dialer_bump_error(nni_dialer *d, int err)
{
#ifdef NNG_ENABLE_STATS
switch (err) {
case NNG_ECONNABORTED:
case NNG_ECONNRESET:
Expand Down Expand Up @@ -156,6 +157,10 @@ nni_dialer_bump_error(nni_dialer *d, int err)
BUMP_STAT(&d->d_stats.s_othererr);
break;
}
#else
NNI_ARG_UNUSED(d);
NNI_ARG_UNUSED(err);
#endif
}

int
Expand Down
5 changes: 5 additions & 0 deletions src/core/listener.c
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ listener_stats_init(nni_listener *l)
void
nni_listener_bump_error(nni_listener *l, int err)
{
#ifdef NNG_ENABLE_STATS
switch (err) {
case NNG_ECONNABORTED:
case NNG_ECONNRESET:
Expand All @@ -150,6 +151,10 @@ nni_listener_bump_error(nni_listener *l, int err)
BUMP_STAT(&l->l_stats.s_othererr);
break;
}
#else
NNI_ARG_UNUSED(l);
NNI_ARG_UNUSED(err);
#endif
}

int
Expand Down
10 changes: 10 additions & 0 deletions src/core/pipe.c
Original file line number Diff line number Diff line change
Expand Up @@ -351,15 +351,25 @@ nni_pipe_add_stat(nni_pipe *p, nni_stat_item *item)
void
nni_pipe_bump_rx(nni_pipe *p, size_t nbytes)
{
#ifdef NNG_ENABLE_STATS
nni_stat_inc_atomic(&p->p_stats.s_rxbytes, nbytes);
nni_stat_inc_atomic(&p->p_stats.s_rxmsgs, 1);
#else
NNI_ARG_UNUSED(p);
NNI_ARG_UNUSED(nbytes);
#endif
}

void
nni_pipe_bump_tx(nni_pipe *p, size_t nbytes)
{
#ifdef NNG_ENABLE_STATS
nni_stat_inc_atomic(&p->p_stats.s_txbytes, nbytes);
nni_stat_inc_atomic(&p->p_stats.s_txmsgs, 1);
#else
NNI_ARG_UNUSED(p);
NNI_ARG_UNUSED(nbytes);
#endif
}

void
Expand Down
4 changes: 4 additions & 0 deletions src/core/stats.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,13 @@ nni_stat_add(nni_stat_item *parent, nni_stat_item *child)
void
nni_stat_register(nni_stat_item *child)
{
#ifdef NNG_ENABLE_STATS
nni_mtx_lock(&stats_lock);
nni_stat_add(&stats_root, child);
nni_mtx_unlock(&stats_lock);
#else
NNI_ARG_UNUSED(child);
#endif
}

void
Expand Down

0 comments on commit 3890f85

Please sign in to comment.