5e5e26a
From 48cff40315cfbfcfae3582935efda961757ceec6 Mon Sep 17 00:00:00 2001
5e5e26a
From: =?UTF-8?q?Fabiano=20Fid=C3=AAncio?= <fidencio@redhat.com>
5e5e26a
Date: Tue, 13 Mar 2018 21:11:16 +0100
5e5e26a
Subject: [PATCH 09/15] KCM: Remove mem_ctx from kcm_new_req()
5e5e26a
MIME-Version: 1.0
5e5e26a
Content-Type: text/plain; charset=UTF-8
5e5e26a
Content-Transfer-Encoding: 8bit
5e5e26a
5e5e26a
Let's remove the mem_ctx argument as we really want cctx to be the
5e5e26a
memory context here, so that if the client disconnects the request goes
5e5e26a
away.
5e5e26a
5e5e26a
Signed-off-by: Fabiano FidĂȘncio <fidencio@redhat.com>
5e5e26a
5e5e26a
Reviewed-by: Jakub Hrozek <jhrozek@redhat.com>
5e5e26a
---
5e5e26a
 src/responder/kcm/kcmsrv_cmd.c | 10 ++++++----
5e5e26a
 1 file changed, 6 insertions(+), 4 deletions(-)
5e5e26a
5e5e26a
diff --git a/src/responder/kcm/kcmsrv_cmd.c b/src/responder/kcm/kcmsrv_cmd.c
5e5e26a
index 0b933f0b4..d4ebb79bf 100644
5e5e26a
--- a/src/responder/kcm/kcmsrv_cmd.c
5e5e26a
+++ b/src/responder/kcm/kcmsrv_cmd.c
5e5e26a
@@ -423,8 +423,10 @@ static errno_t kcm_recv_data(int fd, struct kcm_reqbuf *reqbuf)
5e5e26a
     return EOK;
5e5e26a
 }
5e5e26a
 
5e5e26a
-static struct kcm_req_ctx *kcm_new_req(TALLOC_CTX *mem_ctx,
5e5e26a
-                                       struct cli_ctx *cctx,
5e5e26a
+/* Mind that kcm_new_req() does not take a mem_ctx argument on purpose as we
5e5e26a
+ * really want the cctx to be the memory context here so that if the client
5e5e26a
+ * disconnects, the request goes away. */
5e5e26a
+static struct kcm_req_ctx *kcm_new_req(struct cli_ctx *cctx,
5e5e26a
                                        struct kcm_ctx *kctx)
5e5e26a
 {
5e5e26a
     struct kcm_req_ctx *req;
5e5e26a
@@ -467,8 +469,8 @@ static void kcm_recv(struct cli_ctx *cctx)
5e5e26a
     kctx = talloc_get_type(cctx->rctx->pvt_ctx, struct kcm_ctx);
5e5e26a
     req = talloc_get_type(cctx->state_ctx, struct kcm_req_ctx);
5e5e26a
     if (req == NULL) {
5e5e26a
-        /* A new request comes in, setup data structures */
5e5e26a
-        req = kcm_new_req(cctx, cctx, kctx);
5e5e26a
+        /* A new request comes in, setup data structures. */
5e5e26a
+        req = kcm_new_req(cctx, kctx);
5e5e26a
         if (req == NULL) {
5e5e26a
             DEBUG(SSSDBG_CRIT_FAILURE,
5e5e26a
                   "Cannot set up client connection\n");
5e5e26a
-- 
5e5e26a
2.14.3
5e5e26a