[PATCH] loadparm: Do not talloc empty params
Volker Lendecke
Volker.Lendecke at SerNet.DE
Thu Nov 26 20:09:12 UTC 2015
Hi!
Review appreciated!
Thanks, Volker
--
SerNet GmbH, Bahnhofsallee 1b, 37081 Göttingen
phone: +49-551-370000-0, fax: +49-551-370000-9
AG Göttingen, HRB 2816, GF: Dr. Johannes Loxen
http://www.sernet.de, mailto:kontakt at sernet.de
-------------- next part --------------
From d79436f338f1693b0fc83210fc66c9672301bbcb Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Thu, 26 Nov 2015 13:23:41 +0100
Subject: [PATCH] loadparm: Do not talloc empty params
Reduce memory footprint for large smb.conf files. With 1400 shares this
gets smbd -i from 7259kb to 3087kb according to 64-bit x86 massif. If
you want to serve 1000 clients, this saves you 4GB.
Signed-off-by: Volker Lendecke <vl at samba.org>
---
lib/param/loadparm.c | 15 ++++++++++-----
source3/param/loadparm.c | 2 +-
2 files changed, 11 insertions(+), 6 deletions(-)
diff --git a/lib/param/loadparm.c b/lib/param/loadparm.c
index 640c602..13ca2b5 100644
--- a/lib/param/loadparm.c
+++ b/lib/param/loadparm.c
@@ -128,7 +128,7 @@ static const char *lpcfg_string(const char *s)
standard_sub_basic(ret,len+100);
return (ret);
#endif
- return s;
+ return s ? s : "";
}
/*
@@ -876,11 +876,16 @@ void copy_service(struct loadparm_service *pserviceDest,
*(char *)dest_ptr = *(const char *)src_ptr;
break;
- case P_STRING:
- lpcfg_string_set(pserviceDest,
- (char **)dest_ptr,
- *(const char * const *)src_ptr);
+ case P_STRING: {
+ const char * const *src = (const char * const *)src_ptr;
+ char **dst = (char **)dest_ptr;
+ if ((*src == NULL) || (**src != '\0')) {
+ lpcfg_string_set(pserviceDest, dst, *src);
+ } else {
+ *dst = NULL;
+ }
break;
+ }
case P_USTRING:
lpcfg_string_set_upper(pserviceDest,
diff --git a/source3/param/loadparm.c b/source3/param/loadparm.c
index 9f40e65..7d734a4 100644
--- a/source3/param/loadparm.c
+++ b/source3/param/loadparm.c
@@ -962,7 +962,7 @@ char *lp_string(TALLOC_CTX *ctx, const char *s)
DEBUG(10, ("lp_string(%s)\n", s));
#endif
if (!s) {
- return NULL;
+ s = "";
}
ret = talloc_sub_basic(ctx,
--
1.9.1
More information about the samba-technical
mailing list