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

chug 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 e90df06  DISPATCH-2195: Fix SERVER-PYTHON lock inversion
e90df06 is described below

commit e90df062b08fb572e5d865c69feb0f20dd202abe
Author: Chuck Rolke <c...@apache.org>
AuthorDate: Fri Jul 23 13:55:34 2021 -0400

    DISPATCH-2195: Fix SERVER-PYTHON lock inversion
    
     * Release server lock before calling qd_policy_socket_close instead
       of after.
    
     * As a general rule the PYTHON lock must not be taken while holding
       any other lock.
    
     * Make a copy of the global while holding the lock and then log the
       value of the copy.
    
    This closes #1295
---
 src/policy.c | 3 ++-
 src/server.c | 2 +-
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/src/policy.c b/src/policy.c
index 07f4fae..2255806 100644
--- a/src/policy.c
+++ b/src/policy.c
@@ -289,6 +289,7 @@ void qd_policy_socket_close(qd_policy_t *policy, const 
qd_connection_t *conn)
 {
     sys_mutex_lock(stats_lock);
     n_connections--;
+    uint64_t nc = n_connections;
     assert (n_connections >= 0);
     sys_mutex_unlock(stats_lock);
     if (policy->enableVhostPolicy) {
@@ -319,7 +320,7 @@ void qd_policy_socket_close(qd_policy_t *policy, const 
qd_connection_t *conn)
            "[C%"PRIu64"] Connection '%s' closed with resources n_sessions=%d, 
n_senders=%d, n_receivers=%d, "
            "sessions_denied=%"PRIu64", senders_denied=%"PRIu64", 
receivers_denied=%"PRIu64", max_message_size_denied:%"PRIu64", nConnections= 
%"PRIu64".",
             conn->connection_id, hostname, conn->n_sessions, conn->n_senders, 
conn->n_receivers,
-            qpdc->sessionDenied, qpdc->senderDenied, qpdc->receiverDenied, 
qpdc->maxSizeMessagesDenied, n_connections);
+            qpdc->sessionDenied, qpdc->senderDenied, qpdc->receiverDenied, 
qpdc->maxSizeMessagesDenied, nc);
     }
 }
 
diff --git a/src/server.c b/src/server.c
index 82ad1f3..75527b2 100644
--- a/src/server.c
+++ b/src/server.c
@@ -931,12 +931,12 @@ static void qd_connection_free(qd_connection_t *qd_conn)
 
     sys_mutex_lock(qd_server->lock);
     DEQ_REMOVE(qd_server->conn_list, qd_conn);
+    sys_mutex_unlock(qd_server->lock);
 
     // If counted for policy enforcement, notify it has closed
     if (qd_conn->policy_counted) {
         qd_policy_socket_close(qd_server->qd->policy, qd_conn);
     }
-    sys_mutex_unlock(qd_server->lock);
 
     invoke_deferred_calls(qd_conn, true);  // Discard any pending deferred 
calls
     sys_mutex_free(qd_conn->deferred_call_lock);

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

Reply via email to