diff options
author | Andrew Tridgell <tridge@samba.org> | 2007-04-17 11:20:00 +1000 |
---|---|---|
committer | Andrew Tridgell <tridge@samba.org> | 2007-04-17 11:20:00 +1000 |
commit | 3fc279760c82b4df070e3a16893824e66a6cc7ca (patch) | |
tree | 4a79fbaf0f7270629049955338bccc3ac790b5da | |
parent | 71bf837a1939f765419359a6bca5996d54fc662a (diff) | |
download | samba-3fc279760c82b4df070e3a16893824e66a6cc7ca.tar.gz samba-3fc279760c82b4df070e3a16893824e66a6cc7ca.tar.xz samba-3fc279760c82b4df070e3a16893824e66a6cc7ca.zip |
better error handling in ctdb_ltdb_lock_fetch_requeue()
(This used to be ctdb commit 1952be19f625dbe257050acebf468e7e6eb0da8c)
-rw-r--r-- | ctdb/common/ctdb_ltdb.c | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/ctdb/common/ctdb_ltdb.c b/ctdb/common/ctdb_ltdb.c index 132108e69b..c523d5f995 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; } |