Am I going mad or does TDB allow multiple writers to update the freelist?

simo idra at
Tue Jan 20 22:17:02 GMT 2009

On Tue, 2009-01-20 at 13:52 -0800, Richard Sharpe wrote:
> Am I reading this correctly?


> Are we allowing another process to take
> the free list lock when it is already locked?

No, this code can happen only within the same process.
The first lock is always taken for real, see the following code you

        /* Since fcntl locks don't nest, we do a lock for the first one,
           and simply bump the count for future ones */
        if (!mark_lock &&
            tdb->methods->tdb_brlock(tdb,FREELIST_TOP+4*list, ltype, op,
                                     0, 1)) {
                return -1;


        tdb->lockrecs[tdb->num_lockrecs].list = list;
        tdb->lockrecs[tdb->num_lockrecs].count = 1;
        tdb->lockrecs[tdb->num_lockrecs].ltype = ltype;
        tdb->num_lockrecs += 1;

> Surely I have missed
> something here.

Read the rest of the function? :-)

Although this means that tdb is not thread safe.


Simo Sorce
Samba Team GPL Compliance Officer <simo at>
Principal Software Engineer at Red Hat, Inc. <simo at>

More information about the samba-technical mailing list