optimize file locking: avoid cache-polluting writes to global storage

This commit is contained in:
Rich Felker 2011-03-16 10:39:45 -04:00
parent 9dd7d7e3f6
commit 4d9cc0b399
2 changed files with 5 additions and 3 deletions

View File

@ -3,7 +3,9 @@
void flockfile(FILE *f)
{
pthread_self();
libc.lockfile = __lockfile;
if (!libc.lockfile) {
pthread_self();
libc.lockfile = __lockfile;
}
__lockfile(f);
}

View 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;