From: Andrew Tridgell Date: Tue, 17 Apr 2007 01:20:00 +0000 (+1000) Subject: better error handling in ctdb_ltdb_lock_fetch_requeue() X-Git-Tag: tevent-0.9.20~348^2~2910 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=3fc279760c82b4df070e3a16893824e66a6cc7ca;p=thirdparty%2Fsamba.git better error handling in ctdb_ltdb_lock_fetch_requeue() (This used to be ctdb commit 1952be19f625dbe257050acebf468e7e6eb0da8c) --- diff --git a/ctdb/common/ctdb_ltdb.c b/ctdb/common/ctdb_ltdb.c index 132108e69b1..c523d5f9952 100644 --- a/ctdb/common/ctdb_ltdb.c +++ b/ctdb/common/ctdb_ltdb.c @@ -244,6 +244,12 @@ static void lock_fetch_callback(void *p) immediately satisfied until it can get the lock. This means that the main ctdb daemon will not block waiting for a chainlock held by a client + + There are 3 possible return values: + + 0: means that it got the lock immediately. + -1: means that it failed to get the lock, and won't retry + -2: means that it failed to get the lock immediately, but will retry */ int ctdb_ltdb_lock_fetch_requeue(struct ctdb_db_context *ctdb_db, TDB_DATA key, struct ctdb_ltdb_header *header, @@ -255,6 +261,12 @@ int ctdb_ltdb_lock_fetch_requeue(struct ctdb_db_context *ctdb_db, ret = tdb_chainlock_nonblock(tdb, key); + if (ret != 0 && + !(errno == EACCES || errno == EAGAIN || errno == EDEADLK)) { + /* a hard failure - don't try again */ + return -1; + } + /* first the non-contended path */ if (ret == 0) { ret = ctdb_ltdb_fetch(ctdb_db, key, header, hdr, data); @@ -273,6 +285,11 @@ int ctdb_ltdb_lock_fetch_requeue(struct ctdb_db_context *ctdb_db, /* we get an extra reference to the packet here, to stop it being freed in the top level packet handler */ - (void)talloc_reference(ctdb_db, hdr); - return 0; + if (talloc_reference(ctdb_db, hdr) == NULL) { + talloc_free(h); + return -1; + } + + /* now tell the caller than we will retry asynchronously */ + return -2; }