~ubuntu-branches/debian/jessie/ldb/jessie

« back to all changes in this revision

Viewing changes to lib/tdb_compat/tdb_compat.c

  • Committer: Package Import Robot
  • Author(s): Jelmer Vernooij
  • Date: 2012-04-19 15:00:14 UTC
  • mfrom: (1.3.13)
  • Revision ID: package-import@ubuntu.com-20120419150014-g3pyg7snztb4zyt8
Tags: 1:1.1.6-1
New upstream release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
38
38
        return ecode;
39
39
}
40
40
 
 
41
enum TDB_ERROR tdb_chainlock_nonblock(struct tdb_context *tdb, TDB_DATA key)
 
42
{
 
43
        union tdb_attribute locking, orig;
 
44
        enum TDB_ERROR ecode;
 
45
 
 
46
        orig.base.attr = TDB_ATTRIBUTE_FLOCK;
 
47
        ecode = tdb_get_attribute(tdb, &orig);
 
48
        if (ecode != TDB_SUCCESS)
 
49
                return ecode;
 
50
 
 
51
        /* Replace locking function with our own. */
 
52
        locking = orig;
 
53
        locking.flock.data = &orig;
 
54
        locking.flock.lock = lock_nonblock;
 
55
 
 
56
        ecode = tdb_set_attribute(tdb, &locking);
 
57
        if (ecode != TDB_SUCCESS)
 
58
                return ecode;
 
59
 
 
60
        ecode = tdb_chainlock(tdb, key);
 
61
        tdb_unset_attribute(tdb, TDB_ATTRIBUTE_FLOCK);
 
62
        return ecode;
 
63
}
 
64
 
41
65
/* For TDB1 tdbs, read traverse vs normal matters: write traverse
42
66
   locks the entire thing! */
43
67
int64_t tdb_traverse_read_(struct tdb_context *tdb,