From 801ace5e9adca4e53497d6c7133cc32cf94b23b7 Mon Sep 17 00:00:00 2001 From: Garrett D'Amore Date: Mon, 28 Oct 2024 15:53:23 -0700 Subject: Remove nng_stream_set function family. This was not really used or useful. --- src/platform/posix/posix_tcpconn.c | 54 +++++--------------------------------- src/platform/windows/win_tcpconn.c | 39 --------------------------- 2 files changed, 6 insertions(+), 87 deletions(-) (limited to 'src/platform') diff --git a/src/platform/posix/posix_tcpconn.c b/src/platform/posix/posix_tcpconn.c index 2494b05e..74b3371b 100644 --- a/src/platform/posix/posix_tcpconn.c +++ b/src/platform/posix/posix_tcpconn.c @@ -1,5 +1,5 @@ // -// Copyright 2020 Staysail Systems, Inc. +// Copyright 2024 Staysail Systems, Inc. // Copyright 2018 Capitar IT Group BV // Copyright 2019 Devolutions // @@ -42,7 +42,7 @@ tcp_dowrite(nni_tcp_conn *c) int n; int niov; unsigned naiov; - nni_iov * aiov; + nni_iov *aiov; struct msghdr hdr; struct iovec iovec[16]; @@ -111,7 +111,7 @@ tcp_doread(nni_tcp_conn *c) int n; int niov; unsigned naiov; - nni_iov * aiov; + nni_iov *aiov; struct iovec iovec[16]; nni_aio_get_iov(aio, &naiov, &aiov); @@ -165,7 +165,7 @@ static void tcp_error(void *arg, int err) { nni_tcp_conn *c = arg; - nni_aio * aio; + nni_aio *aio; nni_mtx_lock(&c->mtx); while (((aio = nni_list_first(&c->readq)) != NULL) || @@ -337,7 +337,7 @@ tcp_recv(void *arg, nni_aio *aio) static int tcp_get_peername(void *arg, void *buf, size_t *szp, nni_type t) { - nni_tcp_conn * c = arg; + nni_tcp_conn *c = arg; struct sockaddr_storage ss; socklen_t len = sizeof(ss); int fd = nni_posix_pfd_fd(c->pfd); @@ -356,7 +356,7 @@ tcp_get_peername(void *arg, void *buf, size_t *szp, nni_type t) static int tcp_get_sockname(void *arg, void *buf, size_t *szp, nni_type t) { - nni_tcp_conn * c = arg; + nni_tcp_conn *c = arg; struct sockaddr_storage ss; socklen_t len = sizeof(ss); int fd = nni_posix_pfd_fd(c->pfd); @@ -372,46 +372,6 @@ tcp_get_sockname(void *arg, void *buf, size_t *szp, nni_type t) return (rv); } -static int -tcp_set_nodelay(void *arg, const void *buf, size_t sz, nni_type t) -{ - nni_tcp_conn *c = arg; - int fd; - bool b; - int val; - int rv; - - if (((rv = nni_copyin_bool(&b, buf, sz, t)) != 0) || (c == NULL)) { - return (rv); - } - val = b ? 1 : 0; - fd = nni_posix_pfd_fd(c->pfd); - if (setsockopt(fd, IPPROTO_TCP, TCP_NODELAY, &val, sizeof(val)) != 0) { - return (nni_plat_errno(errno)); - } - return (0); -} - -static int -tcp_set_keepalive(void *arg, const void *buf, size_t sz, nni_type t) -{ - nni_tcp_conn *c = arg; - int fd; - bool b; - int val; - int rv; - - if (((rv = nni_copyin_bool(&b, buf, sz, t)) != 0) || (c == NULL)) { - return (rv); - } - val = b ? 1 : 0; - fd = nni_posix_pfd_fd(c->pfd); - if (setsockopt(fd, SOL_SOCKET, SO_KEEPALIVE, &val, sizeof(val)) != 0) { - return (nni_plat_errno(errno)); - } - return (0); -} - static int tcp_get_nodelay(void *arg, void *buf, size_t *szp, nni_type t) { @@ -454,12 +414,10 @@ static const nni_option tcp_options[] = { { .o_name = NNG_OPT_TCP_NODELAY, .o_get = tcp_get_nodelay, - .o_set = tcp_set_nodelay, }, { .o_name = NNG_OPT_TCP_KEEPALIVE, .o_get = tcp_get_keepalive, - .o_set = tcp_set_keepalive, }, { .o_name = NULL, diff --git a/src/platform/windows/win_tcpconn.c b/src/platform/windows/win_tcpconn.c index eaae822a..3f3acd17 100644 --- a/src/platform/windows/win_tcpconn.c +++ b/src/platform/windows/win_tcpconn.c @@ -304,43 +304,6 @@ tcp_get_sockname(void *arg, void *buf, size_t *szp, nni_type t) return (nni_copyout_sockaddr(&sa, buf, szp, t)); } -static int -tcp_set_nodelay(void *arg, const void *buf, size_t sz, nni_type t) -{ - nni_tcp_conn *c = arg; - bool val; - BOOL b; - int rv; - if ((rv = nni_copyin_bool(&val, buf, sz, t)) != 0) { - return (rv); - } - b = val ? TRUE : FALSE; - if (setsockopt( - c->s, IPPROTO_TCP, TCP_NODELAY, (void *) &b, sizeof(b)) != 0) { - return (nni_win_error(WSAGetLastError())); - } - return (0); -} - -static int -tcp_set_keepalive(void *arg, const void *buf, size_t sz, nni_type t) -{ - nni_tcp_conn *c = arg; - bool val; - BOOL b; - int rv; - - if ((rv = nni_copyin_bool(&val, buf, sz, t)) != 0) { - return (rv); - } - b = val ? TRUE : FALSE; - if (setsockopt( - c->s, SOL_SOCKET, SO_KEEPALIVE, (void *) &b, sizeof(b)) != 0) { - return (nni_win_error(WSAGetLastError())); - } - return (0); -} - static int tcp_get_nodelay(void *arg, void *buf, size_t *szp, nni_type t) { @@ -381,12 +344,10 @@ static const nni_option tcp_options[] = { { .o_name = NNG_OPT_TCP_NODELAY, .o_get = tcp_get_nodelay, - .o_set = tcp_set_nodelay, }, { .o_name = NNG_OPT_TCP_KEEPALIVE, .o_get = tcp_get_keepalive, - .o_set = tcp_set_keepalive, }, { .o_name = NULL, -- cgit v1.2.3-70-g09d2