You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by gm...@apache.org on 2019/09/16 14:08:40 UTC

[qpid-dispatch] branch master updated: DISPATCH-1417 - Introduced a lock around the core thread connection activation to prevent premature freeing of qd_connection_t object. This closes #565.

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

gmurthy 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 2b95158  DISPATCH-1417 - Introduced a lock around the core thread connection activation to prevent premature freeing of qd_connection_t object. This closes #565.
2b95158 is described below

commit 2b95158826f32ca9f43e15c891602ec0acc63c18
Author: Ganesh Murthy <gm...@apache.org>
AuthorDate: Wed Sep 11 23:02:44 2019 -0400

    DISPATCH-1417 - Introduced a lock around the core thread connection activation to prevent premature freeing of qd_connection_t object. This closes #565.
---
 src/dispatch_private.h               |  2 ++
 src/router_core/router_core_thread.c |  3 +++
 src/server.c                         | 10 ++++++++++
 3 files changed, 15 insertions(+)

diff --git a/src/dispatch_private.h b/src/dispatch_private.h
index a01db9b..f658fb2 100644
--- a/src/dispatch_private.h
+++ b/src/dispatch_private.h
@@ -126,4 +126,6 @@ void qd_dispatch_set_agent(qd_dispatch_t *qd, void *agent);
 
 qdr_core_t* qd_dispatch_router_core(qd_dispatch_t *qd);
 
+sys_mutex_t *qd_server_get_activation_lock(qd_server_t *server);
+
 #endif
diff --git a/src/router_core/router_core_thread.c b/src/router_core/router_core_thread.c
index c82d3f2..8a4682c 100644
--- a/src/router_core/router_core_thread.c
+++ b/src/router_core/router_core_thread.c
@@ -19,6 +19,7 @@
 
 #include "router_core_private.h"
 #include "module.h"
+#include "dispatch_private.h"
 
 /**
  * Creates a thread that is dedicated to managing and using the routing table.
@@ -62,7 +63,9 @@ static void qdr_activate_connections_CT(qdr_core_t *core)
     while (conn) {
         DEQ_REMOVE_HEAD_N(ACTIVATE, core->connections_to_activate);
         conn->in_activate_list = false;
+        sys_mutex_lock(qd_server_get_activation_lock(core->qd->server));
         qd_server_activate((qd_connection_t*) qdr_connection_get_context(conn));
+        sys_mutex_unlock(qd_server_get_activation_lock(core->qd->server));
         conn = DEQ_HEAD(core->connections_to_activate);
     }
 }
diff --git a/src/server.c b/src/server.c
index e8bfd9a..a6c2548 100644
--- a/src/server.c
+++ b/src/server.c
@@ -68,6 +68,7 @@ struct qd_server_t {
     uint64_t                  next_connection_id;
     void                     *py_displayname_obj;
     qd_http_server_t         *http;
+    sys_mutex_t              *conn_activation_lock;
 };
 
 #define HEARTBEAT_INTERVAL 1000
@@ -843,7 +844,9 @@ static void qd_connection_free(qd_connection_t *ctx)
     if (ctx->timer) qd_timer_free(ctx->timer);
     free(ctx->name);
     free(ctx->role);
+    sys_mutex_lock(qd_server->conn_activation_lock);
     free_qd_connection_t(ctx);
+    sys_mutex_unlock(qd_server->conn_activation_lock);
 
     /* Note: pn_conn is freed by the proactor */
 }
@@ -1216,6 +1219,7 @@ qd_server_t *qd_server(qd_dispatch_t *qd, int thread_count, const char *containe
     qd_server->container        = 0;
     qd_server->start_context    = 0;
     qd_server->lock             = sys_mutex();
+    qd_server->conn_activation_lock = sys_mutex();
     qd_server->cond             = sys_cond();
     DEQ_INIT(qd_server->conn_list);
 
@@ -1252,6 +1256,7 @@ void qd_server_free(qd_server_t *qd_server)
     }
     qd_timer_finalize();
     sys_mutex_free(qd_server->lock);
+    sys_mutex_free(qd_server->conn_activation_lock);
     sys_cond_free(qd_server->cond);
     Py_XDECREF((PyObject *)qd_server->py_displayname_obj);
     free(qd_server);
@@ -1547,3 +1552,8 @@ void qd_connection_handle(qd_connection_t *c, pn_event_t *e) {
 bool qd_connection_strip_annotations_in(const qd_connection_t *c) {
     return c->strip_annotations_in;
 }
+
+sys_mutex_t *qd_server_get_activation_lock(qd_server_t * server)
+{
+    return server->conn_activation_lock;
+}


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