Am I going mad or does TDB allow multiple writers to update the
freelist?
Richard Sharpe
realrichardsharpe at gmail.com
Tue Jan 20 22:29:25 GMT 2009
On 1/20/09, simo <idra at samba.org> wrote:
> 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:
OK, now I understand, I think. I assumed that the tdb control
structure was part of the mmaped memory and that they were both
looking at the same memory.
Hmmm, have to look harder for the tdb freelist corruption I have found, then.
> /* 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>
>
>
--
Regards,
Richard Sharpe
More information about the samba-technical
mailing list