Blame SOURCES/0006-data_provider_be-got-rid-of-duplicating-SIGTERM-hand.patch

0d097b
From e41e9b37e4d3fcd8544fb6c591dafbaef0954438 Mon Sep 17 00:00:00 2001
0d097b
From: Alexey Tikhonov <atikhono@redhat.com>
0d097b
Date: Mon, 9 Dec 2019 17:48:14 +0100
0d097b
Subject: [PATCH 6/7] data_provider_be: got rid of duplicating SIGTERM handler
0d097b
MIME-Version: 1.0
0d097b
Content-Type: text/plain; charset=UTF-8
0d097b
Content-Transfer-Encoding: 8bit
0d097b
0d097b
It was wrong to install two libtevent SIGTERM handlers both of which did
0d097b
orderly_shutdown()->exit(). Naturally only one of the handlers was executed
0d097b
(as process was terminated with exit()) and libtevent docs doesn't say
0d097b
anything about order of execution. But chances are, be_process_finalize()
0d097b
was executed first so default_quit() was not executed and main_ctx was not
0d097b
freed.
0d097b
0d097b
Moreover there is just no reason to have separate be_process_finalize()
0d097b
at all: default server handler default_quit() frees main_ctx. And be_ctx
0d097b
is linked to main_ctx so will be freed by default handler as well.
0d097b
0d097b
Resolves: https://pagure.io/SSSD/sssd/issue/4088
0d097b
0d097b
Reviewed-by: Michal Židek <mzidek@redhat.com>
0d097b
---
0d097b
 src/providers/data_provider_be.c | 37 --------------------------------
0d097b
 1 file changed, 37 deletions(-)
0d097b
0d097b
diff --git a/src/providers/data_provider_be.c b/src/providers/data_provider_be.c
0d097b
index cfcf0268d..ce00231ff 100644
0d097b
--- a/src/providers/data_provider_be.c
0d097b
+++ b/src/providers/data_provider_be.c
0d097b
@@ -445,36 +445,6 @@ be_register_monitor_iface(struct sbus_connection *conn, struct be_ctx *be_ctx)
0d097b
     return sbus_connection_add_path_map(be_ctx->mon_conn, paths);
0d097b
 }
0d097b
 
0d097b
-static void be_process_finalize(struct tevent_context *ev,
0d097b
-                                struct tevent_signal *se,
0d097b
-                                int signum,
0d097b
-                                int count,
0d097b
-                                void *siginfo,
0d097b
-                                void *private_data)
0d097b
-{
0d097b
-    struct be_ctx *be_ctx;
0d097b
-
0d097b
-    be_ctx = talloc_get_type(private_data, struct be_ctx);
0d097b
-    talloc_free(be_ctx);
0d097b
-    orderly_shutdown(0);
0d097b
-}
0d097b
-
0d097b
-static errno_t be_process_install_sigterm_handler(struct be_ctx *be_ctx)
0d097b
-{
0d097b
-    struct tevent_signal *sige;
0d097b
-
0d097b
-    BlockSignals(false, SIGTERM);
0d097b
-
0d097b
-    sige = tevent_add_signal(be_ctx->ev, be_ctx, SIGTERM, SA_SIGINFO,
0d097b
-                             be_process_finalize, be_ctx);
0d097b
-    if (sige == NULL) {
0d097b
-        DEBUG(SSSDBG_CRIT_FAILURE, "tevent_add_signal failed.\n");
0d097b
-        return ENOMEM;
0d097b
-    }
0d097b
-
0d097b
-    return EOK;
0d097b
-}
0d097b
-
0d097b
 static void dp_initialized(struct tevent_req *req);
0d097b
 
0d097b
 errno_t be_process_init(TALLOC_CTX *mem_ctx,
0d097b
@@ -566,13 +536,6 @@ errno_t be_process_init(TALLOC_CTX *mem_ctx,
0d097b
         goto done;
0d097b
     }
0d097b
 
0d097b
-    /* Install signal handler */
0d097b
-    ret = be_process_install_sigterm_handler(be_ctx);
0d097b
-    if (ret != EOK) {
0d097b
-        DEBUG(SSSDBG_CRIT_FAILURE, "be_install_sigterm_handler failed.\n");
0d097b
-        goto done;
0d097b
-    }
0d097b
-
0d097b
     req = dp_init_send(be_ctx, be_ctx->ev, be_ctx, be_ctx->uid, be_ctx->gid);
0d097b
     if (req == NULL) {
0d097b
         ret = ENOMEM;
0d097b
-- 
0d097b
2.20.1
0d097b