aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVolker Lendecke <vl@samba.org>2018-05-07 16:53:00 +0200
committerKarolin Seeger <kseeger@samba.org>2018-09-27 15:32:11 +0200
commit0e2596567643f87e207d1197233ade203ef69ad3 (patch)
treeef201f830809dd1619b3265985c5ff0ea45c5894
parentaa529bc41463509725322bebad7ca7841023e8c0 (diff)
downloadsamba-v4-8-test.tar.gz
samba-v4-8-test.tar.xz
samba-v4-8-test.zip
lib: Hold at most 10 outstanding paged result cookiesv4-8-test
Bug: https://bugzilla.samba.org/show_bug.cgi?id=13362 Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org> Autobuild-User(master): Jeremy Allison <jra@samba.org> Autobuild-Date(master): Tue May 15 09:37:21 CEST 2018 on sn-devel-144 (cherry picked from commit 9fbd4672b06de5333a9c44fc126b8edac0b9d31a) Autobuild-User(v4-8-test): Karolin Seeger <kseeger@samba.org> Autobuild-Date(v4-8-test): Thu Sep 27 15:32:11 CEST 2018 on sn-devel-144
-rw-r--r--lib/ldb/modules/paged_results.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/lib/ldb/modules/paged_results.c b/lib/ldb/modules/paged_results.c
index aafbcbf4483..ecb22271d28 100644
--- a/lib/ldb/modules/paged_results.c
+++ b/lib/ldb/modules/paged_results.c
@@ -36,6 +36,7 @@
#include "system/filesys.h"
#include "system/time.h"
#include "dlinklist.h"
+#include <assert.h>
#include "ldb_module.h"
struct message_store {
@@ -68,6 +69,7 @@ struct results_store {
struct private_data {
uint32_t next_free_id;
+ size_t num_stores;
struct results_store *store;
};
@@ -76,6 +78,10 @@ static int store_destructor(struct results_store *del)
{
struct private_data *priv = del->priv;
DLIST_REMOVE(priv->store, del);
+
+ assert(priv->num_stores > 0);
+ priv->num_stores -= 1;
+
return 0;
}
@@ -108,8 +114,21 @@ static struct results_store *new_store(struct private_data *priv)
DLIST_ADD(priv->store, newr);
+ assert(priv->num_stores < SIZE_MAX);
+ priv->num_stores += 1;
+
talloc_set_destructor(newr, store_destructor);
+ if (priv->num_stores > 10) {
+ struct results_store *last;
+ /*
+ * 10 is the default for MaxResultSetsPerConn --
+ * possibly need to parameterize it.
+ */
+ last = DLIST_TAIL(priv->store);
+ TALLOC_FREE(last);
+ }
+
return newr;
}
@@ -366,6 +385,8 @@ static int paged_search(struct ldb_module *module, struct ldb_request *req)
return LDB_ERR_UNWILLING_TO_PERFORM;
}
+ DLIST_PROMOTE(private_data->store, current);
+
ac->store = current;
/* check if it is an abandon */
@@ -397,6 +418,7 @@ static int paged_request_init(struct ldb_module *module)
}
data->next_free_id = 1;
+ data->num_stores = 0;
data->store = NULL;
ldb_module_set_private(module, data);