diff options
author | Amitay Isaacs <amitay@gmail.com> | 2013-11-07 15:54:20 +1100 |
---|---|---|
committer | Amitay Isaacs <amitay@gmail.com> | 2013-11-07 16:08:17 +1100 |
commit | 537d4abc113883e0d361a1a907d09e771b7d7987 (patch) | |
tree | cf5fb15c137ca8181b0a1567b3cfcb4caef0de62 | |
parent | ab5908777591b9df819439ad213f0a36fc5afcd3 (diff) | |
download | samba-537d4abc113883e0d361a1a907d09e771b7d7987.tar.gz samba-537d4abc113883e0d361a1a907d09e771b7d7987.tar.xz samba-537d4abc113883e0d361a1a907d09e771b7d7987.zip |
client: Make g_lock_lock() wait till lock is obtained
This makes the behaviour of g_lock_lock() similar to that implemented in
Samba. Now ctdb_transaction_start() will return NULL only when there are
failures and not when another transaction is active.
Signed-off-by: Amitay Isaacs <amitay@gmail.com>
(This used to be ctdb commit 59489019ad15a5ad6b0f295e742fc9832745a842)
-rw-r--r-- | ctdb/client/ctdb_client.c | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/ctdb/client/ctdb_client.c b/ctdb/client/ctdb_client.c index 6ccc4c906aa..fddbd02b628 100644 --- a/ctdb/client/ctdb_client.c +++ b/ctdb/client/ctdb_client.c @@ -3856,10 +3856,20 @@ static bool g_lock_lock(TALLOC_CTX *mem_ctx, struct ctdb_record_handle *h; struct g_lock_recs *locks; struct server_id id; + struct timeval t_start; int i; key.dptr = (uint8_t *)discard_const(keyname); key.dsize = strlen(keyname) + 1; + + t_start = timeval_current(); + +again: + /* Keep trying for an hour. */ + if (timeval_elapsed(&t_start) > 3600) { + return false; + } + h = ctdb_fetch_lock(ctdb_db, mem_ctx, key, &data); if (h == NULL) { return false; @@ -3899,7 +3909,7 @@ static bool g_lock_lock(TALLOC_CTX *mem_ctx, id.task_id, id.vnn, (unsigned long long)id.unique_id)); talloc_free(h); - return false; + goto again; } locks->lock = talloc_realloc(locks, locks->lock, struct g_lock_rec, |