tdb: fix ecode setting on nonblocking brlock
authorRusty Russell <rusty@rustcorp.com.au>
Wed, 19 Aug 2009 01:19:29 +0000 (10:49 +0930)
committerRusty Russell <rusty@rustcorp.com.au>
Wed, 19 Aug 2009 01:19:29 +0000 (10:49 +0930)
This bug was introduced in "Wean off TDB_ERRCODE.".

ccan/tdb/lock.c

index 41c383822433c654a441b0bca065b769bb494e3f..664081932c70e1ad42fd1df762e249f94ff2ed92 100644 (file)
@@ -158,12 +158,11 @@ int tdb_brlock(struct tdb_context *tdb,
        } while (ret == -1 && errno == EINTR);
 
        if (ret == -1) {
+               tdb->ecode = TDB_ERR_LOCK;
                /* Generic lock error. errno set by fcntl.
                 * EAGAIN is an expected return from non-blocking
                 * locks. */
                if (!(flags & TDB_LOCK_PROBE) && errno != EAGAIN) {
-                       /* Ensure error code is set for log fun to examine. */
-                       tdb->ecode = TDB_ERR_LOCK;
                        TDB_LOG((tdb, TDB_DEBUG_TRACE,"tdb_brlock failed (fd=%d) at offset %d rw_type=%d flags=%d len=%d\n", 
                                 tdb->fd, offset, rw_type, flags, (int)len));
                }