• Colin Walters's avatar
    gthread: Rework to avoid holding a mutex half the time · 630fa82e
    Colin Walters authored
    This code was a persistent source of `-fsanitize=thread` errors
    when I was trying to use it on OSTree.
    The problem is that while I think this code is functionally correct,
    we hold a mutex during the writes, but not the reads, and TSAN (IMO
    correctly) flags that.
    Reading this, I don't see a reason we need a mutex at all.  At the
    cost of some small code duplication between posix/win32, we can just
    pass the data we need down into each implementation.  This ends up
    being notably cleaner I think than the awkward "lock/unlock to
    serialize" dance.
    (Minor review changes made by Philip Withnall <withnall@endlessm.com>.)
gthreadprivate.h 2.5 KB