diff options
author | Jeremy Allison <jra@samba.org> | 2000-12-07 17:46:11 +0000 |
---|---|---|
committer | Jeremy Allison <jra@samba.org> | 2000-12-07 17:46:11 +0000 |
commit | 0d658c35eb9d8ec400ad0302ee11d489bb59bd77 (patch) | |
tree | 376abfc6819522969a926a5a8d91f0f7c2b693a8 /source3/tdb/tdb.c | |
parent | c31211167bc2b98f51f8f3cc70bb410250b427aa (diff) | |
download | samba-0d658c35eb9d8ec400ad0302ee11d489bb59bd77.tar.gz samba-0d658c35eb9d8ec400ad0302ee11d489bb59bd77.tar.bz2 samba-0d658c35eb9d8ec400ad0302ee11d489bb59bd77.zip |
Fixed bug with tdb_next_lock failing when reaching then end of a hashchain
and the next hashchain is empty.
Jeremy
(This used to be commit f3b5e2a172a777e1c3bbf6ac72fe5c7cdb8324b3)
Diffstat (limited to 'source3/tdb/tdb.c')
-rw-r--r-- | source3/tdb/tdb.c | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/source3/tdb/tdb.c b/source3/tdb/tdb.c index 1e66fe1419..20f51402dc 100644 --- a/source3/tdb/tdb.c +++ b/source3/tdb/tdb.c @@ -776,9 +776,8 @@ static int tdb_next_lock(TDB_CONTEXT *tdb, struct tdb_traverse_lock *tlock, struct list_struct *rec) { tdb_off next; - int first = (tlock->off == 0); - /* No traversal allows if you've called tdb_lockkeys() */ + /* No traversal allows sf you've called tdb_lockkeys() */ if (tdb->lockedkeys) return TDB_ERRCODE(TDB_ERR_NOLOCK, -1); /* Lock each chain from the start one. */ @@ -791,15 +790,17 @@ static int tdb_next_lock(TDB_CONTEXT *tdb, struct tdb_traverse_lock *tlock, &tlock->off) == -1) goto fail; } else { - /* Othereisre unlock the previous record. */ - unlock_record(tdb, tlock->off); - } - if (!first) { - /* Grab next record */ - if (rec_read(tdb, tlock->off, rec) == -1) goto fail; + /* Get a copy of previous record, to go to next. */ + if (rec_read(tdb, tlock->off, rec) == -1) { + unlock_record(tdb, tlock->off); + goto fail; + } + tlock->off = rec->next; - first = 0; + + /* Now unlock the previous record. */ + unlock_record(tdb, tlock->off); } /* Iterate through chain */ |