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

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