mirror of
https://github.com/fluencelabs/musl
synced 2025-06-13 23:11:51 +00:00
optimize file locking: avoid cache-polluting writes to global storage
This commit is contained in:
@ -3,7 +3,9 @@
|
|||||||
|
|
||||||
void flockfile(FILE *f)
|
void flockfile(FILE *f)
|
||||||
{
|
{
|
||||||
|
if (!libc.lockfile) {
|
||||||
pthread_self();
|
pthread_self();
|
||||||
libc.lockfile = __lockfile;
|
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;
|
||||||
|
Reference in New Issue
Block a user