idmap_tdb2: fix a race condition in idmap_tdb2_allocate_id().
authorMichael Adam <obnox@samba.org>
Tue, 5 Aug 2008 20:38:44 +0000 (22:38 +0200)
committerMichael Adam <obnox@samba.org>
Tue, 5 Aug 2008 21:43:53 +0000 (23:43 +0200)
commit72bd83fea7572a6202027b200d192c05023aa633
tree65c759d5a50d65284ad82b3f1f65c4a092520069
parent103ce6c9e94ce74e616fe922f2584fd46ae1f3f8
idmap_tdb2: fix a race condition in idmap_tdb2_allocate_id().

The race is a regression introduced by the change to dbwrap.
It might have led to two concurrent processes returning the same id.

This fix is achieved by changing dbwrap_change_uint32_atomic() to
match the original behaviour of tdb_change_uint32_atomic(), which
is the following: *oldval is used as initial value when
the value does not yet exist and that the old value should be
returned in *oldval.

dbwrap_change_uint32_atomic() is used (only) in idmap_tdb2.c,
to get new ids.

Michael
source/lib/dbwrap_util.c