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