The Samba-Bugzilla – Attachment 11844 Details for
Bug 11740
Addressing memory leak in loadparm during reload services.
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch for master.
0001-Real-memeory-leak-buildup-issue-in-loadparm.patch (text/plain), 3.54 KB, created by
Hemanth
on 2016-02-16 22:59:02 UTC
(
hide
)
Description:
Patch for master.
Filename:
MIME Type:
Creator:
Hemanth
Created:
2016-02-16 22:59:02 UTC
Size:
3.54 KB
patch
obsolete
>From 1964e4505193bd6818ffef5c55ef670d1763dd5e Mon Sep 17 00:00:00 2001 >From: Hemanth Thummala <hemanth.thummala@nutanix.com> >Date: Tue, 16 Feb 2016 14:44:38 -0800 >Subject: [PATCH] Real memeory leak(buildup) issue in loadparm. > >BUG: https://bugzilla.samba.org/show_bug.cgi?id=11740 > >As part of reload services, unused service ptr structures are getting >unloaded without actually freeingup the memory associated to them. > >Made changes to freeup those allocations on unload. On reload, reuse the >slots in ServicePtr global array instead of extending the array with >holes. > >Also we should mark shares like IPC$ as auto loaded as they never be >exposed to users. > >Signed-off-by: Hemanth Thummala <hemanth.thummala@nutanix.com> >--- > source3/param/loadparm.c | 38 +++++++++++++++++++++++++------------- > 1 files changed, 25 insertions(+), 13 deletions(-) > >diff --git a/source3/param/loadparm.c b/source3/param/loadparm.c >index 7c3195b..f8dbcde 100644 >--- a/source3/param/loadparm.c >+++ b/source3/param/loadparm.c >@@ -93,8 +93,9 @@ static struct smbconf_csn conf_last_csn; > static int config_backend = CONFIG_BACKEND_FILE; > > /* some helpful bits */ >-#define LP_SNUM_OK(i) (((i) >= 0) && ((i) < iNumServices) && (ServicePtrs != NULL) && ServicePtrs[(i)]->valid) >-#define VALID(i) (ServicePtrs != NULL && ServicePtrs[i]->valid) >+#define LP_SNUM_OK(i) (((i) >= 0) && ((i) < iNumServices) && (ServicePtrs != NULL) && \ >+ (ServicePtrs[(i)] != NULL) && ServicePtrs[(i)]->valid) >+#define VALID(i) (ServicePtrs != NULL && (ServicePtrs[i]!= NULL) && ServicePtrs[i]->valid) > > #define USERSHARE_VALID 1 > #define USERSHARE_PENDING_DELETE 2 >@@ -1358,7 +1359,7 @@ static void free_service_byindex(int idx) > } > > free_service(ServicePtrs[idx]); >- talloc_free_children(ServicePtrs[idx]); >+ TALLOC_FREE(ServicePtrs[idx]); > } > > /*************************************************************************** >@@ -1371,6 +1372,7 @@ static int add_a_service(const struct loadparm_service *pservice, const char *na > int i; > int num_to_alloc = iNumServices + 1; > struct loadparm_service **tsp = NULL; >+ bool found = false; > > /* it might already exist */ > if (name) { >@@ -1380,20 +1382,29 @@ static int add_a_service(const struct loadparm_service *pservice, const char *na > } > } > >- /* if not, then create one */ >- i = iNumServices; >- tsp = talloc_realloc(NULL, ServicePtrs, struct loadparm_service *, num_to_alloc); >- if (tsp == NULL) { >- DEBUG(0,("add_a_service: failed to enlarge ServicePtrs!\n")); >- return (-1); >+ /* Re use empty slots if any before allocating new one.*/ >+ for (i=0; i < iNumServices; i++) { >+ if (!ServicePtrs[i]) { >+ found = true; >+ break; >+ } > } >- ServicePtrs = tsp; >- ServicePtrs[iNumServices] = talloc_zero(ServicePtrs, struct loadparm_service); >- if (!ServicePtrs[iNumServices]) { >+ if (!found) { >+ /* if not, then create one */ >+ i = iNumServices; >+ tsp = talloc_realloc(NULL, ServicePtrs, struct loadparm_service *, num_to_alloc); >+ if (tsp == NULL) { >+ DEBUG(0,("add_a_service: failed to enlarge ServicePtrs!\n")); >+ return (-1); >+ } >+ ServicePtrs = tsp; >+ iNumServices++; >+ } >+ ServicePtrs[i] = talloc_zero(ServicePtrs, struct loadparm_service); >+ if (!ServicePtrs[i]) { > DEBUG(0,("add_a_service: out of memory!\n")); > return (-1); > } >- iNumServices++; > > ServicePtrs[i]->valid = true; > >@@ -1559,6 +1570,7 @@ static bool lp_add_ipc(const char *ipc_name, bool guest_ok) > ServicePtrs[i]->guest_ok = guest_ok; > ServicePtrs[i]->printable = false; > ServicePtrs[i]->browseable = sDefault.browseable; >+ ServicePtrs[i]->autoloaded = true; > > DEBUG(3, ("adding IPC service\n")); > >-- >1.7.1 >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 11740
:
11844
|
11847