This is an automated email from the ASF dual-hosted git repository.

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


The following commit(s) were added to refs/heads/main by this push:
     new 18ac554  DISPATCH-2099: flush stream_data before releasing deliveries
18ac554 is described below

commit 18ac55448fea287339a6cc4bdbfd076ae9b6dd46
Author: Kenneth Giusti <kgiu...@apache.org>
AuthorDate: Tue May 4 13:23:18 2021 -0400

    DISPATCH-2099: flush stream_data before releasing deliveries
    
    This closes #1183
---
 src/adaptors/tcp_adaptor.c | 8 +++++---
 src/message.c              | 5 +++++
 2 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/src/adaptors/tcp_adaptor.c b/src/adaptors/tcp_adaptor.c
index e75f1ee..92b9774 100644
--- a/src/adaptors/tcp_adaptor.c
+++ b/src/adaptors/tcp_adaptor.c
@@ -437,7 +437,7 @@ static void flush_outgoing_buffs(qdr_tcp_connection_t *conn)
 
     // Flush in-progress stream data object
     if (conn->outgoing_stream_data) {
-        free_qd_message_stream_data_t(conn->outgoing_stream_data);
+        qd_message_stream_data_release(conn->outgoing_stream_data);
         conn->outgoing_stream_data = 0;
     }
 }
@@ -459,6 +459,10 @@ static void free_qdr_tcp_connection(qdr_tcp_connection_t* 
tc)
 
 static void handle_disconnected(qdr_tcp_connection_t* conn)
 {
+    // release all message buffers since the deliveries will free the message
+    // once we decref them.
+    flush_outgoing_buffs(conn);
+
     if (conn->instream) {
         qd_log(tcp_adaptor->log_source, QD_LOG_DEBUG,
                "[C%"PRIu64"][L%"PRIu64"] handle_disconnected - close instream",
@@ -494,8 +498,6 @@ static void handle_disconnected(qdr_tcp_connection_t* conn)
         qdr_delivery_decref(tcp_adaptor->core, conn->initial_delivery, 
"tcp-adaptor.handle_disconnected - initial_delivery");
         conn->initial_delivery = 0;
     }
-    flush_outgoing_buffs(conn);
-
 
     //need to free on core thread to avoid deleting while in use by management 
agent
     qdr_action_t *action = qdr_action(qdr_del_tcp_connection_CT, 
"delete_tcp_connection");
diff --git a/src/message.c b/src/message.c
index ebb3f77..25aa495 100644
--- a/src/message.c
+++ b/src/message.c
@@ -1041,6 +1041,11 @@ void qd_message_free(qd_message_t *in_msg)
         //
         LOCK(content->lock);
 
+        // DISPATCH-2099: ensure all outstanding stream_data items associated
+        // with this message have been returned since the underlying buffers
+        // may be released
+        assert(DEQ_IS_EMPTY(msg->stream_data_list));
+
         const bool was_blocked = !qd_message_Q2_holdoff_should_unblock(in_msg);
         qd_buffer_t *buf = msg->cursor.buffer;
         while (buf) {

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

Reply via email to