qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From acon...@apache.org
Subject qpid-dispatch git commit: DISPATCH-390: Add missing lock around policy counts
Date Fri, 12 May 2017 18:56:39 GMT
Repository: qpid-dispatch
Updated Branches:
  refs/heads/master 22b11be60 -> bc50c1270


DISPATCH-390: Add missing lock around policy counts


Project: http://git-wip-us.apache.org/repos/asf/qpid-dispatch/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-dispatch/commit/bc50c127
Tree: http://git-wip-us.apache.org/repos/asf/qpid-dispatch/tree/bc50c127
Diff: http://git-wip-us.apache.org/repos/asf/qpid-dispatch/diff/bc50c127

Branch: refs/heads/master
Commit: bc50c1270848b973dfb50392c90a300a188ac102
Parents: 22b11be
Author: Alan Conway <aconway@redhat.com>
Authored: Fri May 12 14:56:06 2017 -0400
Committer: Alan Conway <aconway@redhat.com>
Committed: Fri May 12 14:56:06 2017 -0400

----------------------------------------------------------------------
 src/server.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/bc50c127/src/server.c
----------------------------------------------------------------------
diff --git a/src/server.c b/src/server.c
index d89912e..f3d400d 100644
--- a/src/server.c
+++ b/src/server.c
@@ -594,10 +594,10 @@ static void on_connection_bound(qd_server_t *server, pn_event_t *e)
{
         pn_transport_set_server(tport);
         set_rhost_port(ctx);
 
-        if (qd_policy_socket_accept(server->qd->policy, ctx->rhost))
-        {
-            ctx->policy_counted = true;
-        } else {
+        sys_mutex_lock(server->lock); /* Policy check is not thread safe */
+        ctx->policy_counted = qd_policy_socket_accept(server->qd->policy, ctx->rhost);
+        sys_mutex_unlock(server->lock);
+        if (!ctx->policy_counted) {
             pn_transport_close_tail(tport);
             pn_transport_close_head(tport);
             return;
@@ -719,11 +719,11 @@ void qd_connection_free(qd_connection_t *ctx)
     }
 
     // If counted for policy enforcement, notify it has closed
-    sys_mutex_lock(qd_server->lock);
     if (ctx->policy_counted) {
+        sys_mutex_lock(qd_server->lock); /* Policy check is not thread safe */
         qd_policy_socket_close(qd_server->qd->policy, ctx);
+        sys_mutex_unlock(qd_server->lock);
     }
-    sys_mutex_unlock(qd_server->lock);
 
     invoke_deferred_calls(ctx, true);  // Discard any pending deferred calls
     if (ctx->deferred_call_lock)
@@ -949,7 +949,7 @@ static void setup_ssl_sasl_and_open(qd_connection_t *ctx)
 
 static void try_open_cb(void *context) {
     qd_connector_t *ct = (qd_connector_t*) context;
-    sys_mutex_lock(ct->lock);
+    sys_mutex_lock(ct->lock);   /* TODO aconway 2017-05-09: this lock looks too big */
     try_open_lh(ct);
     sys_mutex_unlock(ct->lock);
 }


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


Mime
View raw message