The branch, v4-8-test has been updated
       via  0e25965 lib: Hold at most 10 outstanding paged result cookies
       via  aa529bc lib: Put "results_store" into a doubly linked list
      from  189697a ctdb-recoverd: Set recovery lock handle at start of attempt

https://git.samba.org/?p=samba.git;a=shortlog;h=v4-8-test


- Log -----------------------------------------------------------------
commit 0e2596567643f87e207d1197233ade203ef69ad3
Author: Volker Lendecke <v...@samba.org>
Date:   Mon May 7 16:53:00 2018 +0200

    lib: Hold at most 10 outstanding paged result cookies
    
    Bug: https://bugzilla.samba.org/show_bug.cgi?id=13362
    Signed-off-by: Volker Lendecke <v...@samba.org>
    Reviewed-by: Jeremy Allison <j...@samba.org>
    
    Autobuild-User(master): Jeremy Allison <j...@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 <ksee...@samba.org>
    Autobuild-Date(v4-8-test): Thu Sep 27 15:32:11 CEST 2018 on sn-devel-144

commit aa529bc41463509725322bebad7ca7841023e8c0
Author: Volker Lendecke <v...@samba.org>
Date:   Mon May 7 16:41:55 2018 +0200

    lib: Put "results_store" into a doubly linked list
    
    Bug: https://bugzilla.samba.org/show_bug.cgi?id=13362
    Signed-off-by: Volker Lendecke <v...@samba.org>
    Reviewed-by: Jeremy Allison <j...@samba.org>
    (cherry picked from commit 8063995a92fffc93aa9d6d1d92a75bf3f3c9592b)

-----------------------------------------------------------------------

Summary of changes:
 lib/ldb/modules/paged_results.c | 43 ++++++++++++++++++++++++-----------------
 1 file changed, 25 insertions(+), 18 deletions(-)


Changeset truncated at 500 lines:

diff --git a/lib/ldb/modules/paged_results.c b/lib/ldb/modules/paged_results.c
index de014a3..ecb2227 100644
--- a/lib/ldb/modules/paged_results.c
+++ b/lib/ldb/modules/paged_results.c
@@ -35,6 +35,8 @@
 #include "replace.h"
 #include "system/filesys.h"
 #include "system/time.h"
+#include "dlinklist.h"
+#include <assert.h>
 #include "ldb_module.h"
 
 struct message_store {
@@ -48,14 +50,13 @@ struct message_store {
 struct private_data;
 
 struct results_store {
+       struct results_store *prev, *next;
 
        struct private_data *priv;
 
        char *cookie;
        time_t timestamp;
 
-       struct results_store *next;
-
        struct message_store *first;
        struct message_store *last;
        int num_entries;
@@ -68,6 +69,7 @@ struct results_store {
 
 struct private_data {
        uint32_t next_free_id;
+       size_t num_stores;
        struct results_store *store;
        
 };
@@ -75,22 +77,12 @@ struct private_data {
 static int store_destructor(struct results_store *del)
 {
        struct private_data *priv = del->priv;
-       struct results_store *loop;
-
-       if (priv->store == del) {
-               priv->store = del->next;
-               return 0;
-       }
+       DLIST_REMOVE(priv->store, del);
 
-       for (loop = priv->store; loop; loop = loop->next) {
-               if (loop->next == del) {
-                       loop->next = del->next;
-                       return 0;
-               }
-       }
+       assert(priv->num_stores > 0);
+       priv->num_stores -= 1;
 
-       /* is not in list ? */
-       return -1;
+       return 0;
 }
 
 static struct results_store *new_store(struct private_data *priv)
@@ -120,11 +112,23 @@ static struct results_store *new_store(struct 
private_data *priv)
        newr->first_ref = NULL;
        newr->controls = NULL;
 
-       newr->next = priv->store;
-       priv->store = newr;
+       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;
 }
 
@@ -381,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 */
@@ -412,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);
 


-- 
Samba Shared Repository

Reply via email to