mirror of
git://git.musl-libc.org/musl
synced 2025-03-06 20:48:29 +01:00
optimize file locking: avoid cache-polluting writes to global storage
This commit is contained in:
parent
9dd7d7e3f6
commit
4d9cc0b399
2 changed files with 5 additions and 3 deletions
|
@ -3,7 +3,9 @@
|
||||||
|
|
||||||
void flockfile(FILE *f)
|
void flockfile(FILE *f)
|
||||||
{
|
{
|
||||||
pthread_self();
|
if (!libc.lockfile) {
|
||||||
libc.lockfile = __lockfile;
|
pthread_self();
|
||||||
|
libc.lockfile = __lockfile;
|
||||||
|
}
|
||||||
__lockfile(f);
|
__lockfile(f);
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
|
|
||||||
int ftrylockfile(FILE *f)
|
int ftrylockfile(FILE *f)
|
||||||
{
|
{
|
||||||
libc.lockfile = __lockfile;
|
if (!libc.lockfile) libc.lockfile = __lockfile;
|
||||||
if (f->owner && f->owner == pthread_self()->tid) {
|
if (f->owner && f->owner == pthread_self()->tid) {
|
||||||
if (f->lockcount == INT_MAX)
|
if (f->lockcount == INT_MAX)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
Loading…
Add table
Reference in a new issue