X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;ds=sidebyside;f=src%2Fstdio%2Fflockfile.c;h=8e2206514c67db4bd05aef79484ad110a07170ed;hb=59b64ff686cef2a87e9552658b2c8d2531f87176;hp=6b574cf0905f8ac4bd58458c2730d5e79b739634;hpb=c21f750727515602a9e84f2a190ee8a0a2aeb2a1;p=musl diff --git a/src/stdio/flockfile.c b/src/stdio/flockfile.c index 6b574cf0..8e220651 100644 --- a/src/stdio/flockfile.c +++ b/src/stdio/flockfile.c @@ -1,14 +1,9 @@ #include "stdio_impl.h" #include "pthread_impl.h" -#define MAYBE_WAITERS 0x40000000 - void flockfile(FILE *f) { - while (ftrylockfile(f)) { - int owner = f->lock; - if (!owner) continue; - a_cas(&f->lock, owner, owner|MAYBE_WAITERS); - __futexwait(&f->lock, owner|MAYBE_WAITERS, 1); - } + if (!ftrylockfile(f)) return; + __lockfile(f); + __register_locked_file(f, __pthread_self()); }