optimize file locking: avoid cache-polluting writes to global storage
[musl] / src / stdio / ftrylockfile.c
index 725b66e..1d0a1ff 100644 (file)
@@ -3,7 +3,7 @@
 
 int ftrylockfile(FILE *f)
 {
-       libc.lockfile = __lockfile;
+       if (!libc.lockfile) libc.lockfile = __lockfile;
        if (f->owner && f->owner == pthread_self()->tid) {
                if (f->lockcount == INT_MAX)
                        return -1;