[SCM] Samba Shared Repository - branch master updated

Martin Schwenke martins at samba.org
Thu Mar 27 22:29:05 MDT 2014


The branch, master has been updated
       via  f99a759 ctdb-locking: Instead of comparing key, compare key hash
       via  d1c8f8d ctdb-locking: Check for talloc_memdup error
       via  ff1c85a ctdb-locking: Avoid memory leak
      from  2e2137f smbd: Use asys_results

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


- Log -----------------------------------------------------------------
commit f99a759ce7cb5492442c018f976619f0ba439a43
Author: Amitay Isaacs <amitay at gmail.com>
Date:   Mon Mar 10 19:10:29 2014 +1100

    ctdb-locking: Instead of comparing key, compare key hash
    
    This replaces memory comparison of the key with integer comparison.
    In addition, this also avoids scheduling locks with the same hash.
    
    Signed-off-by: Amitay Isaacs <amitay at gmail.com>
    Reviewed-by: Martin Schwenke <martin at meltin.net>
    
    Autobuild-User(master): Martin Schwenke <martins at samba.org>
    Autobuild-Date(master): Fri Mar 28 05:28:58 CET 2014 on sn-devel-104

commit d1c8f8d63506c099e2ee9be7cb91f0fac4a8d848
Author: Amitay Isaacs <amitay at gmail.com>
Date:   Tue Mar 11 18:57:08 2014 +1100

    ctdb-locking: Check for talloc_memdup error
    
    Signed-off-by: Amitay Isaacs <amitay at gmail.com>
    Reviewed-by: Martin Schwenke <martin at meltin.net>

commit ff1c85ae279a87d9ce23955b02a68814f1f846f1
Author: Amitay Isaacs <amitay at gmail.com>
Date:   Tue Mar 11 18:56:22 2014 +1100

    ctdb-locking: Avoid memory leak
    
    If lock_request could not be allocated, free lock_ctx since there can
    only be a single lock_request per lock_ctx.
    
    Signed-off-by: Amitay Isaacs <amitay at gmail.com>
    Reviewed-by: Martin Schwenke <martin at meltin.net>

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

Summary of changes:
 ctdb/server/ctdb_lock.c |   16 ++++++++++++----
 1 files changed, 12 insertions(+), 4 deletions(-)


Changeset truncated at 500 lines:

diff --git a/ctdb/server/ctdb_lock.c b/ctdb/server/ctdb_lock.c
index b71fac2..339a9d2 100644
--- a/ctdb/server/ctdb_lock.c
+++ b/ctdb/server/ctdb_lock.c
@@ -79,6 +79,7 @@ struct lock_context {
 	pid_t block_child;
 	int block_fd[2];
 	struct timeval start_time;
+	uint32_t key_hash;
 };
 
 /* lock_request is the client specific part for a lock request */
@@ -672,7 +673,8 @@ static struct lock_context *find_lock_context(struct lock_context *lock_list,
 					      struct ctdb_db_context *ctdb_db,
 					      TDB_DATA key,
 					      uint32_t priority,
-					      enum lock_type type)
+					      enum lock_type type,
+					      uint32_t key_hash)
 {
 	struct lock_context *lock_ctx;
 
@@ -685,8 +687,7 @@ static struct lock_context *find_lock_context(struct lock_context *lock_list,
 		switch (lock_ctx->type) {
 		case LOCK_RECORD:
 			if (ctdb_db == lock_ctx->ctdb_db &&
-			    key.dsize == lock_ctx->key.dsize &&
-			    memcmp(key.dptr, lock_ctx->key.dptr, key.dsize) == 0) {
+			    key_hash == lock_ctx->key_hash) {
 				goto done;
 			}
 			break;
@@ -763,7 +764,7 @@ static void ctdb_lock_schedule(struct ctdb_context *ctdb)
 		} else {
 			active_ctx = find_lock_context(ctdb->lock_current, lock_ctx->ctdb_db,
 						       lock_ctx->key, lock_ctx->priority,
-						       lock_ctx->type);
+						       lock_ctx->type, lock_ctx->key_hash);
 			if (active_ctx == NULL) {
 				if (lock_ctx->ctdb_db == NULL ||
 				    lock_ctx->ctdb_db->lock_num_current < MAX_LOCK_PROCESSES_PER_DB) {
@@ -927,6 +928,12 @@ static struct lock_request *ctdb_lock_internal(struct ctdb_context *ctdb,
 		lock_ctx->key.dsize = key.dsize;
 		if (key.dsize > 0) {
 			lock_ctx->key.dptr = talloc_memdup(lock_ctx, key.dptr, key.dsize);
+			if (lock_ctx->key.dptr == NULL) {
+				DEBUG(DEBUG_ERR, (__location__ "Memory allocation error\n"));
+				talloc_free(lock_ctx);
+				return NULL;
+			}
+			lock_ctx->key_hash = ctdb_hash(&key);
 		} else {
 			lock_ctx->key.dptr = NULL;
 		}
@@ -948,6 +955,7 @@ static struct lock_request *ctdb_lock_internal(struct ctdb_context *ctdb,
 	}
 
 	if ((request = talloc_zero(lock_ctx, struct lock_request)) == NULL) {
+		talloc_free(lock_ctx);
 		return NULL;
 	}
 


-- 
Samba Shared Repository


More information about the samba-cvs mailing list