From 1b2f22fd68a2e50cabdfe2e036096cc9e7a05a1f Mon Sep 17 00:00:00 2001 From: Garrett D'Amore Date: Fri, 5 Jan 2018 14:44:10 -0800 Subject: Convert existing websocket and http code to use new URL framework. This also fixes a use-after-free bug in the HTTP framework, where the handler could be deleted why callbacks were still using it. (We now reference count the handlers.) --- tests/tcp.c | 48 +++++++++++++++++++++--------------------------- 1 file changed, 21 insertions(+), 27 deletions(-) (limited to 'tests/tcp.c') diff --git a/tests/tcp.c b/tests/tcp.c index fdcf458c..5860eb03 100644 --- a/tests/tcp.c +++ b/tests/tcp.c @@ -1,6 +1,6 @@ // -// Copyright 2017 Garrett D'Amore -// Copyright 2017 Capitar IT Group BV +// Copyright 2018 Staysail Systems, Inc. +// Copyright 2018 Capitar IT Group BV // // This software is supplied under the terms of the MIT License, a // copy of which should be located in the distribution where this @@ -23,31 +23,27 @@ static int check_props_v4(nng_msg *msg, nng_listener l, nng_dialer d) { - nng_pipe p; - size_t z; + nng_pipe p; + size_t z; + nng_sockaddr la; + nng_sockaddr ra; + p = nng_msg_get_pipe(msg); So(p > 0); - - Convey("Local address property works", { - nng_sockaddr la; - z = sizeof(nng_sockaddr); - So(nng_pipe_getopt(p, NNG_OPT_LOCADDR, &la, &z) == 0); - So(z == sizeof(la)); - So(la.s_un.s_family == NNG_AF_INET); - So(la.s_un.s_in.sa_port == htons(trantest_port - 1)); - So(la.s_un.s_in.sa_port != 0); - So(la.s_un.s_in.sa_addr == htonl(0x7f000001)); - }); - - Convey("Remote address property works", { - nng_sockaddr ra; - z = sizeof(nng_sockaddr); - So(nng_pipe_getopt(p, NNG_OPT_REMADDR, &ra, &z) == 0); - So(z == sizeof(ra)); - So(ra.s_un.s_family == NNG_AF_INET); - So(ra.s_un.s_in.sa_port != 0); - So(ra.s_un.s_in.sa_addr == htonl(0x7f000001)); - }); + z = sizeof(nng_sockaddr); + So(nng_pipe_getopt(p, NNG_OPT_LOCADDR, &la, &z) == 0); + So(z == sizeof(la)); + So(la.s_un.s_family == NNG_AF_INET); + So(la.s_un.s_in.sa_port == htons(trantest_port - 1)); + So(la.s_un.s_in.sa_port != 0); + So(la.s_un.s_in.sa_addr == htonl(0x7f000001)); + + z = sizeof(nng_sockaddr); + So(nng_pipe_getopt(p, NNG_OPT_REMADDR, &ra, &z) == 0); + So(z == sizeof(ra)); + So(ra.s_un.s_family == NNG_AF_INET); + So(ra.s_un.s_in.sa_port != 0); + So(ra.s_un.s_in.sa_addr == htonl(0x7f000001)); return (0); } @@ -94,8 +90,6 @@ TestMain("TCP Transport", { NNG_EADDRINVAL); So(nng_dial(s1, "tcp://127.0.x.1.32", NULL, 0) == NNG_EADDRINVAL); - So(nng_listen(s1, "tcp://127.0.0.1", NULL, 0) == - NNG_EADDRINVAL); So(nng_listen(s1, "tcp://127.0.0.1.32", NULL, 0) == NNG_EADDRINVAL); So(nng_listen(s1, "tcp://127.0.x.1.32", NULL, 0) == -- cgit v1.2.3-70-g09d2