correct locking in stdio functions that tried to be lock-free
[musl] / src / stdio / flockfile.c
index 1b6ef58..a196c1e 100644 (file)
@@ -3,7 +3,8 @@
 
 void flockfile(FILE *f)
 {
-       pthread_self();
-       libc.lockfile = __lockfile;
-       __lockfile(f);
+       while (ftrylockfile(f)) {
+               int owner = f->lock;
+               if (owner) __wait(&f->lock, &f->waiters, owner, 1);
+       }
 }