#include "system/filesys.h"
#include "system/time.h"
#include "dlinklist.h"
+#include <assert.h>
#include "ldb_module.h"
struct message_store {
struct private_data {
uint32_t next_free_id;
+ size_t num_stores;
struct results_store *store;
};
{
struct private_data *priv = del->priv;
DLIST_REMOVE(priv->store, del);
+
+ assert(priv->num_stores > 0);
+ priv->num_stores -= 1;
+
return 0;
}
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;
}
return LDB_ERR_UNWILLING_TO_PERFORM;
}
+ DLIST_PROMOTE(private_data->store, current);
+
ac->store = current;
/* check if it is an abandon */
}
data->next_free_id = 1;
+ data->num_stores = 0;
data->store = NULL;
ldb_module_set_private(module, data);