qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From acon...@apache.org
Subject [2/2] qpid-dispatch git commit: DISPATCH-777: async-signal-safe shutdown of the reactor.
Date Mon, 29 May 2017 19:20:17 GMT
DISPATCH-777: async-signal-safe shutdown of the reactor.

Previously the server was disconnecting the proactor inside a signal handler,
which is not async-signal-safe and caused occasional crashes on shutdown.

Now it only signals the proactor threads to stop. The main thread does required
clean up after all other proactor threads are joined.


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

Branch: refs/heads/master
Commit: b1f09d5ea8101f40f3df4db5b4c5d2ee00e6ef7e
Parents: d773cc8
Author: Alan Conway <aconway@redhat.com>
Authored: Mon May 29 15:16:26 2017 -0400
Committer: Alan Conway <aconway@redhat.com>
Committed: Mon May 29 15:18:46 2017 -0400

----------------------------------------------------------------------
 router/src/main.c | 5 +++++
 src/server.c      | 9 ++++-----
 2 files changed, 9 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/b1f09d5e/router/src/main.c
----------------------------------------------------------------------
diff --git a/router/src/main.c b/router/src/main.c
index ee084df..5ba36a8 100644
--- a/router/src/main.c
+++ b/router/src/main.c
@@ -42,6 +42,11 @@ static const char* argv0 = 0;
  */
 static void signal_handler(int signum)
 {
+    /* Ignore future signals, dispatch may already be freed */
+    signal(SIGHUP,  SIG_IGN);
+    signal(SIGQUIT, SIG_IGN);
+    signal(SIGTERM, SIG_IGN);
+    signal(SIGINT,  SIG_IGN);
     switch (signum) {
     case SIGINT:
         exit_with_sigint = 1;

http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/b1f09d5e/src/server.c
----------------------------------------------------------------------
diff --git a/src/server.c b/src/server.c
index f3d400d..792e03e 100644
--- a/src/server.c
+++ b/src/server.c
@@ -756,6 +756,8 @@ static bool handle(qd_server_t *qd_server, pn_event_t *e) {
     switch (pn_event_type(e)) {
 
     case PN_PROACTOR_INTERRUPT:
+        /* Interrupt the next thread */
+        pn_proactor_interrupt(qd_server->proactor);
         /* Stop the current thread */
         return false;
 
@@ -1041,11 +1043,8 @@ void qd_server_run(qd_dispatch_t *qd)
 
 void qd_server_stop(qd_dispatch_t *qd)
 {
-    /* Disconnect everything, interrupt threads */
-    pn_proactor_disconnect(qd->server->proactor, NULL);
-    for (int i = 0; i < qd->server->thread_count; i++) {
-        pn_proactor_interrupt(qd->server->proactor);
-    }
+    /* Interrupt the proactor, async-signal-safe */
+    pn_proactor_interrupt(qd->server->proactor);
 }
 
 void qd_server_activate(qd_connection_t *ctx)


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


Mime
View raw message