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

simo idra at samba.org
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?

No.

> 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
omitted:

        /* 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->num_locks++;

        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.

-- 
Simo Sorce
Samba Team GPL Compliance Officer <simo at samba.org>
Principal Software Engineer at Red Hat, Inc. <simo at redhat.com>



More information about the samba-technical mailing list