summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
authorVolker Lendecke <vl@samba.org>2009-07-14 18:31:28 +0200
committerVolker Lendecke <vl@samba.org>2009-07-15 10:55:20 +0200
commit76705d10c626a66cc77f3ec294f4f98bef95aeb5 (patch)
treeebba28d32a98b4095118c7c14687f0ef63edfe89 /source3
parent3d7dfc1197017c34bdb8dbc6e62460f19bd7d141 (diff)
downloadsamba-76705d10c626a66cc77f3ec294f4f98bef95aeb5.tar.gz
samba-76705d10c626a66cc77f3ec294f4f98bef95aeb5.tar.bz2
samba-76705d10c626a66cc77f3ec294f4f98bef95aeb5.zip
Consolidate gencache also every 100 writes in a single process
Diffstat (limited to 'source3')
-rw-r--r--source3/lib/gencache.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/source3/lib/gencache.c b/source3/lib/gencache.c
index 6496ad3ed6..ee1f4b70b3 100644
--- a/source3/lib/gencache.c
+++ b/source3/lib/gencache.c
@@ -121,6 +121,7 @@ bool gencache_set_data_blob(const char *keystr, const DATA_BLOB *blob,
TDB_DATA databuf;
char* val;
time_t last_stabilize;
+ static int writecount;
if (tdb_data_cmp(string_term_tdb_data(keystr),
last_stabilize_key()) == 0) {
@@ -163,6 +164,18 @@ bool gencache_set_data_blob(const char *keystr, const DATA_BLOB *blob,
}
/*
+ * Every 100 writes within a single process, stabilize the cache with
+ * a transaction. This is done to prevent a single transaction to
+ * become huge and chew lots of memory.
+ */
+ writecount += 1;
+ if (writecount > lp_parm_int(-1, "gencache", "stabilize_count", 100)) {
+ gencache_stabilize();
+ writecount = 0;
+ goto done;
+ }
+
+ /*
* Every 5 minutes, call gencache_stabilize() to not let grow
* gencache_notrans.tdb too large.
*/
@@ -180,6 +193,7 @@ bool gencache_set_data_blob(const char *keystr, const DATA_BLOB *blob,
gencache_stabilize();
}
+done:
return ret == 0;
}