You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by tr...@apache.org on 2021/01/18 21:09:51 UTC
[qpid-dispatch] 01/02: DISPATCH-1912 - Fixed bugs identified by the
thread sanitizer.
This is an automated email from the ASF dual-hosted git repository.
tross pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/qpid-dispatch.git
commit ac2c1472c0995a6e96ac031eb70bed5aa7531ff0
Author: Ted Ross <tr...@apache.org>
AuthorDate: Fri Jan 15 13:29:21 2021 -0500
DISPATCH-1912 - Fixed bugs identified by the thread sanitizer.
---
include/qpid/dispatch/buffer.h | 4 ++++
src/adaptors/tcp_adaptor.c | 2 --
src/buffer.c | 3 ---
src/router_core/connections.c | 6 ++++++
src/router_core/delivery.c | 11 +++++++----
src/router_core/delivery.h | 2 +-
src/router_core/forwarder.c | 2 +-
7 files changed, 19 insertions(+), 11 deletions(-)
diff --git a/include/qpid/dispatch/buffer.h b/include/qpid/dispatch/buffer.h
index 230eebc..e23f690 100644
--- a/include/qpid/dispatch/buffer.h
+++ b/include/qpid/dispatch/buffer.h
@@ -44,6 +44,10 @@ struct qd_buffer_t {
/**
* Set the initial buffer capacity to be allocated by future calls to qp_buffer.
+ *
+ * NOTICE: This function is provided for testing purposes only. It should not be invoked
+ * in the production code. If this function is called after the first buffer has been allocated,
+ * the software WILL BE unstable and WILL crash.
*/
void qd_buffer_set_size(size_t size);
diff --git a/src/adaptors/tcp_adaptor.c b/src/adaptors/tcp_adaptor.c
index 994f1b4..7ff4e50 100644
--- a/src/adaptors/tcp_adaptor.c
+++ b/src/adaptors/tcp_adaptor.c
@@ -673,8 +673,6 @@ static void qdr_tcp_open_server_side_connection(qdr_tcp_connection_t* tc)
if (!!tc->initial_delivery) {
qd_log(tcp_adaptor->log_source, QD_LOG_DEBUG, DLV_FMT" initial_delivery ownership passed to "DLV_FMT,
DLV_ARGS(tc->initial_delivery), tc->outgoing->conn_id, tc->outgoing->identity, tc->initial_delivery->delivery_id);
- tc->initial_delivery->conn_id = tc->outgoing->conn_id;
- tc->initial_delivery->link_id = tc->outgoing->identity;
qdr_delivery_decref(tcp_adaptor->core, tc->initial_delivery, "tcp-adaptor - passing initial_delivery into new link");
tc->initial_delivery = 0;
}
diff --git a/src/buffer.c b/src/buffer.c
index 94315b2..d3e788e 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -25,7 +25,6 @@
size_t BUFFER_SIZE = 512;
-static int size_locked = 0;
ALLOC_DECLARE(qd_buffer_t);
ALLOC_DEFINE_CONFIG(qd_buffer_t, sizeof(qd_buffer_t), &BUFFER_SIZE, 0);
@@ -33,14 +32,12 @@ ALLOC_DEFINE_CONFIG(qd_buffer_t, sizeof(qd_buffer_t), &BUFFER_SIZE, 0);
void qd_buffer_set_size(size_t size)
{
- assert(!size_locked);
BUFFER_SIZE = size;
}
qd_buffer_t *qd_buffer(void)
{
- size_locked = 1;
qd_buffer_t *buf = new_qd_buffer_t();
DEQ_ITEM_INIT(buf);
diff --git a/src/router_core/connections.c b/src/router_core/connections.c
index 2d833e1..6bba0d5 100644
--- a/src/router_core/connections.c
+++ b/src/router_core/connections.c
@@ -1646,6 +1646,12 @@ static void qdr_link_process_initial_delivery_CT(qdr_core_t *core, qdr_link_t *l
qdr_forward_deliver_CT(core, link, dlv);
//
+ // Adjust the delivery's identity
+ //
+ dlv->conn_id = link->conn->identity;
+ dlv->link_id = link->identity;
+
+ //
// Adjust the delivery's reference count
//
assert(ref_delta <= 0);
diff --git a/src/router_core/delivery.c b/src/router_core/delivery.c
index 37632b2..01bba64 100644
--- a/src/router_core/delivery.c
+++ b/src/router_core/delivery.c
@@ -108,8 +108,6 @@ uint64_t qdr_delivery_disposition(const qdr_delivery_t *delivery)
void qdr_delivery_incref(qdr_delivery_t *delivery, const char *label)
{
uint32_t rc = sys_atomic_inc(&delivery->ref_count);
- assert(rc > 0 || !delivery->ref_counted);
- delivery->ref_counted = true;
qdr_link_t *link = qdr_delivery_link(delivery);
if (link)
qd_log(link->core->log, QD_LOG_DEBUG, DLV_FMT" Delivery incref: rc:%"PRIu32" %s",
@@ -138,11 +136,16 @@ void qdr_delivery_set_presettled(qdr_delivery_t *delivery)
void qdr_delivery_decref(qdr_core_t *core, qdr_delivery_t *delivery, const char *label)
{
+ char log_prefix[DLV_ARGS_MAX];
+ if (qd_log_enabled(core->log, QD_LOG_DEBUG)) {
+ snprintf(log_prefix, DLV_ARGS_MAX, DLV_FMT, DLV_ARGS(delivery));
+ }
+
uint32_t ref_count = sys_atomic_dec(&delivery->ref_count);
assert(ref_count > 0);
- qd_log(core->log, QD_LOG_DEBUG, DLV_FMT" Delivery decref: rc:%"PRIu32" %s",
- DLV_ARGS(delivery), ref_count - 1, label);
+ qd_log(core->log, QD_LOG_DEBUG, "%s Delivery decref: rc:%"PRIu32" %s",
+ log_prefix, ref_count - 1, label);
if (ref_count == 1) {
// The ref_count was 1 and now it is zero. We are deleting the last ref.
diff --git a/src/router_core/delivery.h b/src/router_core/delivery.h
index bbcccc2..7f9ae7d 100644
--- a/src/router_core/delivery.h
+++ b/src/router_core/delivery.h
@@ -36,7 +36,6 @@ struct qdr_delivery_t {
DEQ_LINKS(qdr_delivery_t);
void *context;
sys_atomic_t ref_count;
- bool ref_counted; /// Used to protect against ref count going 1 -> 0 -> 1
qdr_link_t_sp link_sp; /// Safe pointer to the link
qdr_delivery_t *peer; /// Use this peer if the delivery has one and only one peer.
qdr_delivery_ref_t *next_peer_ref;
@@ -80,6 +79,7 @@ static inline uint32_t next_delivery_id() { return sys_atomic_inc(&global_delive
// Common log line prefix
#define DLV_FMT "[C%"PRIu64"][L%"PRIu64"][D%"PRIu32"]"
#define DLV_ARGS(dlv) dlv->conn_id, dlv->link_id, dlv->delivery_id
+#define DLV_ARGS_MAX 75
///////////////////////////////////////////////////////////////////////////////
// Delivery API
diff --git a/src/router_core/forwarder.c b/src/router_core/forwarder.c
index 43b2943..be704ea 100644
--- a/src/router_core/forwarder.c
+++ b/src/router_core/forwarder.c
@@ -348,7 +348,7 @@ void qdr_forward_on_message(qdr_core_t *core, qdr_general_work_t *work)
qdr_action_enqueue(core, action);
// Transfer the delivery reference from work protection to action protection
} else
- qdr_delivery_decref_CT(core, work->delivery, "qdr_forward_on_message - remove from general work");
+ qdr_delivery_decref(core, work->delivery, "qdr_forward_on_message - remove from general work");
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org