diff options
| author | Garrett D'Amore <garrett@damore.org> | 2018-04-26 13:53:40 -0700 |
|---|---|---|
| committer | Garrett D'Amore <garrett@damore.org> | 2018-04-26 13:53:40 -0700 |
| commit | 3de2b56557c80b310341c423492bd8ba895c1abe (patch) | |
| tree | 897815f4d9aa30d8c40cbed4c5fec4088d555fda /src/supplemental/tls | |
| parent | 492bfcc90d4b80842b024201cc1e4526404128b4 (diff) | |
| download | nng-3de2b56557c80b310341c423492bd8ba895c1abe.tar.gz nng-3de2b56557c80b310341c423492bd8ba895c1abe.tar.bz2 nng-3de2b56557c80b310341c423492bd8ba895c1abe.zip | |
fixes #105 Want NNG_OPT_TCP_NODELAY option
fixes #106 TCP keepalive tuning
Diffstat (limited to 'src/supplemental/tls')
| -rw-r--r-- | src/supplemental/tls/mbedtls/tls.c | 17 | ||||
| -rw-r--r-- | src/supplemental/tls/tls_api.h | 2 |
2 files changed, 19 insertions, 0 deletions
diff --git a/src/supplemental/tls/mbedtls/tls.c b/src/supplemental/tls/mbedtls/tls.c index c2a0fb52..5246e06c 100644 --- a/src/supplemental/tls/mbedtls/tls.c +++ b/src/supplemental/tls/mbedtls/tls.c @@ -311,6 +311,11 @@ nni_tls_init(nni_tls **tpp, nng_tls_config *cfg, nni_plat_tcp_pipe *tcp) nni_tls *tp; int rv; + // During the handshake, disable Nagle to shorten the + // negotiation. Once things are set up the caller can + // re-enable Nagle if so desired. + (void) nni_plat_tcp_pipe_set_nodelay(tcp, true); + if ((tp = NNI_ALLOC_STRUCT(tp)) == NULL) { return (NNG_ENOMEM); } @@ -606,6 +611,18 @@ nni_tls_sockname(nni_tls *tp, nni_sockaddr *sa) return (nni_plat_tcp_pipe_sockname(tp->tcp, sa)); } +int +nni_tls_set_nodelay(nni_tls *tp, bool val) +{ + return (nni_plat_tcp_pipe_set_nodelay(tp->tcp, val)); +} + +int +nni_tls_set_keepalive(nni_tls *tp, bool val) +{ + return (nni_plat_tcp_pipe_set_keepalive(tp->tcp, val)); +} + static void nni_tls_do_handshake(nni_tls *tp) { diff --git a/src/supplemental/tls/tls_api.h b/src/supplemental/tls/tls_api.h index 24d8e578..8a40bcfb 100644 --- a/src/supplemental/tls/tls_api.h +++ b/src/supplemental/tls/tls_api.h @@ -38,6 +38,8 @@ extern void nni_tls_send(nni_tls *, nng_aio *); extern void nni_tls_recv(nni_tls *, nng_aio *); extern int nni_tls_sockname(nni_tls *, nni_sockaddr *); extern int nni_tls_peername(nni_tls *, nni_sockaddr *); +extern int nni_tls_set_nodelay(nni_tls *, bool); +extern int nni_tls_set_keepalive(nni_tls *, bool); // nni_tls_verified returns true if the peer, or false if the peer did not // verify. (During the handshake phase, the peer is not verified, so this |
