projects
/
oweals
/
musl.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
add and consolidate nasty stdio_ext junk
[oweals/musl.git]
/
src
/
stdio
/
ftrylockfile.c
diff --git
a/src/stdio/ftrylockfile.c
b/src/stdio/ftrylockfile.c
index 1d0a1ff8662baad6ce8593348c4179530b70ca4e..0b0e44aaf4fb6d7da1922b44e80b0926870376d1 100644
(file)
--- a/
src/stdio/ftrylockfile.c
+++ b/
src/stdio/ftrylockfile.c
@@
-3,16
+3,15
@@
int ftrylockfile(FILE *f)
{
int ftrylockfile(FILE *f)
{
- i
f (!libc.lockfile) libc.lockfile = __lockfile
;
- if (f->
owner && f->owner == pthread_self()->
tid) {
+ i
nt tid = pthread_self()->tid
;
+ if (f->
lock ==
tid) {
if (f->lockcount == INT_MAX)
return -1;
f->lockcount++;
return 0;
}
if (f->lockcount == INT_MAX)
return -1;
f->lockcount++;
return 0;
}
- if (
a_swap(&f->lock, 1
))
+ if (
f->lock || a_cas(&f->lock, 0, tid
))
return -1;
return -1;
- f->owner = pthread_self()->tid;
f->lockcount = 1;
return 0;
}
f->lockcount = 1;
return 0;
}