fix bug in dladdr that prevented resolving addresses in the PLT
[oweals/musl.git] / src / stdio / flockfile.c
index 440a36a9aecb9bfb1a08907d2c91ab9513da19e5..a196c1efe0af11663f5e0537a0de1db02c3982ef 100644 (file)
@@ -3,9 +3,8 @@
 
 void flockfile(FILE *f)
 {
-       if (!libc.lockfile) {
-               pthread_self();
-               libc.lockfile = __lockfile;
+       while (ftrylockfile(f)) {
+               int owner = f->lock;
+               if (owner) __wait(&f->lock, &f->waiters, owner, 1);
        }
-       __lockfile(f);
 }