diff options
| author | Garrett D'Amore <garrett@damore.org> | 2018-07-13 09:13:13 -0700 |
|---|---|---|
| committer | Garrett D'Amore <garrett@damore.org> | 2018-07-16 10:06:55 -0700 |
| commit | 3715056cf6337d2692b6916739042cff5296761d (patch) | |
| tree | a6960d619d5655dde20143a39e6569a27a60f6c8 /src/platform/posix | |
| parent | 4b75793ad60a228db727f76caa10615e4a14899b (diff) | |
| download | nng-3715056cf6337d2692b6916739042cff5296761d.tar.gz nng-3715056cf6337d2692b6916739042cff5296761d.tar.bz2 nng-3715056cf6337d2692b6916739042cff5296761d.zip | |
fixes #591 incorrect reuse of server instances by websocket
This also arranges for server shutdown to be handled using
the reaper, leading to more elegant cleanup.
Diffstat (limited to 'src/platform/posix')
| -rw-r--r-- | src/platform/posix/posix_tcp.c | 69 | ||||
| -rw-r--r-- | src/platform/posix/posix_tcpconn.c | 2 |
2 files changed, 2 insertions, 69 deletions
diff --git a/src/platform/posix/posix_tcp.c b/src/platform/posix/posix_tcp.c deleted file mode 100644 index 53ea8026..00000000 --- a/src/platform/posix/posix_tcp.c +++ /dev/null @@ -1,69 +0,0 @@ -// -// Copyright 2018 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 -// copy of which should be located in the distribution where this -// file was obtained (LICENSE.txt). A copy of the license may also be -// found online at https://opensource.org/licenses/MIT. -// - -#include "core/nng_impl.h" - -#ifdef NNG_PLATFORM_POSIX -#include "platform/posix/posix_aio.h" - -#include <arpa/inet.h> -#include <errno.h> -#include <fcntl.h> -#include <netinet/in.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <sys/socket.h> -#include <sys/types.h> -#include <sys/uio.h> -#include <unistd.h> - -int -nni_plat_tcp_ntop(const nni_sockaddr *sa, char *ipstr, char *portstr) -{ - const void *ap; - uint16_t port; - int af; - switch (sa->s_family) { - case NNG_AF_INET: - ap = &sa->s_in.sa_addr; - port = sa->s_in.sa_port; - af = AF_INET; - break; - case NNG_AF_INET6: - ap = &sa->s_in6.sa_addr; - port = sa->s_in6.sa_port; - af = AF_INET6; - break; - default: - return (NNG_EINVAL); - } - if (ipstr != NULL) { - if (af == AF_INET6) { - size_t l; - ipstr[0] = '['; - inet_ntop(af, ap, ipstr + 1, INET6_ADDRSTRLEN); - l = strlen(ipstr); - ipstr[l++] = ']'; - ipstr[l++] = '\0'; - } else { - inet_ntop(af, ap, ipstr, INET6_ADDRSTRLEN); - } - } - if (portstr != NULL) { -#ifdef NNG_LITTLE_ENDIAN - port = ((port >> 8) & 0xff) | ((port & 0xff) << 8); -#endif - snprintf(portstr, 6, "%u", port); - } - return (0); -} - -#endif // NNG_PLATFORM_POSIX diff --git a/src/platform/posix/posix_tcpconn.c b/src/platform/posix/posix_tcpconn.c index 30525648..5cd1887a 100644 --- a/src/platform/posix/posix_tcpconn.c +++ b/src/platform/posix/posix_tcpconn.c @@ -401,7 +401,9 @@ nni_tcp_conn_fini(nni_tcp_conn *c) { nni_tcp_conn_close(c); nni_posix_pfd_fini(c->pfd); + nni_mtx_lock(&c->mtx); // not strictly needed, but shut up TSAN c->pfd = NULL; + nni_mtx_unlock(&c->mtx); nni_mtx_fini(&c->mtx); NNI_FREE_STRUCT(c); |
