diff options
| author | Garrett D'Amore <garrett@damore.org> | 2019-02-18 20:15:16 -0800 |
|---|---|---|
| committer | Garrett D'Amore <garrett@damore.org> | 2019-02-23 11:50:17 -0800 |
| commit | 64e784237d143aa032311942bc44abd22e1e4114 (patch) | |
| tree | e3ea529d5e5adfd022773ab207622cc2247f057c /src/core/pipe.c | |
| parent | d210ef96517c1462bc058c95bced8c27b5e19c4f (diff) | |
| download | nng-64e784237d143aa032311942bc44abd22e1e4114.tar.gz nng-64e784237d143aa032311942bc44abd22e1e4114.tar.bz2 nng-64e784237d143aa032311942bc44abd22e1e4114.zip | |
fixes #848 server hang waiting for client handshake
fixes #698 Need TCP stats
fixes #699 Need IPC stats
fixes #701 Need TLS stats
This commit addresses a problem when negotiating using one of the stream
based negotiation APIs -- a slow or misbehaving peer can prevent well
behaved ones from establishing a connection. The fix is a fairly
significant change in how these transports link up, and it does rely
on the fact that the socket only has a single accept() or connect()
pending at a time (on a given endpoint that is).
While here, we have completely revamped the way transport statistics are
done, offering a standard API for collecting these statistics.
Unfortunately, this completely borks the statistics for inproc. As we
are planning to change the way inproc works soon, in order to provide
more control and work on performance fixes for the message queue, we feel
this is an acceptable trade-off. Furthermore, almost nobody uses inproc
for anything, and even fewer people are making use of the statistics
at this time.
Diffstat (limited to 'src/core/pipe.c')
| -rw-r--r-- | src/core/pipe.c | 38 |
1 files changed, 37 insertions, 1 deletions
diff --git a/src/core/pipe.c b/src/core/pipe.c index 6ad62fa4..44957def 100644 --- a/src/core/pipe.c +++ b/src/core/pipe.c @@ -1,5 +1,5 @@ // -// Copyright 2018 Staysail Systems, Inc. <info@staysail.tech> +// Copyright 2019 Staysail Systems, Inc. <info@staysail.tech> // Copyright 2018 Capitar IT Group BV <info@capitar.com> // Copyright 2018 Devolutions <info@devolutions.net> // @@ -228,6 +228,18 @@ pipe_create(nni_pipe **pp, nni_sock *sock, nni_tran *tran, void *tdata) nni_stat_init_id(&st->s_sock_id, "socket", "socket for pipe", nni_sock_id(p->p_sock)); nni_stat_append(&st->s_root, &st->s_sock_id); + nni_stat_init_atomic(&st->s_rxmsgs, "rxmsgs", "messages received"); + nni_stat_set_unit(&st->s_rxmsgs, NNG_UNIT_MESSAGES); + nni_stat_append(&st->s_root, &st->s_rxmsgs); + nni_stat_init_atomic(&st->s_txmsgs, "txmsgs", "messages sent"); + nni_stat_set_unit(&st->s_txmsgs, NNG_UNIT_MESSAGES); + nni_stat_append(&st->s_root, &st->s_txmsgs); + nni_stat_init_atomic(&st->s_rxbytes, "rxbytes", "bytes received"); + nni_stat_set_unit(&st->s_rxbytes, NNG_UNIT_BYTES); + nni_stat_append(&st->s_root, &st->s_rxbytes); + nni_stat_init_atomic(&st->s_txbytes, "txbytes", "bytes sent"); + nni_stat_set_unit(&st->s_txbytes, NNG_UNIT_BYTES); + nni_stat_append(&st->s_root, &st->s_txbytes); if ((rv != 0) || ((rv = p->p_tran_ops.p_init(tdata, p)) != 0) || ((rv = pops->pipe_init(&p->p_proto_data, p, sdata)) != 0)) { @@ -337,3 +349,27 @@ nni_pipe_add_stat(nni_pipe *p, nni_stat_item *item) { nni_stat_append(&p->p_stats.s_root, item); } + +void +nni_pipe_bump_rx(nni_pipe *p, size_t nbytes) +{ + nni_stat_inc_atomic(&p->p_stats.s_rxbytes, nbytes); + nni_stat_inc_atomic(&p->p_stats.s_rxmsgs, 1); +} + +void +nni_pipe_bump_tx(nni_pipe *p, size_t nbytes) +{ + nni_stat_inc_atomic(&p->p_stats.s_txbytes, nbytes); + nni_stat_inc_atomic(&p->p_stats.s_txmsgs, 1); +} + +void +nni_pipe_bump_error(nni_pipe *p, int err) +{ + if (p->p_dialer != NULL) { + nni_dialer_bump_error(p->p_dialer, err); + } else { + nni_listener_bump_error(p->p_listener, err); + } +}
\ No newline at end of file |
