}
+/*
+ * Find the lock context of a given type
+ */
+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)
+{
+ struct lock_context *lock_ctx;
+
+ /* Search active locks */
+ for (lock_ctx=lock_list; lock_ctx; lock_ctx=lock_ctx->next) {
+ if (lock_ctx->type != type) {
+ continue;
+ }
+
+ 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) {
+ goto done;
+ }
+ break;
+
+ case LOCK_DB:
+ if (ctdb_db == lock_ctx->ctdb_db) {
+ goto done;
+ }
+ break;
+
+ case LOCK_ALLDB_PRIO:
+ if (priority == lock_ctx->priority) {
+ goto done;
+ }
+ break;
+
+ case LOCK_ALLDB:
+ goto done;
+ break;
+ }
+ }
+
+ /* Did not find the lock context we are searching for */
+ lock_ctx = NULL;
+
+done:
+ return lock_ctx;
+
+}
+
+
/*
* Schedule a new lock child process
* Set up callback handler and timeout handler
}
-/*
- * Find the lock context of a given type
- */
-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)
-{
- struct lock_context *lock_ctx;
-
- /* Search active locks */
- for (lock_ctx=lock_list; lock_ctx; lock_ctx=lock_ctx->next) {
- if (lock_ctx->type != type) {
- continue;
- }
-
- 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) {
- goto done;
- }
- break;
-
- case LOCK_DB:
- if (ctdb_db == lock_ctx->ctdb_db) {
- goto done;
- }
- break;
-
- case LOCK_ALLDB_PRIO:
- if (priority == lock_ctx->priority) {
- goto done;
- }
- break;
-
- case LOCK_ALLDB:
- goto done;
- break;
- }
- }
-
- /* Did not find the lock context we are searching for */
- lock_ctx = NULL;
-
-done:
- return lock_ctx;
-
-}
-
-
/*
* Lock record / db depending on type
*/