[qpid-dispatch] branch master updated: DISPATCH-1941: fix http1 parser to detect null characters

2021-02-12 Thread kgiusti
This is an automated email from the ASF dual-hosted git repository.

kgiusti pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/qpid-dispatch.git


The following commit(s) were added to refs/heads/master by this push:
 new ce7c5a0  DISPATCH-1941: fix http1 parser to detect null characters
ce7c5a0 is described below

commit ce7c5a0cddb89fb32c80ebf7e3773d9a9e6ac973
Author: Kenneth Giusti 
AuthorDate: Mon Feb 8 13:25:35 2021 -0500

DISPATCH-1941: fix http1 parser to detect null characters
---
 src/adaptors/http1/http1_codec.c  | 18 ++
 src/adaptors/http1/http1_server.c |  4 ++--
 2 files changed, 16 insertions(+), 6 deletions(-)

diff --git a/src/adaptors/http1/http1_codec.c b/src/adaptors/http1/http1_codec.c
index 7669d26..a11f226 100644
--- a/src/adaptors/http1/http1_codec.c
+++ b/src/adaptors/http1/http1_codec.c
@@ -353,6 +353,8 @@ static void ensure_outgoing_capacity(struct encoder_t 
*encoder, size_t capacity)
 static void write_string(struct encoder_t *encoder, const char *string)
 {
 size_t needed = strlen(string);
+if (needed == 0) return;
+
 ensure_outgoing_capacity(encoder, needed);
 
 encoder->hrs->out_octets += needed;
@@ -492,6 +494,14 @@ static bool ensure_scratch_size(scratch_memory_t *b, 
size_t required)
 }
 
 
+// return true if octet in str
+static inline bool filter_str(const char *str, uint8_t octet)
+{
+const char *ptr = strchr(str, (int)((unsigned int)octet));
+return ptr && *ptr != 0;
+}
+
+
 // trims any optional whitespace characters at the start of 'line'
 // RFC7230 defines OWS as zero or more spaces or horizontal tabs
 //
