summaryrefslogtreecommitdiff
path: root/src/stdio/ftrylockfile.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/stdio/ftrylockfile.c')
-rw-r--r--src/stdio/ftrylockfile.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/stdio/ftrylockfile.c b/src/stdio/ftrylockfile.c
index 0b0e44aa..725c4c3e 100644
--- a/src/stdio/ftrylockfile.c
+++ b/src/stdio/ftrylockfile.c
@@ -5,11 +5,12 @@ int ftrylockfile(FILE *f)
{
int tid = pthread_self()->tid;
if (f->lock == tid) {
- if (f->lockcount == INT_MAX)
+ if (f->lockcount == LONG_MAX)
return -1;
f->lockcount++;
return 0;
}
+ if (f->lock < 0) f->lock = 0;
if (f->lock || a_cas(&f->lock, 0, tid))
return -1;
f->lockcount = 1;