trylock_stream has a bug, it seems that it never works correctly.
Description
Description
Revisions and Commits
Revisions and Commits
| rE libgpg-error | |||
| rE0a82a34bb723 Fix gpgrt_ftrylockfile. | |||
| Status | Assigned | Task | ||
|---|---|---|---|---|
| Open | None | T8518 gpg: Hang on exit after trustdb error, when keyboxd is in use | ||
| Testing | • gniibe | T8519 trylock_stream bug (exposed as gpgrt_ftrylockfile) |
Event Timeline
Comment Actions
Internally, _gpgrt_lock_trylock returns an error code on error, 0 when success.
It seems that trylock_stream (and thus gpgrt_ftrylockfile) should return -1 on error, 0 when success.
Here is a patch:
diff --git a/src/estream.c b/src/estream.c index ba345ff..301a078 100644 --- a/src/estream.c +++ b/src/estream.c @@ -476,7 +476,7 @@ trylock_stream (estream_t _GPGRT__RESTRICT stream) if (!stream->intern->samethread) { dbg_lock_1 ("enter trylock_stream for %p\n", stream); - rc = _gpgrt_lock_trylock (&stream->intern->lock)? 0 : -1; + rc = _gpgrt_lock_trylock (&stream->intern->lock)? -1 : 0; dbg_lock_2 ("leave trylock_stream for %p: rc=%d\n", stream, rc); } else
Comment Actions
Right, it should have the same semantics as flockfile:
RETURN VALUE
The ftrylockfile() function returns zero for success (the lock was obtained), and nonzero for failure.