@@ -538,7 +548,7 @@ static bool parse_token(qd_iterator_pointer_t *line, 
qd_iterator_pointer_t *toke
&& (('A' <= octet && octet <= 'Z') ||
('a' <= octet && octet <= 'z') ||
('0' <= octet && octet <= '9') ||
-   (strchr(TOKEN_EXTRA, octet {
+   (filter_str(TOKEN_EXTRA, octet {
 len++;
 }
 
@@ -1733,17 +1743,17 @@ const char *h1_codec_token_list_next(const char *start, 
size_t *len, const char
 
 if (!start) return 0;
 
-while (*start && strchr(SKIPME, *start))
+while (*start && filter_str(SKIPME, *start))
 ++start;
 
 if (!*start) return 0;
 
 const char *end = start;
-while (*end && !strchr(SKIPME, *end))
+while (*end && !filter_str(SKIPME, *end))
 ++end;
 
 *len = end - start;
-while (*end && strchr(SKIPME, *end))
+while (*end && filter_str(SKIPME, *end))
 ++end;
 
 *next = end;
diff --git a/src/adaptors/http1/http1_server.c 
b/src/adaptors/http1/http1_server.c
index 61a0634..3f46e44 100644
--- a/src/adaptors/http1/http1_server.c
+++ b/src/adaptors/http1/http1_server.c
@@ -1247,7 +1247,7 @@ static uint64_t _send_request_headers(_server_request_t 
*hreq, qd_message_t *msg
 
 method_str = (char*) qd_iterator_copy(method_iter);
 qd_iterator_free(method_iter);
-if (!method_str) {
+if (!method_str || *method_str == 0) {
 return PN_REJECTED;
 }
 
@@ -1267,7 +1267,7 @@ static uint64_t _send_request_headers(_server_request_t 
*hreq, qd_message_t *msg
 
 qd_parsed_field_t *ref = qd_parse_value_by_key(app_props, 
TARGET_HEADER_KEY);
 target_str = (char*) qd_iterator_copy(qd_parse_raw(ref));
-if (!target_str) {
+if (!target_str || *target_str == 0) {
 outcome = PN_REJECTED;
 goto exit;
 }


-
To unsubscribe, e-mail: commits-unsubscr...@qpid.apache.org
For additional commands, e-mail: commits-h...@qpid.apache.org



[qpid-dispatch] branch master updated: DISPATCH-1948: fix alignment issues in alloc_pool.c

2021-02-12 Thread kgiusti
This is an automated email from the ASF dual-hosted git repository.

kgiusti pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/qpid-dispatch.git


The following commit(s) were added to refs/heads/master by this push:
 new 63f1b21  DISPATCH-1948: fix alignment issues in alloc_pool.c
63f1b21 is described below

commit 63f1b21d10d93b34be787aa2c1accd4d2aaa3a5a
Author: Kenneth Giusti 
AuthorDate: Tue Feb 2 16:52:51 2021 -0500

DISPATCH-1948: fix alignment issues in alloc_pool.c

This closes #1015
---
 src/alloc_pool.c | 10 +++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/src/alloc_pool.c b/src/alloc_pool.c
index 0feb20e..284630e 100644
--- a/src/alloc_pool.c
+++ b/src/alloc_pool.c
@@ -348,7 +348,8 @@ void *qd_alloc(qd_alloc_type_desc_t *desc, qd_alloc_pool_t 
**tpool)
 DEQ_INSERT_TAIL(qtype->allocated, item);
 sys_mutex_unlock(desc->lock);
 item->header = PATTERN_FRONT;
-*((uint32_t*) ((char*) [1] + desc->total_size))= PATTERN_BACK;
+const uint32_t pb = PATTERN_BACK;
+memcpy((char*) [1] + desc->total_size, , sizeof(pb));
 QD_MEMORY_FILL([1], QD_MEMORY_INIT, desc->total_size);
 #endif
 return [1];
@@ -414,7 +415,8 @@ void *qd_alloc(qd_alloc_type_desc_t *desc, qd_alloc_pool_t 
**tpool)
 DEQ_INSERT_TAIL(qtype->allocated, item);
 sys_mutex_unlock(desc->lock);
 item->header = PATTERN_FRONT;
-*((uint32_t*) ((char*) [1] + desc->total_size))= PATTERN_BACK;
+const uint32_t pb = PATTERN_BACK;
+memcpy((char*) [1] + desc->total_size, , sizeof(pb));
 QD_MEMORY_FILL([1], QD_MEMORY_INIT, desc->total_size);
 #endif
 return [1];
@@ -434,7 +436,9 @@ void qd_dealloc(qd_alloc_type_desc_t *desc, qd_alloc_pool_t 
**tpool, char *p)
 assert (desc->header  == PATTERN_FRONT);
 assert (desc->trailer == PATTERN_BACK);
 assert (item->header  == PATTERN_FRONT);
-assert (*((uint32_t*) (p + desc->total_size)) == PATTERN_BACK);
+const uint32_t pb = PATTERN_BACK;
+(void)pb;  // prevent unused warning
+assert (memcmp(p + desc->total_size, , sizeof(pb)) == 0);
 assert (item->desc == desc);  // Check for double-free
 qd_alloc_type_t *qtype = (qd_alloc_type_t*) desc->debug;
 sys_mutex_lock(desc->lock);


-
To unsubscribe, e-mail: commits-unsubscr...@qpid.apache.org
For additional commands, e-mail: commits-h...@qpid.apache.org



[qpid-proton] 02/02: PROTON-2334: c-fdlimit-tests fix for libuv immediate close connection drain behaviour for EMFILE accept() error

2021-02-12 Thread cliffjansen
This is an automated email from the ASF dual-hosted git repository.

cliffjansen pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/qpid-proton.git

commit 039c1fef0954491292c0fd171f22abc63fc541c5
Author: Cliff Jansen 
AuthorDate: Fri Feb 12 10:02:43 2021 -0800

PROTON-2334: c-fdlimit-tests fix for libuv immediate close connection drain 
behaviour for EMFILE accept() error
---
 c/tests/fdlimit.py | 31 ---
 1 file changed, 16 insertions(+), 15 deletions(-)

diff --git a/c/tests/fdlimit.py b/c/tests/fdlimit.py
index 8ef60ac..ae750ef 100644
--- a/c/tests/fdlimit.py
+++ b/c/tests/fdlimit.py
@@ -64,25 +64,26 @@ class FdLimitTest(unittest.TestCase):
 #  PN_TRANSPORT_CLOSED: amqp:connection:framing-error: connection 
aborted
 #  PN_TRANSPORT_CLOSED: proton:io: Connection reset by peer - 
disconnected :5672 (connection aborted)
 for i in range(fdlimit):
-receiver = test_subprocess.Popen(["receive", "", b.port, 
str(i)], stdout=self.devnull)
+receiver = subprocess.Popen(["receive", "", b.port, str(i)], 
stdout=self.devnull, stderr=subprocess.STDOUT)
 receivers.append(receiver)
 # Allow these subprocesses time to establish ahead of the upcoming 
test sender.
 time.sleep(1)
 
-# All FDs are now in use, send attempt will (with present 
implementation) hang
-with test_subprocess.Popen(["send", "", b.port, "x"],
-   stdout=self.devnull, 
stderr=subprocess.STDOUT) as sender:
-time.sleep(1)  # polling for None immediately would always 
succeed, regardless whether send hangs or not
-self.assertIsNone(sender.poll())
-
-# Kill receivers to free up FDs
-for r in receivers:
-r.kill()
-for r in receivers:
-r.wait()
-
-# Sender now succeeded and exited
-self.assertEqual(sender.wait(), 0)
+# All FDs are now in use, new send should not succeed.  May fail 
by hanging (epoll) or by
+# immediate failure (libuv). But poll() should never be 0.
+sender = subprocess.Popen(["send", "", b.port, "x"],
+   stdout=self.devnull, 
stderr=subprocess.STDOUT)
+time.sleep(1)  # polling for None immediately would always 
succeed, regardless whether send hangs or not
+self.assertNotEqual(sender.poll(), 0)
+
+# Kill receivers to free up FDs
+for r in receivers:
+r.kill()
+for r in receivers:
+r.wait()
+
+# Sender completes on its own
+sender.wait()
 
 # Additional send/receive should succeed now
 self.assertIn("10 messages sent", test_subprocess.check_output(


-
To unsubscribe, e-mail: commits-unsubscr...@qpid.apache.org
For additional commands, e-mail: commits-h...@qpid.apache.org



[qpid-proton] branch master updated (e4f3c34 -> 039c1fe)

2021-02-12 Thread cliffjansen
This is an automated email from the ASF dual-hosted git repository.

cliffjansen pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/qpid-proton.git.


from e4f3c34  NO-JIRA Add two forgotten test files to the project (#296)
 new 09dfeea  PROTON-2334: threaderciser test - simultaneous connect and 
pn_proactor_disconnect()
 new 039c1fe  PROTON-2334: c-fdlimit-tests fix for libuv immediate close 
connection drain behaviour for EMFILE accept() error

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 c/src/proactor/libuv.c |  2 +-
 c/tests/fdlimit.py | 31 ---
 2 files changed, 17 insertions(+), 16 deletions(-)


-
To unsubscribe, e-mail: commits-unsubscr...@qpid.apache.org
For additional commands, e-mail: commits-h...@qpid.apache.org



[qpid-proton] 01/02: PROTON-2334: threaderciser test - simultaneous connect and pn_proactor_disconnect()

2021-02-12 Thread cliffjansen
This is an automated email from the ASF dual-hosted git repository.

cliffjansen pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/qpid-proton.git

commit 09dfeea5db115a99217dbc64900db8f2496e2787
Author: Cliff Jansen 
AuthorDate: Fri Feb 12 08:33:53 2021 -0800

PROTON-2334: threaderciser test - simultaneous connect and 
pn_proactor_disconnect()
---
 c/src/proactor/libuv.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/c/src/proactor/libuv.c b/c/src/proactor/libuv.c
index fa51cc4..31f1e7c 100644
--- a/c/src/proactor/libuv.c
+++ b/c/src/proactor/libuv.c
@@ -654,7 +654,6 @@ static int lsocket(pn_listener_t *l, struct addrinfo *ai) {
 
 /* Listen on all available addresses */
 static void leader_listen_lh(pn_listener_t *l) {
-  add_active(l->work.proactor);
   int err = leader_resolve(l->work.proactor, >addr, true);
   if (!err) {
 /* Allocate enough space for the pn_netaddr_t addresses */
@@ -1170,6 +1169,7 @@ void pn_proactor_listen(pn_proactor_t *p, pn_listener_t 
*l, const char *addr, in
   work_init(>work, p, T_LISTENER);
   parse_addr(>addr, addr);
   l->backlog = backlog;
+  add_active(l->work.proactor);  /* Owned by proactor.  Track it for 
PN_PROACTOR_INACTIVE. */;
   work_start(>work);
 }
 


-
To unsubscribe, e-mail: commits-unsubscr...@qpid.apache.org
For additional commands, e-mail: commits-h...@qpid.apache.org



[qpid-proton] 01/01: Update .travis.yml

2021-02-12 Thread jdanek
This is an automated email from the ASF dual-hosted git repository.

jdanek pushed a commit to branch jd_can_i_haz_clang11
in repository https://gitbox.apache.org/repos/asf/qpid-proton.git

commit 324bb3f48f0cc3898bb2f0a0ad95a5b78c0b8c4c
Author: Jiri Daněk 
AuthorDate: Fri Feb 12 17:28:43 2021 +0100

Update .travis.yml
---
 .travis.yml | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/.travis.yml b/.travis.yml
index cd3ae5d..d720d12 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -68,14 +68,14 @@ jobs:
 os: linux
 dist: focal
 before_install:
-- sudo apt-get install -y clang-10 llvm-10-dev
+- sudo apt-get install -y clang-11 llvm-11-dev
 env:
-- CC=clang-10
-- CXX=clang++-10
+- CC=clang-11
+- CXX=clang++-11
 - PYTHON=python3
 - QPID_PROTON_CMAKE_ARGS='-DRUNTIME_CHECK=asan -DENABLE_TOX_TEST=OFF 
-DTHREADERCISER=ON'
 # otherwise, on Travis ldd gives `libclang_rt.asan-x86_64.so => not found` 
and binaries don't work
-- LD_LIBRARY_PATH=/usr/lib/llvm-10/lib/clang/10.0.0/lib/linux/
+- LD_LIBRARY_PATH=/usr/lib/llvm-11/lib/clang/11.0.0/lib/linux/
   - name: gcc tsan
 os: linux
 dist: focal


-
To unsubscribe, e-mail: commits-unsubscr...@qpid.apache.org
For additional commands, e-mail: commits-h...@qpid.apache.org



[qpid-proton] branch jd_can_i_haz_clang11 created (now 324bb3f)

2021-02-12 Thread jdanek
This is an automated email from the ASF dual-hosted git repository.

jdanek pushed a change to branch jd_can_i_haz_clang11
in repository https://gitbox.apache.org/repos/asf/qpid-proton.git.


  at 324bb3f  Update .travis.yml

This branch includes the following new commits:

 new 324bb3f  Update .travis.yml

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



-
To unsubscribe, e-mail: commits-unsubscr...@qpid.apache.org
For additional commands, e-mail: commits-h...@qpid.apache.org



[qpid-dispatch] branch master updated: DISPATCH-1586 - Add allocator metrics (#696)

2021-02-12 Thread jdanek
This is an automated email from the ASF dual-hosted git repository.

jdanek pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/qpid-dispatch.git


The following commit(s) were added to refs/heads/master by this push:
 new 4a30f53  DISPATCH-1586 - Add allocator metrics (#696)
4a30f53 is described below

commit 4a30f537971d929c3ba63019acefd2997c4eb762
Author: Fernando Giorgetti 
AuthorDate: Fri Feb 12 09:17:06 2021 -0300

DISPATCH-1586 - Add allocator metrics (#696)
---
 src/http-libwebsockets.c | 140 +--
 1 file changed, 136 insertions(+), 4 deletions(-)

diff --git a/src/http-libwebsockets.c b/src/http-libwebsockets.c
index 9a2e803..66cf187 100644
--- a/src/http-libwebsockets.c
+++ b/src/http-libwebsockets.c
@@ -460,6 +460,11 @@ typedef struct metric_definition {
 int_metric value;
 } metric_definition;
 
+typedef struct allocator_metric_definition {
+const char* name;
+qd_alloc_stats_t *(*fn)(void);
+} allocator_metric_definition;
+
 static int stats_get_connections(qdr_global_stats_t *stats) { return 
stats->connections; }
 static int stats_get_links(qdr_global_stats_t *stats) { return stats->links; }
 static int stats_get_addrs(qdr_global_stats_t *stats) { return stats->addrs; }
@@ -483,6 +488,43 @@ static int stats_get_deliveries_stuck(qdr_global_stats_t 
*stats) { return stats-
 static int stats_get_links_blocked(qdr_global_stats_t *stats) { return 
stats->links_blocked; }
 static int stats_get_deliveries_redirected_to_fallback(qdr_global_stats_t 
*stats) { return stats->deliveries_redirected_to_fallback; }
 
+qd_alloc_stats_t *alloc_stats_qd_bitmask_t(void);
+qd_alloc_stats_t *alloc_stats_qd_buffer_t(void);
+qd_alloc_stats_t *alloc_stats_qd_composed_field_t(void);
+qd_alloc_stats_t *alloc_stats_qd_composite_t(void);
+qd_alloc_stats_t *alloc_stats_qd_connection_t(void);
+qd_alloc_stats_t *alloc_stats_qd_hash_handle_t(void);
+qd_alloc_stats_t *alloc_stats_qd_hash_item_t(void);
+qd_alloc_stats_t *alloc_stats_qd_iterator_t(void);
+qd_alloc_stats_t *alloc_stats_qd_link_ref_t(void);
+qd_alloc_stats_t *alloc_stats_qd_link_t(void);
+qd_alloc_stats_t *alloc_stats_qd_listener_t(void);
+qd_alloc_stats_t *alloc_stats_qd_log_entry_t(void);
+qd_alloc_stats_t *alloc_stats_qd_management_context_t(void);
+qd_alloc_stats_t *alloc_stats_qd_message_content_t(void);
+qd_alloc_stats_t *alloc_stats_qd_message_t(void);
+qd_alloc_stats_t *alloc_stats_qd_node_t(void);
+qd_alloc_stats_t *alloc_stats_qd_parse_node_t(void);
+qd_alloc_stats_t *alloc_stats_qd_parsed_field_t(void);
+qd_alloc_stats_t *alloc_stats_qd_timer_t(void);
+qd_alloc_stats_t *alloc_stats_qdr_action_t(void);
+qd_alloc_stats_t *alloc_stats_qdr_address_config_t(void);
+qd_alloc_stats_t *alloc_stats_qdr_address_t(void);
+qd_alloc_stats_t *alloc_stats_qdr_connection_info_t(void);
+qd_alloc_stats_t *alloc_stats_qdr_connection_t(void);
+qd_alloc_stats_t *alloc_stats_qdr_connection_work_t(void);
+qd_alloc_stats_t *alloc_stats_qdr_core_timer_t(void);
+qd_alloc_stats_t *alloc_stats_qdr_delivery_cleanup_t(void);
+qd_alloc_stats_t *alloc_stats_qdr_delivery_ref_t(void);
+qd_alloc_stats_t *alloc_stats_qdr_delivery_t(void);
+qd_alloc_stats_t *alloc_stats_qdr_field_t(void);
+qd_alloc_stats_t *alloc_stats_qdr_general_work_t(void);
+qd_alloc_stats_t *alloc_stats_qdr_link_ref_t(void);
+qd_alloc_stats_t *alloc_stats_qdr_link_t(void);
+qd_alloc_stats_t *alloc_stats_qdr_link_work_t(void);
+qd_alloc_stats_t *alloc_stats_qdr_query_t(void);
+qd_alloc_stats_t *alloc_stats_qdr_terminus_t(void);
+
 static struct metric_definition metrics[] = {
 {"qdr_connections_total", "gauge", stats_get_connections},
 {"qdr_links_total", "gauge", stats_get_links},
@@ -509,9 +551,60 @@ static struct metric_definition metrics[] = {
 };
 static size_t metrics_length = sizeof(metrics)/sizeof(metrics[0]);
 
+static struct allocator_metric_definition allocator_metrics[] = {
+{"qdr_allocator_qd_bitmask_t", alloc_stats_qd_bitmask_t},
+{"qdr_allocator_qd_buffer_t", alloc_stats_qd_buffer_t},
+{"qdr_allocator_qd_composed_field_t", alloc_stats_qd_composed_field_t},
+{"qdr_allocator_qd_composite_t", alloc_stats_qd_composite_t},
+{"qdr_allocator_qd_connection_t", alloc_stats_qd_connection_t},
+{"qdr_allocator_qd_hash_handle_t", alloc_stats_qd_hash_handle_t},
+{"qdr_allocator_qd_hash_item_t", alloc_stats_qd_hash_item_t},
+{"qdr_allocator_qd_iterator_t", alloc_stats_qd_iterator_t},
+{"qdr_allocator_qd_link_ref_t", alloc_stats_qd_link_ref_t},
+{"qdr_allocator_qd_link_t", alloc_stats_qd_link_t},
+{"qdr_allocator_qd_listener_t", alloc_stats_qd_listener_t},
+{"qdr_allocator_qd_log_entry_t", alloc_stats_qd_log_entry_t},
+{"qdr_allocator_qd_management_context_t", 
alloc_stats_qd_management_context_t},
+{"qdr_allocator_qd_message_content_t", 
alloc_stats_qd_message_content_t},
+