parent
e8e881e11a
commit
567427ba98
@ -1,198 +0,0 @@
|
|||||||
From ea875055e446da8514b10e3b6af0942997544af0 Mon Sep 17 00:00:00 2001
|
|
||||||
From: Alan Conway <aconway@redhat.com>
|
|
||||||
Date: Wed, 10 May 2017 16:30:14 -0400
|
|
||||||
Subject: [PATCH] PROTON-1466: proton-c mixing up links with names that are
|
|
||||||
prefixes
|
|
||||||
|
|
||||||
Creating links where one link name is a prefix of the other, e.g. "xx" and
|
|
||||||
"xxyy" sometimes caused the links to be confused.
|
|
||||||
---
|
|
||||||
proton-c/src/core/codec.c | 2 +-
|
|
||||||
proton-c/src/core/transport.c | 14 +++++------
|
|
||||||
proton-c/src/core/util.h | 11 +++++++++
|
|
||||||
proton-c/src/extra/scanner.c | 8 ++++---
|
|
||||||
proton-c/src/tests/engine.c | 55 +++++++++++++++++++++++++++++++++++++++++++
|
|
||||||
5 files changed, 79 insertions(+), 11 deletions(-)
|
|
||||||
|
|
||||||
diff --git a/proton-c/src/core/codec.c b/proton-c/src/core/codec.c
|
|
||||||
index 67769ad..7809907 100644
|
|
||||||
--- a/proton-c/src/core/codec.c
|
|
||||||
+++ b/proton-c/src/core/codec.c
|
|
||||||
@@ -1328,7 +1328,7 @@ bool pn_data_lookup(pn_data_t *data, const char *name)
|
|
||||||
case PN_SYMBOL:
|
|
||||||
{
|
|
||||||
pn_bytes_t bytes = pn_data_get_bytes(data);
|
|
||||||
- if (strlen(name) == bytes.size && !strncmp(name, bytes.start, bytes.size)) {
|
|
||||||
+ if (pn_bytes_equal(bytes, pn_bytes(strlen(name), name))) {
|
|
||||||
return pn_data_next(data);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
diff --git a/proton-c/src/core/transport.c b/proton-c/src/core/transport.c
|
|
||||||
index 8777318..f9eea7b 100644
|
|
||||||
--- a/proton-c/src/core/transport.c
|
|
||||||
+++ b/proton-c/src/core/transport.c
|
|
||||||
@@ -1277,7 +1277,7 @@ pn_link_t *pn_find_link(pn_session_t *ssn, pn_bytes_t name, bool is_sender)
|
|
||||||
// which is closed both locally and remotely, assume that is
|
|
||||||
// no longer in use.
|
|
||||||
!((link->endpoint.state & PN_LOCAL_CLOSED) && (link->endpoint.state & PN_REMOTE_CLOSED)) &&
|
|
||||||
- !strncmp(name.start, pn_string_get(link->name), name.size))
|
|
||||||
+ pn_bytes_equal(name, pn_string_bytes(link->name)))
|
|
||||||
{
|
|
||||||
return link;
|
|
||||||
}
|
|
||||||
@@ -1290,13 +1290,13 @@ static pn_expiry_policy_t symbol2policy(pn_bytes_t symbol)
|
|
||||||
if (!symbol.start)
|
|
||||||
return PN_EXPIRE_WITH_SESSION;
|
|
||||||
|
|
||||||
- if (!strncmp(symbol.start, "link-detach", symbol.size))
|
|
||||||
+ if (pn_bytes_equal(symbol, PN_BYTES_LITERAL(link-detach)))
|
|
||||||
return PN_EXPIRE_WITH_LINK;
|
|
||||||
- if (!strncmp(symbol.start, "session-end", symbol.size))
|
|
||||||
+ if (pn_bytes_equal(symbol, PN_BYTES_LITERAL(session-end)))
|
|
||||||
return PN_EXPIRE_WITH_SESSION;
|
|
||||||
- if (!strncmp(symbol.start, "connection-close", symbol.size))
|
|
||||||
+ if (pn_bytes_equal(symbol, PN_BYTES_LITERAL(connection-close)))
|
|
||||||
return PN_EXPIRE_WITH_CONNECTION;
|
|
||||||
- if (!strncmp(symbol.start, "never", symbol.size))
|
|
||||||
+ if (pn_bytes_equal(symbol, PN_BYTES_LITERAL(never)))
|
|
||||||
return PN_EXPIRE_NEVER;
|
|
||||||
|
|
||||||
return PN_EXPIRE_WITH_SESSION;
|
|
||||||
@@ -1307,9 +1307,9 @@ static pn_distribution_mode_t symbol2dist_mode(const pn_bytes_t symbol)
|
|
||||||
if (!symbol.start)
|
|
||||||
return PN_DIST_MODE_UNSPECIFIED;
|
|
||||||
|
|
||||||
- if (!strncmp(symbol.start, "move", symbol.size))
|
|
||||||
+ if (pn_bytes_equal(symbol, PN_BYTES_LITERAL(move)))
|
|
||||||
return PN_DIST_MODE_MOVE;
|
|
||||||
- if (!strncmp(symbol.start, "copy", symbol.size))
|
|
||||||
+ if (pn_bytes_equal(symbol, PN_BYTES_LITERAL(copy)))
|
|
||||||
return PN_DIST_MODE_COPY;
|
|
||||||
|
|
||||||
return PN_DIST_MODE_UNSPECIFIED;
|
|
||||||
diff --git a/proton-c/src/core/util.h b/proton-c/src/core/util.h
|
|
||||||
index b54f689..4d3ba3b 100644
|
|
||||||
--- a/proton-c/src/core/util.h
|
|
||||||
+++ b/proton-c/src/core/util.h
|
|
||||||
@@ -44,6 +44,17 @@ char *pn_strndup(const char *src, size_t n);
|
|
||||||
int pn_strcasecmp(const char* a, const char* b);
|
|
||||||
int pn_strncasecmp(const char* a, const char* b, size_t len);
|
|
||||||
|
|
||||||
+static inline bool pn_bytes_equal(const pn_bytes_t a, const pn_bytes_t b) {
|
|
||||||
+ return (a.size == b.size && !memcmp(a.start, b.start, a.size));
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+static inline pn_bytes_t pn_string_bytes(pn_string_t *s) {
|
|
||||||
+ return pn_bytes(pn_string_size(s), pn_string_get(s));
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+/* Create a literal bytes value, e.g. PN_BYTES_LITERAL(foo) == pn_bytes(3, "foo") */
|
|
||||||
+#define PN_BYTES_LITERAL(X) (pn_bytes(sizeof(#X)-1, #X))
|
|
||||||
+
|
|
||||||
#define DIE_IFR(EXPR, STRERR) \
|
|
||||||
do { \
|
|
||||||
int __code__ = (EXPR); \
|
|
||||||
diff --git a/proton-c/src/extra/scanner.c b/proton-c/src/extra/scanner.c
|
|
||||||
index beb7322..99c35d2 100644
|
|
||||||
--- a/proton-c/src/extra/scanner.c
|
|
||||||
+++ b/proton-c/src/extra/scanner.c
|
|
||||||
@@ -20,6 +20,7 @@
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "scanner.h"
|
|
||||||
+#include "../core/util.h"
|
|
||||||
|
|
||||||
#include "platform/platform.h"
|
|
||||||
|
|
||||||
@@ -217,12 +218,13 @@ static int pni_scanner_alpha_end(pn_scanner_t *scanner, const char *str, int sta
|
|
||||||
static int pni_scanner_alpha(pn_scanner_t *scanner, const char *str)
|
|
||||||
{
|
|
||||||
int n = pni_scanner_alpha_end(scanner, str, 0);
|
|
||||||
+ pn_bytes_t b = pn_bytes(n, str);
|
|
||||||
pn_token_type_t type;
|
|
||||||
- if (!strncmp(str, "true", n)) {
|
|
||||||
+ if (pn_bytes_equal(b, PN_BYTES_LITERAL(true))) {
|
|
||||||
type = PN_TOK_TRUE;
|
|
||||||
- } else if (!strncmp(str, "false", n)) {
|
|
||||||
+ } else if (pn_bytes_equal(b, PN_BYTES_LITERAL(false))) {
|
|
||||||
type = PN_TOK_FALSE;
|
|
||||||
- } else if (!strncmp(str, "null", n)) {
|
|
||||||
+ } else if (pn_bytes_equal(b, PN_BYTES_LITERAL(null))) {
|
|
||||||
type = PN_TOK_NULL;
|
|
||||||
} else {
|
|
||||||
type = PN_TOK_ID;
|
|
||||||
diff --git a/proton-c/src/tests/engine.c b/proton-c/src/tests/engine.c
|
|
||||||
index 87d8d95..41d17a0 100644
|
|
||||||
--- a/proton-c/src/tests/engine.c
|
|
||||||
+++ b/proton-c/src/tests/engine.c
|
|
||||||
@@ -294,12 +294,67 @@ int test_free_link(int argc, char **argv)
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
+// regression test fo PROTON-1466 - confusion between links with prefix names
|
|
||||||
+static int test_link_name_prefix(int argc, char **argv)
|
|
||||||
+{
|
|
||||||
+ fprintf(stdout, "test_link_name_prefix\n");
|
|
||||||
+ pn_connection_t *c1 = pn_connection();
|
|
||||||
+ pn_transport_t *t1 = pn_transport();
|
|
||||||
+ pn_transport_bind(t1, c1);
|
|
||||||
+
|
|
||||||
+ pn_connection_t *c2 = pn_connection();
|
|
||||||
+ pn_transport_t *t2 = pn_transport();
|
|
||||||
+ pn_transport_set_server(t2);
|
|
||||||
+ pn_transport_bind(t2, c2);
|
|
||||||
+
|
|
||||||
+ pn_connection_open(c1);
|
|
||||||
+ pn_connection_open(c2);
|
|
||||||
+
|
|
||||||
+ pn_session_t *s1 = pn_session(c1);
|
|
||||||
+ pn_session_open(s1);
|
|
||||||
+
|
|
||||||
+ pn_link_t *l = pn_receiver(s1, "l");
|
|
||||||
+ pn_link_open(l);
|
|
||||||
+ pn_link_t *lll = pn_receiver(s1, "lll");
|
|
||||||
+ pn_link_open(lll);
|
|
||||||
+ pn_link_t *ll = pn_receiver(s1, "ll");
|
|
||||||
+ pn_link_open(ll);
|
|
||||||
+
|
|
||||||
+ while (pump(t1, t2)) {
|
|
||||||
+ process_endpoints(c1);
|
|
||||||
+ process_endpoints(c2);
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ // session and link should be up, c2 should have a receiver link:
|
|
||||||
+ assert(pn_session_state( s1 ) == (PN_LOCAL_ACTIVE | PN_REMOTE_ACTIVE));
|
|
||||||
+ assert(pn_link_state( l ) == (PN_LOCAL_ACTIVE | PN_REMOTE_ACTIVE));
|
|
||||||
+ assert(pn_link_state( lll ) == (PN_LOCAL_ACTIVE | PN_REMOTE_ACTIVE));
|
|
||||||
+ assert(pn_link_state( ll ) == (PN_LOCAL_ACTIVE | PN_REMOTE_ACTIVE));
|
|
||||||
+
|
|
||||||
+ pn_link_t *r = pn_link_head(c2, (PN_LOCAL_ACTIVE | PN_REMOTE_ACTIVE));
|
|
||||||
+ assert(!strcmp(pn_link_name(r), "l"));
|
|
||||||
+ r = pn_link_next(r, (PN_LOCAL_ACTIVE | PN_REMOTE_ACTIVE));
|
|
||||||
+ assert(!strcmp(pn_link_name(r), "lll"));
|
|
||||||
+ r = pn_link_next(r, (PN_LOCAL_ACTIVE | PN_REMOTE_ACTIVE));
|
|
||||||
+ assert(!strcmp(pn_link_name(r), "ll"));
|
|
||||||
+
|
|
||||||
+ pn_transport_unbind(t1);
|
|
||||||
+ pn_transport_free(t1);
|
|
||||||
+ pn_connection_free(c1);
|
|
||||||
+
|
|
||||||
+ pn_transport_unbind(t2);
|
|
||||||
+ pn_transport_free(t2);
|
|
||||||
+ pn_connection_free(c2);
|
|
||||||
+
|
|
||||||
+ return 0;
|
|
||||||
+}
|
|
||||||
|
|
||||||
typedef int (*test_ptr_t)(int argc, char **argv);
|
|
||||||
|
|
||||||
test_ptr_t tests[] = {test_free_connection,
|
|
||||||
test_free_session,
|
|
||||||
test_free_link,
|
|
||||||
+ test_link_name_prefix,
|
|
||||||
NULL};
|
|
||||||
|
|
||||||
int main(int argc, char **argv)
|
|
||||||
--
|
|
||||||
2.9.3
|
|
||||||
|
|
@ -1,41 +0,0 @@
|
|||||||
From 1b8dae76d36167b9f3e0748968d9b6ee1da3bc20 Mon Sep 17 00:00:00 2001
|
|
||||||
From: Justin Ross <jross@apache.org>
|
|
||||||
Date: Tue, 8 Aug 2017 13:58:38 -0700
|
|
||||||
Subject: [PATCH] PROTON-1526: Ensure the module .so file has no prefix; remove
|
|
||||||
version-based rename
|
|
||||||
|
|
||||||
---
|
|
||||||
proton-c/bindings/perl/CMakeLists.txt | 14 +++-----------
|
|
||||||
1 file changed, 3 insertions(+), 11 deletions(-)
|
|
||||||
|
|
||||||
diff --git a/proton-c/bindings/perl/CMakeLists.txt b/proton-c/bindings/perl/CMakeLists.txt
|
|
||||||
index 1356cce..744e812 100644
|
|
||||||
--- a/proton-c/bindings/perl/CMakeLists.txt
|
|
||||||
+++ b/proton-c/bindings/perl/CMakeLists.txt
|
|
||||||
@@ -54,20 +54,12 @@ list(APPEND SWIG_MODULE_cproton_perl_EXTRA_DEPS
|
|
||||||
${PROTON_HEADERS}
|
|
||||||
)
|
|
||||||
swig_add_module(cproton_perl perl perl.i)
|
|
||||||
+set_target_properties(cproton_perl PROPERTIES PREFIX "")
|
|
||||||
swig_link_libraries(cproton_perl ${BINDING_DEPS} ${PERL_LIBRARY})
|
|
||||||
|
|
||||||
-if ((${CMAKE_MAJOR_VERSION} EQUAL 2) AND (${CMAKE_MINOR_VERSION} LESS 8))
|
|
||||||
- install(FILES ${CMAKE_CURRENT_BINARY_DIR}/cproton_perl.so
|
|
||||||
+install(FILES ${CMAKE_CURRENT_BINARY_DIR}/cproton_perl.so
|
|
||||||
DESTINATION ${PERL_VENDORARCH_DIR}/auto/cproton_perl
|
|
||||||
- COMPONENT Perl
|
|
||||||
- )
|
|
||||||
-else()
|
|
||||||
- install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libcproton_perl.so
|
|
||||||
- RENAME cproton_perl.so
|
|
||||||
- DESTINATION ${PERL_VENDORARCH_DIR}/auto/cproton_perl
|
|
||||||
- COMPONENT Perl
|
|
||||||
- )
|
|
||||||
-endif ((${CMAKE_MAJOR_VERSION} EQUAL 2) AND (${CMAKE_MINOR_VERSION} LESS 8))
|
|
||||||
+ COMPONENT Perl)
|
|
||||||
|
|
||||||
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/cproton_perl.pm
|
|
||||||
DESTINATION ${PERL_VENDORARCH_DIR}
|
|
||||||
--
|
|
||||||
1.8.3.1
|
|
||||||
|
|
@ -0,0 +1,15 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||||
|
<licenseSummary>
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<packageName>qpid-proton</packageName>
|
||||||
|
<version>0.18.0</version>
|
||||||
|
<licenses>
|
||||||
|
<license>
|
||||||
|
<name>ASL 2.0</name>
|
||||||
|
<url>http://www.apache.org/licenses/LICENSE-2.0</url>
|
||||||
|
</license>
|
||||||
|
</licenses>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
</licenseSummary>
|
@ -1 +1 @@
|
|||||||
SHA512 (qpid-proton-0.17.0.tar.gz) = ce082fdc2793fc9d3db1b558bd897d364543bd50cba60e66aff839f8f16d82c245381d836ef3ee5b6ee17ba2b2ffe1899b86ed9d1f8cf8db569f726b6d162463
|
SHA512 (qpid-proton-0.18.1.tar.gz) = f51f7c622351255758ca3727d758f0893088d9e2f13d350134b06784e85da476e01cd73f747d20543933fefe202f55d0f56c50015e9d2be6ba9ab819aa85f23c
|
||||||
|
Loading…
Reference in new issue