|
|
905b4d |
From 82d37e1a84202d3609ceb70aaf0893199ec0e464 Mon Sep 17 00:00:00 2001
|
|
|
905b4d |
From: Lukas Slebodnik <lslebodn@redhat.com>
|
|
|
905b4d |
Date: Fri, 21 Nov 2014 14:00:23 +0100
|
|
|
905b4d |
Subject: [PATCH 105/112] sss_client: Extract destroying of mmap cache to
|
|
|
905b4d |
function
|
|
|
905b4d |
MIME-Version: 1.0
|
|
|
905b4d |
Content-Type: text/plain; charset=UTF-8
|
|
|
905b4d |
Content-Transfer-Encoding: 8bit
|
|
|
905b4d |
|
|
|
905b4d |
Reviewed-by: Michal Židek <mzidek@redhat.com>
|
|
|
905b4d |
---
|
|
|
905b4d |
src/sss_client/nss_mc_common.c | 30 ++++++++++++++----------------
|
|
|
905b4d |
1 file changed, 14 insertions(+), 16 deletions(-)
|
|
|
905b4d |
|
|
|
905b4d |
diff --git a/src/sss_client/nss_mc_common.c b/src/sss_client/nss_mc_common.c
|
|
|
905b4d |
index 6c9b35de280c637bf957207993e539c889b16c23..9c6e1af1642275fc7738b51d7ca80d712d49b2ac 100644
|
|
|
905b4d |
--- a/src/sss_client/nss_mc_common.c
|
|
|
905b4d |
+++ b/src/sss_client/nss_mc_common.c
|
|
|
905b4d |
@@ -102,6 +102,18 @@ errno_t sss_nss_check_header(struct sss_cli_mc_ctx *ctx)
|
|
|
905b4d |
return 0;
|
|
|
905b4d |
}
|
|
|
905b4d |
|
|
|
905b4d |
+static void sss_nss_mc_destroy_ctx(struct sss_cli_mc_ctx *ctx)
|
|
|
905b4d |
+{
|
|
|
905b4d |
+ if ((ctx->mmap_base != NULL) && (ctx->mmap_size != 0)) {
|
|
|
905b4d |
+ munmap(ctx->mmap_base, ctx->mmap_size);
|
|
|
905b4d |
+ }
|
|
|
905b4d |
+ if (ctx->fd != -1) {
|
|
|
905b4d |
+ close(ctx->fd);
|
|
|
905b4d |
+ }
|
|
|
905b4d |
+ memset(ctx, 0, sizeof(struct sss_cli_mc_ctx));
|
|
|
905b4d |
+ ctx->fd = -1;
|
|
|
905b4d |
+}
|
|
|
905b4d |
+
|
|
|
905b4d |
static errno_t sss_nss_mc_init_ctx(const char *name,
|
|
|
905b4d |
struct sss_cli_mc_ctx *ctx)
|
|
|
905b4d |
{
|
|
|
905b4d |
@@ -157,14 +169,7 @@ static errno_t sss_nss_mc_init_ctx(const char *name,
|
|
|
905b4d |
|
|
|
905b4d |
done:
|
|
|
905b4d |
if (ret) {
|
|
|
905b4d |
- if ((ctx->mmap_base != NULL) && (ctx->mmap_size != 0)) {
|
|
|
905b4d |
- munmap(ctx->mmap_base, ctx->mmap_size);
|
|
|
905b4d |
- }
|
|
|
905b4d |
- if (ctx->fd != -1) {
|
|
|
905b4d |
- close(ctx->fd);
|
|
|
905b4d |
- }
|
|
|
905b4d |
- memset(ctx, 0, sizeof(struct sss_cli_mc_ctx));
|
|
|
905b4d |
- ctx->fd = -1;
|
|
|
905b4d |
+ sss_nss_mc_destroy_ctx(ctx);
|
|
|
905b4d |
}
|
|
|
905b4d |
free(file);
|
|
|
905b4d |
sss_nss_unlock();
|
|
|
905b4d |
@@ -191,14 +196,7 @@ errno_t sss_nss_mc_get_ctx(const char *name, struct sss_cli_mc_ctx *ctx)
|
|
|
905b4d |
|
|
|
905b4d |
done:
|
|
|
905b4d |
if (ret) {
|
|
|
905b4d |
- if ((ctx->mmap_base != NULL) && (ctx->mmap_size != 0)) {
|
|
|
905b4d |
- munmap(ctx->mmap_base, ctx->mmap_size);
|
|
|
905b4d |
- }
|
|
|
905b4d |
- if (ctx->fd != -1) {
|
|
|
905b4d |
- close(ctx->fd);
|
|
|
905b4d |
- }
|
|
|
905b4d |
- memset(ctx, 0, sizeof(struct sss_cli_mc_ctx));
|
|
|
905b4d |
- ctx->fd = -1;
|
|
|
905b4d |
+ sss_nss_mc_destroy_ctx(ctx);
|
|
|
905b4d |
}
|
|
|
905b4d |
return ret;
|
|
|
905b4d |
}
|
|
|
905b4d |
--
|
|
|
905b4d |
1.9.3
|
|
|
905b4d |
|