correct locking in stdio functions that tried to be lock-free
[musl] / src / stdio / fileno.c
index 9ffb26d..ba7f939 100644 (file)
@@ -2,6 +2,11 @@
 
 int fileno(FILE *f)
 {
+       /* f->fd never changes, but the lock must be obtained and released
+        * anyway since this function cannot return while another thread
+        * holds the lock. */
+       FLOCK(f);
+       FUNLOCK(f);
        return f->fd;
 }