Repository: qpid-proton Updated Branches: refs/heads/master 998d89da4 -> e74b5ca3b
PROTON-1460: fix false failures in epoll proactor tests Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/e74b5ca3 Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/e74b5ca3 Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/e74b5ca3 Branch: refs/heads/master Commit: e74b5ca3ba58ab2ab129746188f77c4d3aaf3c84 Parents: 998d89d Author: Alan Conway <[email protected]> Authored: Wed May 3 19:07:26 2017 -0400 Committer: Alan Conway <[email protected]> Committed: Wed May 3 19:28:01 2017 -0400 ---------------------------------------------------------------------- proton-c/CMakeLists.txt | 4 +- proton-c/src/proactor/proactor-internal.c | 66 ++++++++++++++++++++++++++ proton-c/src/proactor/proactor.c | 66 -------------------------- proton-c/src/tests/proactor.c | 27 ++++++----- 4 files changed, 83 insertions(+), 80 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/e74b5ca3/proton-c/CMakeLists.txt ---------------------------------------------------------------------- diff --git a/proton-c/CMakeLists.txt b/proton-c/CMakeLists.txt index 4bc7666..092f3d4 100644 --- a/proton-c/CMakeLists.txt +++ b/proton-c/CMakeLists.txt @@ -488,7 +488,7 @@ if (PROACTOR STREQUAL "epoll") # OR (NOT PROACTOR AND NOT PROACTOR_OK)) check_symbol_exists(epoll_wait "sys/epoll.h" HAVE_EPOLL) if (HAVE_EPOLL) set (PROACTOR_OK epoll) - set (qpid-proton-proactor src/proactor/epoll.c src/proactor/proactor.c) + set (qpid-proton-proactor src/proactor/epoll.c src/proactor/proactor-internal.c) set (PROACTOR_LIBS "") set_source_files_properties (${qpid-proton-proactor} PROPERTIES COMPILE_FLAGS "${COMPILE_WARNING_FLAGS} ${COMPILE_LANGUAGE_FLAGS} ${LTO}" @@ -500,7 +500,7 @@ if (PROACTOR STREQUAL "libuv" OR (NOT PROACTOR AND NOT PROACTOR_OK)) find_package(Libuv) if (LIBUV_FOUND) set (PROACTOR_OK libuv) - set (qpid-proton-proactor src/proactor/libuv.c src/proactor/proactor.c) + set (qpid-proton-proactor src/proactor/libuv.c src/proactor/proactor-internal.c) set (PROACTOR_LIBS ${Libuv_LIBRARIES}) set_source_files_properties (${qpid-proton-proactor} PROPERTIES COMPILE_FLAGS "${COMPILE_WARNING_FLAGS} ${COMPILE_LANGUAGE_FLAGS} ${LTO}" http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/e74b5ca3/proton-c/src/proactor/proactor-internal.c ---------------------------------------------------------------------- diff --git a/proton-c/src/proactor/proactor-internal.c b/proton-c/src/proactor/proactor-internal.c new file mode 100644 index 0000000..af7b057 --- /dev/null +++ b/proton-c/src/proactor/proactor-internal.c @@ -0,0 +1,66 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + + +/* Common platform-independent implementation for proactor libraries */ + +#include "proactor-internal.h" +#include <proton/error.h> +#include <proton/proactor.h> + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + + +static const char *AMQP_PORT = "5672"; +static const char *AMQP_PORT_NAME = "amqp"; +static const char *AMQPS_PORT = "5671"; +static const char *AMQPS_PORT_NAME = "amqps"; + +int pn_proactor_addr(char *buf, size_t len, const char *host, const char *port) { + return snprintf(buf, len, "%s:%s", host ? host : "", port ? port : ""); +} + +int pni_parse_addr(const char *addr, char *buf, size_t len, const char **host, const char **port) +{ + size_t hplen = strlen(addr); + if (hplen >= len) { + return PN_OVERFLOW; + } + memcpy(buf, addr, hplen+1); + char *p = strrchr(buf, ':'); + if (p) { + *port = p + 1; + *p = '\0'; + if (**port == '\0' || !strcmp(*port, AMQP_PORT_NAME)) { + *port = AMQP_PORT; + } else if (!strcmp(*port, AMQPS_PORT_NAME)) { + *port = AMQPS_PORT; + } + } else { + *port = AMQP_PORT; + } + if (*buf) { + *host = buf; + } else { + *host = NULL; + } + return 0; +} http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/e74b5ca3/proton-c/src/proactor/proactor.c ---------------------------------------------------------------------- diff --git a/proton-c/src/proactor/proactor.c b/proton-c/src/proactor/proactor.c deleted file mode 100644 index af7b057..0000000 --- a/proton-c/src/proactor/proactor.c +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - - -/* Common platform-independent implementation for proactor libraries */ - -#include "proactor-internal.h" -#include <proton/error.h> -#include <proton/proactor.h> - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> - - -static const char *AMQP_PORT = "5672"; -static const char *AMQP_PORT_NAME = "amqp"; -static const char *AMQPS_PORT = "5671"; -static const char *AMQPS_PORT_NAME = "amqps"; - -int pn_proactor_addr(char *buf, size_t len, const char *host, const char *port) { - return snprintf(buf, len, "%s:%s", host ? host : "", port ? port : ""); -} - -int pni_parse_addr(const char *addr, char *buf, size_t len, const char **host, const char **port) -{ - size_t hplen = strlen(addr); - if (hplen >= len) { - return PN_OVERFLOW; - } - memcpy(buf, addr, hplen+1); - char *p = strrchr(buf, ':'); - if (p) { - *port = p + 1; - *p = '\0'; - if (**port == '\0' || !strcmp(*port, AMQP_PORT_NAME)) { - *port = AMQP_PORT; - } else if (!strcmp(*port, AMQPS_PORT_NAME)) { - *port = AMQPS_PORT; - } - } else { - *port = AMQP_PORT; - } - if (*buf) { - *host = buf; - } else { - *host = NULL; - } - return 0; -} http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/e74b5ca3/proton-c/src/tests/proactor.c ---------------------------------------------------------------------- diff --git a/proton-c/src/tests/proactor.c b/proton-c/src/tests/proactor.c index 01332cb..5dfb42a 100644 --- a/proton-c/src/tests/proactor.c +++ b/proton-c/src/tests/proactor.c @@ -345,15 +345,17 @@ static void test_abort(test_t *t) { TEST_ETYPE_EQUAL(t, PN_LISTENER_OPEN, PROACTOR_TEST_RUN(pts)); sock_close(port.sock); pn_proactor_connect(client, pn_connection(), port.host_port); - /* server transport closes */ - TEST_ETYPE_EQUAL(t, PN_TRANSPORT_CLOSED, PROACTOR_TEST_RUN(pts)); - TEST_COND_NAME(t, "amqp:connection:framing-error",last_condition); - TEST_COND_DESC(t, "abort", last_condition); + /* server transport closes */ + if (TEST_ETYPE_EQUAL(t, PN_TRANSPORT_CLOSED, PROACTOR_TEST_RUN(pts))) { + TEST_COND_NAME(t, "amqp:connection:framing-error",last_condition); + TEST_COND_DESC(t, "abort", last_condition); + } /* client transport closes */ - TEST_ETYPE_EQUAL(t, PN_TRANSPORT_CLOSED, PROACTOR_TEST_RUN(pts)); /* client */ - TEST_COND_NAME(t, "amqp:connection:framing-error", last_condition); - TEST_COND_DESC(t, "abort", last_condition); + if (TEST_ETYPE_EQUAL(t, PN_TRANSPORT_CLOSED, PROACTOR_TEST_RUN(pts))) { + TEST_COND_NAME(t, "amqp:connection:framing-error", last_condition); + TEST_COND_DESC(t, "abort", last_condition); + } pn_listener_close(l); PROACTOR_TEST_DRAIN(pts); @@ -847,6 +849,8 @@ static void test_disconnect(test_t *t) { TEST_ETYPE_EQUAL(t, PN_PROACTOR_INACTIVE, PROACTOR_TEST_RUN(pts)); pn_proactor_disconnect(server, cond); + pn_condition_free(cond); + int expect_tclose = 2, expect_lclose = 2; while (expect_tclose || expect_lclose) { pn_event_type_t et = PROACTOR_TEST_RUN(pts); @@ -854,12 +858,12 @@ static void test_disconnect(test_t *t) { case PN_TRANSPORT_CLOSED: TEST_CHECK(t, --expect_tclose >= 0); TEST_STR_EQUAL(t, "test-name", pn_condition_get_name(last_condition)); - TEST_STR_EQUAL(t, "test-description", pn_condition_get_description(last_condition)); + TEST_STR_IN(t, "test-description", pn_condition_get_description(last_condition)); break; case PN_LISTENER_CLOSE: TEST_CHECK(t, --expect_lclose >= 0); TEST_STR_EQUAL(t, "test-name", pn_condition_get_name(last_condition)); - TEST_STR_EQUAL(t, "test-description", pn_condition_get_description(last_condition)); + TEST_STR_IN(t, "test-description", pn_condition_get_description(last_condition)); break; default: TEST_ERRORF(t, "%s unexpected: want %d TRANSPORT_CLOSED, %d LISTENER_CLOSE", @@ -868,8 +872,7 @@ static void test_disconnect(test_t *t) { continue; } } - - pn_condition_free(cond); + TEST_ETYPE_EQUAL(t, PN_PROACTOR_INACTIVE, PROACTOR_TEST_RUN(pts)); /* Make sure the proactors are still functional */ test_port_t port3 = test_port(localhost); @@ -881,7 +884,7 @@ static void test_disconnect(test_t *t) { TEST_ETYPE_EQUAL(t, PN_CONNECTION_REMOTE_OPEN, PROACTOR_TEST_RUN(pts)); pn_proactor_disconnect(client, NULL); - PROACTOR_TEST_DRAIN(pts); /* Drain will */ + PROACTOR_TEST_DRAIN(pts); PROACTOR_TEST_FREE(pts); } --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
