summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWerner Koch <wk@gnupg.org>2015-09-28 17:41:33 +0200
committerWerner Koch <wk@gnupg.org>2015-09-28 17:41:33 +0200
commitc09997bc50f3fffaf76d60d2e571b1d85536571e (patch)
tree38d6e6a25a4eb850c7d8e476c5b6c813eba3b77b
parentd3e9514ff82ff767fc78ce485aef71ba56f3c0d5 (diff)
downloadlibgpg-error-c09997bc50f3fffaf76d60d2e571b1d85536571e.tar.gz
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@gnupg.org>
-rw-r--r--src/estream.c29
1 files 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;