The branch, master has been updated
       via  e185ff2 ctdb-locking: Simplify ctdb_find_lock_context()
       via  9f596c1 ctdb-locking: TALLOC_FREE copes with NULL
      from  bb8e6d4 s3:smbd: pass smbXsrv_connection to smbd_[un]lock_socket()

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit e185ff22caf430f680f8bad1edf14bc98dd7c64e
Author: Volker Lendecke <v...@samba.org>
Date:   Mon Aug 4 13:57:12 2014 +0000

    ctdb-locking: Simplify ctdb_find_lock_context()
    
    I like early returns that avoid else branches :-)
    
    Signed-off-by: Volker Lendecke <v...@samba.org>
    Reviewed-by: Amitay Isaacs <ami...@gmail.com>
    
    Autobuild-User(master): Amitay Isaacs <ami...@samba.org>
    Autobuild-Date(master): Wed Aug  6 14:44:31 CEST 2014 on sn-devel-104

commit 9f596c17c7d255213df6201d4d489df1580faef4
Author: Volker Lendecke <v...@samba.org>
Date:   Mon Aug 4 12:41:06 2014 +0000

    ctdb-locking: TALLOC_FREE copes with NULL
    
    Signed-off-by: Volker Lendecke <v...@samba.org>
    Reviewed-by: Amitay Isaacs <ami...@gmail.com>

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

Summary of changes:
 ctdb/server/ctdb_lock.c |   71 ++++++++++++++++++++++------------------------
 1 files changed, 34 insertions(+), 37 deletions(-)


Changeset truncated at 500 lines:

diff --git a/ctdb/server/ctdb_lock.c b/ctdb/server/ctdb_lock.c
index a403e25..72352af 100644
--- a/ctdb/server/ctdb_lock.c
+++ b/ctdb/server/ctdb_lock.c
@@ -432,9 +432,7 @@ static void ctdb_lock_handler(struct tevent_context *ev,
        lock_ctx = talloc_get_type_abort(private_data, struct lock_context);
 
        /* cancel the timeout event */
-       if (lock_ctx->ttimer) {
-               TALLOC_FREE(lock_ctx->ttimer);
-       }
+       TALLOC_FREE(lock_ctx->ttimer);
 
        t = timeval_elapsed(&lock_ctx->start_time);
        id = lock_bucket_id(t);
@@ -666,51 +664,50 @@ struct lock_context *ctdb_find_lock_context(struct 
ctdb_context *ctdb)
        struct ctdb_db_context *ctdb_db;
 
        /* First check if there are database lock requests */
-       lock_ctx = ctdb->lock_pending;
-       while (lock_ctx != NULL) {
-               next_ctx = lock_ctx->next;
-               if (! lock_ctx->request) {
-                       DEBUG(DEBUG_INFO, ("Removing lock context without lock 
request\n"));
-                       DLIST_REMOVE(ctdb->lock_pending, lock_ctx);
-                       CTDB_DECREMENT_STAT(ctdb, locks.num_pending);
-                       if (lock_ctx->ctdb_db) {
-                               CTDB_DECREMENT_DB_STAT(lock_ctx->ctdb_db, 
locks.num_pending);
-                       }
-                       talloc_free(lock_ctx);
-               } else {
-                       /* Found a lock context with lock requests */
-                       break;
+
+       for (lock_ctx = ctdb->lock_pending; lock_ctx != NULL;
+            lock_ctx = next_ctx) {
+
+               if (lock_ctx->request != NULL) {
+                       /* Found a lock context with a request */
+                       return lock_ctx;
                }
-               lock_ctx = next_ctx;
-       }
 
-       if (lock_ctx) {
-               return lock_ctx;
+               next_ctx = lock_ctx->next;
+
+               DEBUG(DEBUG_INFO, ("Removing lock context without lock "
+                                  "request\n"));
+               DLIST_REMOVE(ctdb->lock_pending, lock_ctx);
+               CTDB_DECREMENT_STAT(ctdb, locks.num_pending);
+               if (lock_ctx->ctdb_db) {
+                       CTDB_DECREMENT_DB_STAT(lock_ctx->ctdb_db,
+                                              locks.num_pending);
+               }
+               talloc_free(lock_ctx);
        }
 
        /* Next check database queues */
        for (ctdb_db = ctdb->db_list; ctdb_db; ctdb_db = ctdb_db->next) {
-               if (ctdb_db->lock_num_current == 
ctdb->tunable.lock_processes_per_db) {
+               if (ctdb_db->lock_num_current ==
+                   ctdb->tunable.lock_processes_per_db) {
                        continue;
                }
-               lock_ctx = ctdb_db->lock_pending;
-               while (lock_ctx != NULL) {
+
+               for (lock_ctx = ctdb_db->lock_pending; lock_ctx != NULL;
+                    lock_ctx = next_ctx) {
+
                        next_ctx = lock_ctx->next;
-                       if (! lock_ctx->request) {
-                               DEBUG(DEBUG_INFO, ("Removing lock context 
without lock request\n"));
-                               DLIST_REMOVE(ctdb_db->lock_pending, lock_ctx);
-                               CTDB_DECREMENT_STAT(ctdb, locks.num_pending);
-                               CTDB_DECREMENT_DB_STAT(ctdb_db, 
locks.num_pending);
-                               talloc_free(lock_ctx);
-                       } else {
-                               break;
-                       }
 
-                       lock_ctx = next_ctx;
-               }
+                       if (lock_ctx->request != NULL) {
+                               return lock_ctx;
+                       }
 
-               if (lock_ctx) {
-                       return lock_ctx;
+                       DEBUG(DEBUG_INFO, ("Removing lock context without "
+                                          "lock request\n"));
+                       DLIST_REMOVE(ctdb_db->lock_pending, lock_ctx);
+                       CTDB_DECREMENT_STAT(ctdb, locks.num_pending);
+                       CTDB_DECREMENT_DB_STAT(ctdb_db, locks.num_pending);
+                       talloc_free(lock_ctx);
                }
        }
 


-- 
Samba Shared Repository

Reply via email to