avoid setting FILE lock count when not using flockfile
authorRich Felker <dalias@aerifal.cx>
Thu, 22 Sep 2011 01:30:45 +0000 (21:30 -0400)
committerRich Felker <dalias@aerifal.cx>
Thu, 22 Sep 2011 01:30:45 +0000 (21:30 -0400)
for now this is just a tiny optimization, but later if we support
cancellation from __stdio_read and __stdio_write, it will be necessary
for the recusrive lock count to be zero in order for these functions
to know they are responsible for unlocking the FILE on cancellation.

src/stdio/__lockfile.c

index 6ebf620..3bf3c26 100644 (file)
@@ -8,7 +8,7 @@ int __lockfile(FILE *f)
                return 0;
        while ((owner = a_cas(&f->lock, 0, tid)))
                __wait(&f->lock, &f->waiters, owner, 1);
                return 0;
        while ((owner = a_cas(&f->lock, 0, tid)))
                __wait(&f->lock, &f->waiters, owner, 1);
-       return f->lockcount = 1;
+       return 1;
 }
 
 void __unlockfile(FILE *f)
 }
 
 void __unlockfile(FILE *f)