summaryrefslogtreecommitdiff
path: root/src/core/socket.c
diff options
context:
space:
mode:
authorGarrett D'Amore <garrett@damore.org>2019-02-18 20:15:16 -0800
committerGarrett D'Amore <garrett@damore.org>2019-02-23 11:50:17 -0800
commit64e784237d143aa032311942bc44abd22e1e4114 (patch)
treee3ea529d5e5adfd022773ab207622cc2247f057c /src/core/socket.c
parentd210ef96517c1462bc058c95bced8c27b5e19c4f (diff)
downloadnng-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/socket.c')
-rw-r--r--src/core/socket.c30
1 files changed, 12 insertions, 18 deletions
diff --git a/src/core/socket.c b/src/core/socket.c
index 387796a6..dadc9073 100644
--- a/src/core/socket.c
+++ b/src/core/socket.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>
//
// This software is supplied under the terms of the MIT License, a
@@ -58,8 +58,7 @@ typedef struct sock_stats {
nni_stat_item s_txbytes; // number of bytes received
nni_stat_item s_rxmsgs; // number of msgs received
nni_stat_item s_txmsgs; // number of msgs sent
- nni_stat_item s_protorej; // pipes rejected by protocol
- nni_stat_item s_apprej; // pipes rejected by application
+ nni_stat_item s_reject; // pipes rejected
} sock_stats;
struct nni_socket {
@@ -465,13 +464,8 @@ sock_stats_init(nni_sock *s)
nni_stat_set_unit(&st->s_txmsgs, NNG_UNIT_MESSAGES);
nni_stat_append(root, &st->s_txmsgs);
- nni_stat_init_atomic(
- &st->s_protorej, "protoreject", "pipes rejected by protocol");
- nni_stat_append(root, &st->s_protorej);
-
- nni_stat_init_atomic(
- &st->s_apprej, "appreject", "pipes rejected by application");
- nni_stat_append(root, &st->s_apprej);
+ nni_stat_init_atomic(&st->s_reject, "reject", "pipes rejected");
+ nni_stat_append(root, &st->s_reject);
#else
NNI_ARG_UNUSED(s);
#endif
@@ -1441,15 +1435,15 @@ nni_dialer_add_pipe(nni_dialer *d, void *tpipe)
nni_mtx_lock(&s->s_mx);
if (p->p_closed) {
nni_mtx_unlock(&s->s_mx);
- nni_stat_inc_atomic(&d->d_stats.s_apprej, 1);
- nni_stat_inc_atomic(&s->s_stats.s_apprej, 1);
+ nni_stat_inc_atomic(&d->d_stats.s_reject, 1);
+ nni_stat_inc_atomic(&s->s_stats.s_reject, 1);
nni_pipe_rele(p);
return;
}
if (p->p_proto_ops.pipe_start(p->p_proto_data) != 0) {
nni_mtx_unlock(&s->s_mx);
- nni_stat_inc_atomic(&d->d_stats.s_protorej, 1);
- nni_stat_inc_atomic(&s->s_stats.s_protorej, 1);
+ nni_stat_inc_atomic(&d->d_stats.s_reject, 1);
+ nni_stat_inc_atomic(&s->s_stats.s_reject, 1);
nni_pipe_close(p);
nni_pipe_rele(p);
return;
@@ -1550,15 +1544,15 @@ nni_listener_add_pipe(nni_listener *l, void *tpipe)
nni_mtx_lock(&s->s_mx);
if (p->p_closed) {
nni_mtx_unlock(&s->s_mx);
- nni_stat_inc_atomic(&l->l_stats.s_apprej, 1);
- nni_stat_inc_atomic(&s->s_stats.s_apprej, 1);
+ nni_stat_inc_atomic(&l->l_stats.s_reject, 1);
+ nni_stat_inc_atomic(&s->s_stats.s_reject, 1);
nni_pipe_rele(p);
return;
}
if (p->p_proto_ops.pipe_start(p->p_proto_data) != 0) {
nni_mtx_unlock(&s->s_mx);
- nni_stat_inc_atomic(&l->l_stats.s_protorej, 1);
- nni_stat_inc_atomic(&s->s_stats.s_protorej, 1);
+ nni_stat_inc_atomic(&l->l_stats.s_reject, 1);
+ nni_stat_inc_atomic(&s->s_stats.s_reject, 1);
nni_pipe_close(p);
nni_pipe_rele(p);
return;