[PATCH] loadparm: Do not talloc empty params
Volker Lendecke
Volker.Lendecke at SerNet.DE
Fri Nov 27 06:41:59 UTC 2015
On Thu, Nov 26, 2015 at 09:26:26PM +0100, Volker Lendecke wrote:
> On Thu, Nov 26, 2015 at 09:09:12PM +0100, Volker Lendecke wrote:
> > Hi!
> >
> > Review appreciated!
>
> Survived autobuild, but obviously buggy. More later.
This is better I think.
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 e293d94818959bc1536a4058cc603e3f3cf16c51 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 | 18 +++++++++++++-----
source3/param/loadparm.c | 2 +-
2 files changed, 14 insertions(+), 6 deletions(-)
diff --git a/lib/param/loadparm.c b/lib/param/loadparm.c
index 640c602..9e185f8 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,19 @@ 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')) {
+ *dst = NULL;
+ } else {
+ lpcfg_string_set(pserviceDest,
+ dst, *src);
+ }
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