[Pkg-gnupg-commit] [libgpg-error] 06/19: estream: Keep track of EPIPE.
Daniel Kahn Gillmor
dkg at fifthhorseman.net
Tue Dec 15 15:55:26 UTC 2015
This is an automated email from the git hooks/post-receive script.
dkg pushed a commit to branch master
in repository libgpg-error.
commit c09997bc50f3fffaf76d60d2e571b1d85536571e
Author: Werner Koch <wk at gnupg.org>
Date: Mon Sep 28 17:41:33 2015 +0200
estream: Keep track of EPIPE.
* src/estream.c (_gpgrt_stream_internal): Add indicators.hup.
(init_stream_obj): Init it.
(es_fill, es_flush, es_seek): Set that.
(_gpgrt_poll): Set event.
Signed-off-by: Werner Koch <wk at gnupg.org>
---
src/estream.c | 29 +++++++++++++++++++++++++----
1 file changed, 25 insertions(+), 4 deletions(-)
diff --git a/src/estream.c b/src/estream.c
index 58f069c..21694a3 100644
--- a/src/estream.c
+++ b/src/estream.c
@@ -195,6 +195,7 @@ struct _gpgrt_stream_internal
{
unsigned int err: 1;
unsigned int eof: 1;
+ unsigned int hup: 1;
} indicators;
unsigned int deallocate_buffer: 1;
unsigned int is_stdstream:1; /* This is a standard stream. */
@@ -1713,7 +1714,11 @@ es_fill (estream_t stream)
if (err)
{
if (errno != EAGAIN)
- stream->intern->indicators.err = 1;
+ {
+ if (errno == EPIPE)
+ stream->intern->indicators.hup = 1;
+ stream->intern->indicators.err = 1;
+ }
}
else if (!bytes_read)
stream->intern->indicators.eof = 1;
@@ -1793,8 +1798,12 @@ es_flush (estream_t stream)
out:
- if (err)
- stream->intern->indicators.err = 1;
+ if (err && errno != EAGAIN)
+ {
+ if (errno == EPIPE)
+ stream->intern->indicators.hup = 1;
+ stream->intern->indicators.err = 1;
+ }
return err;
}
@@ -1829,6 +1838,7 @@ init_stream_obj (estream_t stream,
stream->intern->print_ntotal = 0;
stream->intern->indicators.err = 0;
stream->intern->indicators.eof = 0;
+ stream->intern->indicators.hup = 0;
stream->intern->is_stdstream = 0;
stream->intern->stdstream_fd = 0;
stream->intern->deallocate_buffer = 0;
@@ -2310,7 +2320,11 @@ es_seek (estream_t _GPGRT__RESTRICT stream, gpgrt_off_t offset, int whence,
out:
if (err)
- stream->intern->indicators.err = 1;
+ {
+ if (errno == EPIPE)
+ stream->intern->indicators.hup = 1;
+ stream->intern->indicators.err = 1;
+ }
return err;
}
@@ -3624,6 +3638,8 @@ _gpgrt_clearerr_unlocked (estream_t stream)
{
stream->intern->indicators.eof = 0;
stream->intern->indicators.err = 0;
+ /* We do not reset the HUP indicator because there is no way to
+ get out of this state. */
}
@@ -4609,6 +4625,11 @@ _gpgrt_poll (gpgrt_poll_t *fds, unsigned int nfds, int timeout)
}
any = 0;
+ if (item->stream->intern->indicators.hup)
+ {
+ item->got_hup = 1;
+ any = 1;
+ }
if (item->want_read && FD_ISSET (fd, &readfds))
{
item->got_read = 1;
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-gnupg/libgpg-error.git
More information about the Pkg-gnupg-commit
mailing list