|
Ian Kent |
89523c |
autofs-5.0.5 - fix memory leak on reload
|
|
Ian Kent |
89523c |
|
|
Ian Kent |
89523c |
From: Ian Kent <raven@themaw.net>
|
|
Ian Kent |
89523c |
|
|
Ian Kent |
89523c |
When sending a signal to the automount daemon to re-load the maps a map
|
|
Ian Kent |
89523c |
entry cache is pre-allocated before checking if the entry already exists.
|
|
Ian Kent |
89523c |
If the master map entry was found to exist the pre-allocated cache was
|
|
Ian Kent |
89523c |
not being freed.
|
|
Ian Kent |
89523c |
|
|
Ian Kent |
89523c |
If there are a large number of entries in the master map and there are
|
|
Ian Kent |
89523c |
frequent re-load requests sent to the daemon the memory leak will cause
|
|
Ian Kent |
89523c |
the system to become unstable fairly quilkly.
|
|
Ian Kent |
89523c |
|
|
Ian Kent |
89523c |
Since the map entry cache (allocated for each map entry) is fairly large
|
|
Ian Kent |
89523c |
these days (and is configurable) pre-allocating it is no longer a cheap
|
|
Ian Kent |
89523c |
operation. This patch fixes the memory leak and only allocates a map
|
|
Ian Kent |
89523c |
entry cache if the entry does not already exist.
|
|
Ian Kent |
89523c |
---
|
|
Ian Kent |
89523c |
|
|
Ian Kent |
89523c |
CHANGELOG | 1 +
|
|
Ian Kent |
89523c |
lib/master.c | 17 +++++++++++++++--
|
|
Ian Kent |
89523c |
2 files changed, 16 insertions(+), 2 deletions(-)
|
|
Ian Kent |
89523c |
|
|
Ian Kent |
89523c |
|
|
Ian Kent |
89523c |
diff --git a/CHANGELOG b/CHANGELOG
|
|
Ian Kent |
89523c |
index 20566a6..df2ec09 100644
|
|
Ian Kent |
89523c |
--- a/CHANGELOG
|
|
Ian Kent |
89523c |
+++ b/CHANGELOG
|
|
Ian Kent |
89523c |
@@ -16,6 +16,7 @@
|
|
Ian Kent |
89523c |
- check for path mount location in generic module.
|
|
Ian Kent |
89523c |
- dont fail mount on access fail.
|
|
Ian Kent |
89523c |
- fix rpc fail on large export list.
|
|
Ian Kent |
89523c |
+- fix memory leak on reload.
|
|
Ian Kent |
89523c |
|
|
Ian Kent |
89523c |
03/09/2009 autofs-5.0.5
|
|
Ian Kent |
89523c |
-----------------------
|
|
Ian Kent |
89523c |
diff --git a/lib/master.c b/lib/master.c
|
|
Ian Kent |
89523c |
index 8455f40..83019aa 100644
|
|
Ian Kent |
89523c |
--- a/lib/master.c
|
|
Ian Kent |
89523c |
+++ b/lib/master.c
|
|
Ian Kent |
89523c |
@@ -190,9 +190,15 @@ master_add_map_source(struct master_mapent *entry,
|
|
Ian Kent |
89523c |
|
|
Ian Kent |
89523c |
master_source_writelock(entry);
|
|
Ian Kent |
89523c |
|
|
Ian Kent |
89523c |
- if (!entry->maps)
|
|
Ian Kent |
89523c |
+ if (!entry->maps) {
|
|
Ian Kent |
89523c |
+ source->mc = cache_init(entry->ap, source);
|
|
Ian Kent |
89523c |
+ if (!source->mc) {
|
|
Ian Kent |
89523c |
+ master_free_map_source(source, 0);
|
|
Ian Kent |
89523c |
+ master_source_unlock(entry);
|
|
Ian Kent |
89523c |
+ return NULL;
|
|
Ian Kent |
89523c |
+ }
|
|
Ian Kent |
89523c |
entry->maps = source;
|
|
Ian Kent |
89523c |
- else {
|
|
Ian Kent |
89523c |
+ } else {
|
|
Ian Kent |
89523c |
struct map_source *this, *last, *next;
|
|
Ian Kent |
89523c |
|
|
Ian Kent |
89523c |
/* Typically there only a few map sources */
|
|
Ian Kent |
89523c |
@@ -205,6 +211,13 @@ master_add_map_source(struct master_mapent *entry,
|
|
Ian Kent |
89523c |
return this;
|
|
Ian Kent |
89523c |
}
|
|
Ian Kent |
89523c |
|
|
Ian Kent |
89523c |
+ source->mc = cache_init(entry->ap, source);
|
|
Ian Kent |
89523c |
+ if (!source->mc) {
|
|
Ian Kent |
89523c |
+ master_free_map_source(source, 0);
|
|
Ian Kent |
89523c |
+ master_source_unlock(entry);
|
|
Ian Kent |
89523c |
+ return NULL;
|
|
Ian Kent |
89523c |
+ }
|
|
Ian Kent |
89523c |
+
|
|
Ian Kent |
89523c |
last = NULL;
|
|
Ian Kent |
89523c |
next = entry->maps;
|
|
Ian Kent |
89523c |
while (next) {
|