summaryrefslogtreecommitdiffstats
path: root/src/sss_client
diff options
context:
space:
mode:
authorLukas Slebodnik <lslebodn@redhat.com>2014-11-21 14:00:23 +0100
committerJakub Hrozek <jhrozek@redhat.com>2014-11-24 20:53:54 +0100
commit19f6a6733b5c6cf7dd2f6f746cfa5c787706331c (patch)
tree99aef2143c05d89eee253196a4d854434d861fe5 /src/sss_client
parentcbbe63ded9d628ffb2494132ca1e5ebe90e2d5f8 (diff)
downloadsssd-19f6a6733b5c6cf7dd2f6f746cfa5c787706331c.tar.gz
sssd-19f6a6733b5c6cf7dd2f6f746cfa5c787706331c.tar.xz
sssd-19f6a6733b5c6cf7dd2f6f746cfa5c787706331c.zip
sss_client: Extract destroying of mmap cache to function
Reviewed-by: Michal Židek <mzidek@redhat.com>
Diffstat (limited to 'src/sss_client')
-rw-r--r--src/sss_client/nss_mc_common.c30
1 files changed, 14 insertions, 16 deletions
diff --git a/src/sss_client/nss_mc_common.c b/src/sss_client/nss_mc_common.c
index 6c9b35de2..9c6e1af16 100644
--- a/src/sss_client/nss_mc_common.c
+++ b/src/sss_client/nss_mc_common.c
@@ -102,6 +102,18 @@ errno_t sss_nss_check_header(struct sss_cli_mc_ctx *ctx)
return 0;
}
+static void sss_nss_mc_destroy_ctx(struct sss_cli_mc_ctx *ctx)
+{
+ if ((ctx->mmap_base != NULL) && (ctx->mmap_size != 0)) {
+ munmap(ctx->mmap_base, ctx->mmap_size);
+ }
+ if (ctx->fd != -1) {
+ close(ctx->fd);
+ }
+ memset(ctx, 0, sizeof(struct sss_cli_mc_ctx));
+ ctx->fd = -1;
+}
+
static errno_t sss_nss_mc_init_ctx(const char *name,
struct sss_cli_mc_ctx *ctx)
{
@@ -157,14 +169,7 @@ static errno_t sss_nss_mc_init_ctx(const char *name,
done:
if (ret) {
- if ((ctx->mmap_base != NULL) && (ctx->mmap_size != 0)) {
- munmap(ctx->mmap_base, ctx->mmap_size);
- }
- if (ctx->fd != -1) {
- close(ctx->fd);
- }
- memset(ctx, 0, sizeof(struct sss_cli_mc_ctx));
- ctx->fd = -1;
+ sss_nss_mc_destroy_ctx(ctx);
}
free(file);
sss_nss_unlock();
@@ -191,14 +196,7 @@ errno_t sss_nss_mc_get_ctx(const char *name, struct sss_cli_mc_ctx *ctx)
done:
if (ret) {
- if ((ctx->mmap_base != NULL) && (ctx->mmap_size != 0)) {
- munmap(ctx->mmap_base, ctx->mmap_size);
- }
- if (ctx->fd != -1) {
- close(ctx->fd);
- }
- memset(ctx, 0, sizeof(struct sss_cli_mc_ctx));
- ctx->fd = -1;
+ sss_nss_mc_destroy_ctx(ctx);
}
return ret;
}