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/03/25 15:31:16 UTC

[qpid-dispatch] branch master updated: DISPATCH-1274 - This commit reverts 48e62a11e67cf3a37b5e1f9862d07a939101cdb4 and 077710c72a20f854e9fe0cbcd983ba68c4d72d10. This code caused a deadlock in the timer.

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 35a2cff  DISPATCH-1274 - This commit reverts 48e62a11e67cf3a37b5e1f9862d07a939101cdb4 and 077710c72a20f854e9fe0cbcd983ba68c4d72d10. This code caused a deadlock in the timer.
35a2cff is described below

commit 35a2cff60a515b080eba6fcf4e43672557cca1f1
Author: Ganesh Murthy <gm...@redhat.com>
AuthorDate: Mon Mar 25 11:06:08 2019 -0400

    DISPATCH-1274 - This commit reverts 48e62a11e67cf3a37b5e1f9862d07a939101cdb4 and 077710c72a20f854e9fe0cbcd983ba68c4d72d10. This code caused a deadlock in the timer.
---
 src/CMakeLists.txt      |  1 -
 src/immediate_private.h | 45 ---------------------------------------------
 src/server.c            | 23 +++++------------------
 src/server_private.h    |  1 -
 src/timer.c             | 20 +++-----------------
 src/timer_private.h     |  4 +---
 6 files changed, 9 insertions(+), 85 deletions(-)

diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 5f4f745..07ae846 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -51,7 +51,6 @@ set(qpid_dispatch_SOURCES
   entity_cache.c
   failoverlist.c
   hash.c
-  immediate.c
   iterator.c
   log.c
   message.c
diff --git a/src/immediate_private.h b/src/immediate_private.h
deleted file mode 100644
index cd8d11b..0000000
--- a/src/immediate_private.h
+++ /dev/null
@@ -1,45 +0,0 @@
-#ifndef __immediate_private_h__
-#define __immediate_private_h__ 1
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-
-#include <qpid/dispatch/dispatch.h>
-#include <qpid/dispatch/server.h>
-#include <stdint.h>
-
-/* Immediate actions - used by timer to optimize schedule(0) */
-
-void qd_immediate_initialize(void);
-void qd_immediate_finalize(void);
-void qd_immediate_visit(void);
-
-typedef struct qd_immediate_t qd_immediate_t;
-
-qd_immediate_t *qd_immediate(qd_dispatch_t *qd, void (*handler)(void*), void* context);
-
-/* Arm causes a call to handler(context) ASAP in a server thread. */
-void qd_immediate_arm(qd_immediate_t *);
-
-/* After disarm() returns, there will be no handler() call unless re-armed. */
-void qd_immediate_disarm(qd_immediate_t *);
-
-void qd_immediate_free(qd_immediate_t *);
-
-#endif
diff --git a/src/server.c b/src/server.c
index 8dc2fc1..e8bfd9a 100644
--- a/src/server.c
+++ b/src/server.c
@@ -38,7 +38,6 @@
 #include "entity.h"
 #include "entity_cache.h"
 #include "dispatch_private.h"
-#include "immediate_private.h"
 #include "policy.h"
 #include "server_private.h"
 #include "timer_private.h"
@@ -69,7 +68,6 @@ struct qd_server_t {
     uint64_t                  next_connection_id;
     void                     *py_displayname_obj;
     qd_http_server_t         *http;
-    bool                      stopping;
 };
 
 #define HEARTBEAT_INTERVAL 1000
@@ -906,16 +904,10 @@ static bool handle(qd_server_t *qd_server, pn_event_t *e, pn_connection_t *pn_co
     switch (pn_event_type(e)) {
 
     case PN_PROACTOR_INTERRUPT:
-        if (qd_server->stopping) {
-            /* Interrupt the next thread */
-            pn_proactor_interrupt(qd_server->proactor);
-            /* Stop the current thread */
-            return false;
-        } else {
-            /* Check for immediate tasks */
-            qd_immediate_visit();
-        }
-        break;
+        /* Interrupt the next thread */
+        pn_proactor_interrupt(qd_server->proactor);
+        /* Stop the current thread */
+        return false;
 
     case PN_PROACTOR_TIMEOUT:
         qd_timer_visit();
@@ -1227,7 +1219,7 @@ qd_server_t *qd_server(qd_dispatch_t *qd, int thread_count, const char *containe
     qd_server->cond             = sys_cond();
     DEQ_INIT(qd_server->conn_list);
 
-    qd_timer_initialize();
+    qd_timer_initialize(qd_server->lock);
 
     qd_server->pause_requests         = 0;
     qd_server->threads_paused         = 0;
@@ -1303,7 +1295,6 @@ void qd_server_run(qd_dispatch_t *qd)
 
 void qd_server_stop(qd_dispatch_t *qd)
 {
-    qd->server->stopping = true;
     /* Interrupt the proactor, async-signal-safe */
     pn_proactor_interrupt(qd->server->proactor);
 }
@@ -1520,10 +1511,6 @@ void qd_server_timeout(qd_server_t *server, qd_duration_t duration) {
     pn_proactor_set_timeout(server->proactor, duration);
 }
 
-void qd_server_interrupt(qd_server_t *server) {
-    pn_proactor_interrupt(server->proactor);
-}
-
 qd_dispatch_t* qd_server_dispatch(qd_server_t *server) { return server->qd; }
 
 const char* qd_connection_name(const qd_connection_t *c) {
diff --git a/src/server_private.h b/src/server_private.h
index 0a0a32f..f5a714b 100644
--- a/src/server_private.h
+++ b/src/server_private.h
@@ -38,7 +38,6 @@
 
 qd_dispatch_t* qd_server_dispatch(qd_server_t *server);
 void qd_server_timeout(qd_server_t *server, qd_duration_t delay);
-void qd_server_interrupt(qd_server_t *server);
 
 qd_connection_t *qd_server_connection(qd_server_t *server, qd_server_config_t* config);
 
diff --git a/src/timer.c b/src/timer.c
index c76f77d..a4aae2a 100644
--- a/src/timer.c
+++ b/src/timer.c
@@ -18,9 +18,8 @@
  */
 
 #include "dispatch_private.h"
-#include "immediate_private.h"
-#include "server_private.h"
 #include "timer_private.h"
+#include "server_private.h"
 #include <qpid/dispatch/ctools.h>
 #include <qpid/dispatch/threading.h>
 #include <qpid/dispatch/alloc.h>
@@ -55,7 +54,6 @@ static void timer_cancel_LH(qd_timer_t *timer)
         DEQ_INSERT_TAIL(idle_timers, timer);
         timer->scheduled = false;
     }
-    qd_immediate_disarm(timer->immediate);
 }
 
 /* Adjust timer's time_base and delays for the current time. */
@@ -97,7 +95,6 @@ qd_timer_t *qd_timer(qd_dispatch_t *qd, qd_timer_cb_t cb, void* context)
     timer->context    = context;
     timer->delta_time = 0;
     timer->scheduled  = false;
-    timer->immediate  = qd_immediate(qd, cb, context);
     sys_mutex_lock(lock);
     DEQ_INSERT_TAIL(idle_timers, timer);
     sys_mutex_unlock(lock);
@@ -112,7 +109,6 @@ void qd_timer_free(qd_timer_t *timer)
     sys_mutex_lock(lock);
     timer_cancel_LH(timer);
     DEQ_REMOVE(idle_timers, timer);
-    qd_immediate_free(timer->immediate);
     sys_mutex_unlock(lock);
     free_qd_timer_t(timer);
 }
@@ -128,11 +124,6 @@ qd_timestamp_t qd_timer_now() {
 void qd_timer_schedule(qd_timer_t *timer, qd_duration_t duration)
 {
     sys_mutex_lock(lock);
-    if (duration == 0) {
-        qd_immediate_arm(timer->immediate);
-        sys_mutex_unlock(lock);
-        return;
-    }
     timer_cancel_LH(timer);  // Timer is now on the idle list
     DEQ_REMOVE(idle_timers, timer);
 
@@ -182,10 +173,9 @@ void qd_timer_cancel(qd_timer_t *timer)
 //=========================================================================
 
 
-void qd_timer_initialize()
+void qd_timer_initialize(sys_mutex_t *server_lock)
 {
-    qd_immediate_initialize();
-    lock = sys_mutex();
+    lock = server_lock;
     DEQ_INIT(idle_timers);
     DEQ_INIT(scheduled_timers);
     time_base = 0;
@@ -194,9 +184,7 @@ void qd_timer_initialize()
 
 void qd_timer_finalize(void)
 {
-    sys_mutex_free(lock);
     lock = 0;
-    qd_immediate_finalize();
 }
 
 
@@ -208,7 +196,6 @@ void qd_timer_visit()
     qd_timer_t *timer = DEQ_HEAD(scheduled_timers);
     while (timer && timer->delta_time == 0) {
         timer_cancel_LH(timer); /* Removes timer from scheduled_timers */
-        qd_immediate_disarm(timer->immediate);
         sys_mutex_unlock(lock);
         timer->handler(timer->context); /* Call the handler outside the lock, may re-schedule */
         sys_mutex_lock(lock);
@@ -219,5 +206,4 @@ void qd_timer_visit()
         qd_server_timeout(first->server, first->delta_time);
     }
     sys_mutex_unlock(lock);
-    qd_immediate_visit();
 }
diff --git a/src/timer_private.h b/src/timer_private.h
index 9f6f1cb..537eb4b 100644
--- a/src/timer_private.h
+++ b/src/timer_private.h
@@ -19,7 +19,6 @@
  * under the License.
  */
 
-#include "immediate_private.h"
 #include <qpid/dispatch/ctools.h>
 #include <qpid/dispatch/timer.h>
 #include <qpid/dispatch/threading.h>
@@ -30,13 +29,12 @@ struct qd_timer_t {
     qd_timer_cb_t     handler;
     void             *context;
     qd_timestamp_t    delta_time;
-    qd_immediate_t   *immediate; /* Optimized path for schedule(0) */
     bool              scheduled; /* true means on scheduled list, false on idle list */
 };
 
 DEQ_DECLARE(qd_timer_t, qd_timer_list_t);
 
-void qd_timer_initialize(void);
+void qd_timer_initialize(sys_mutex_t *server_lock);
 void qd_timer_finalize(void);
 void qd_timer_visit();
 


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