This is an automated email from the ASF dual-hosted git repository. kgiusti pushed a commit to branch 1.18.x in repository https://gitbox.apache.org/repos/asf/qpid-dispatch.git
commit 99be9d4f56bc8b486e82079aa53022d98977a7ad Author: Kenneth Giusti <kgiu...@apache.org> AuthorDate: Mon Nov 15 19:31:53 2021 -0500 DISPATCH-2289: postpone data stream free until after disconnect. The TCP adaptor should not release any outstanding data stream elements until after the connection disconnect event. Otherwise it is possible proton is still holding a reference to the data stream. This closes #1439 (cherry picked from commit f7fdaf12a1bcbaa660f6ebc10d066542a3a30fca) --- src/adaptors/tcp_adaptor.c | 30 ++++++++++++------------------ 1 file changed, 12 insertions(+), 18 deletions(-) diff --git a/src/adaptors/tcp_adaptor.c b/src/adaptors/tcp_adaptor.c index fe89fb2..214586b 100644 --- a/src/adaptors/tcp_adaptor.c +++ b/src/adaptors/tcp_adaptor.c @@ -427,19 +427,6 @@ static int handle_incoming(qdr_tcp_connection_t *conn, const char *msg) } -static void flush_outgoing_buffs(qdr_tcp_connection_t *conn) -{ - // Free any remaining stream data objects - if (conn->outgoing_stream_data) { - qd_message_stream_data_release_up_to(conn->outgoing_stream_data); - conn->outgoing_stream_data = 0; - } else if (conn->previous_stream_data) { - qd_message_stream_data_release_up_to(conn->previous_stream_data); - conn->previous_stream_data = 0; - } -} - - static void free_qdr_tcp_connection(qdr_tcp_connection_t* tc) { free(tc->reply_to); @@ -464,9 +451,18 @@ 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); + // release all referenced message buffers since the deliveries will free + // the message once we decref them. Note the order: outgoing_stream_data + // comes after previous_stream_data, so previous_stream_data is + // automagically freed when we release_up_to(outgoing_stream_data). + if (conn->outgoing_stream_data) { + qd_message_stream_data_release_up_to(conn->outgoing_stream_data); + conn->outgoing_stream_data = 0; + conn->previous_stream_data = 0; + } else if (conn->previous_stream_data) { + qd_message_stream_data_release_up_to(conn->previous_stream_data); + conn->previous_stream_data = 0; + } if (conn->instream) { qd_log(tcp_adaptor->log_source, QD_LOG_DEBUG, @@ -615,8 +611,6 @@ static void handle_outgoing(qdr_tcp_connection_t *conn) { if (conn->outstream) { if (IS_ATOMIC_FLAG_SET(&conn->raw_closed_write)) { - // flush outgoing buffers and free attached stream_data objects - flush_outgoing_buffs(conn); // give no more buffers to raw connection return; } --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@qpid.apache.org For additional commands, e-mail: commits-h...@qpid.apache.org