mirror of
git://git.gnupg.org/gnupg.git
synced 2025-07-03 22:56:33 +02:00
Avoid double-close in unusual dotlock situations.
* jnlib/dotlock.c (create_dotlock): Avoid double close due to EINTR.
--
close(2) says:
close() should not be retried after an EINTR since this may cause a
reused descriptor from another thread to be closed.
(backported from commit 628b111fa6
)
Debian-Bug-Id: 773423
Signed-off-by: Werner Koch <wk@gnupg.org>
This commit is contained in:
parent
b2359db21c
commit
f256bab03e
1 changed files with 32 additions and 26 deletions
|
@ -244,7 +244,12 @@ create_dotlock (const char *file_to_lock)
|
||||||
if ( write (fd, "\n", 1 ) != 1 )
|
if ( write (fd, "\n", 1 ) != 1 )
|
||||||
goto write_failed;
|
goto write_failed;
|
||||||
if ( close (fd) )
|
if ( close (fd) )
|
||||||
|
{
|
||||||
|
if ( errno == EINTR )
|
||||||
|
fd = -1;
|
||||||
goto write_failed;
|
goto write_failed;
|
||||||
|
}
|
||||||
|
fd = -1;
|
||||||
|
|
||||||
# ifdef _REENTRANT
|
# ifdef _REENTRANT
|
||||||
/* release mutex */
|
/* release mutex */
|
||||||
|
@ -267,6 +272,7 @@ create_dotlock (const char *file_to_lock)
|
||||||
/* fixme: release mutex */
|
/* fixme: release mutex */
|
||||||
# endif
|
# endif
|
||||||
log_error ( _("error writing to `%s': %s\n"), h->tname, strerror(errno) );
|
log_error ( _("error writing to `%s': %s\n"), h->tname, strerror(errno) );
|
||||||
|
if (fd != -1)
|
||||||
close (fd);
|
close (fd);
|
||||||
unlink (h->tname);
|
unlink (h->tname);
|
||||||
jnlib_free (h->tname);
|
jnlib_free (h->tname);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue