summaryrefslogtreecommitdiff
path: root/libmailutils
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org>2021-08-24 21:49:59 +0300
committerSergey Poznyakoff <gray@gnu.org>2021-08-24 21:49:59 +0300
commitd11a273a35ecc861e8f3aeda3c616125a0e5fbe4 (patch)
tree14b321f7347cb58601253b97363c536c21c0cafa /libmailutils
parent9571268d27b3310f7257b1683f82d5809c855eb4 (diff)
downloadmailutils-d11a273a35ecc861e8f3aeda3c616125a0e5fbe4.tar.gz
mailutils-d11a273a35ecc861e8f3aeda3c616125a0e5fbe4.tar.bz2
Intermediate streams: propagate _MU_STR_EVENT_CLRFLAG to the underlying transport
* libmailutils/stream/fltstream.c: Propagate mu_stream_clearerr to the transport stream. * libmailutils/stream/iostream.c: Likewise. * libmu_auth/tls.c: Likewise. * libmu_auth/tlsiostr.c: Likewise. * libmu_auth/tlsfdstr.c (_tlsfd_read, _tlsfd_write): Translate GNUTLS_E_TIMEDOUT to MU_ERR_TIMEOUT. * imap4d/bye.c (imap4d_bye_command): Clear stream error on ERR_TIMEOUT. ---
Diffstat (limited to 'libmailutils')
-rw-r--r--libmailutils/stream/fltstream.c13
-rw-r--r--libmailutils/stream/iostream.c18
2 files changed, 30 insertions, 1 deletions
diff --git a/libmailutils/stream/fltstream.c b/libmailutils/stream/fltstream.c
index 08ed59c63..4986982f2 100644
--- a/libmailutils/stream/fltstream.c
+++ b/libmailutils/stream/fltstream.c
@@ -648,6 +648,17 @@ filter_wait (struct _mu_stream *stream, int *pflags, struct timeval *tvp)
return mu_stream_wait (fs->transport, pflags, tvp);
}
+static void
+filter_event (struct _mu_stream *str, int code,
+ unsigned long lval, void *pval)
+{
+ struct _mu_filter_stream *fs = (struct _mu_filter_stream *)str;
+ if (code == _MU_STR_EVENT_CLRFLAG && lval == _MU_STR_ERR)
+ {
+ mu_stream_clearerr (fs->transport);
+ }
+}
+
int
mu_filter_stream_create (mu_stream_t *pflt,
@@ -705,6 +716,8 @@ mu_filter_stream_create (mu_stream_t *pflt,
fs->stream.ctl = filter_ctl;
fs->stream.wait = filter_wait;
fs->stream.error_string = filter_error_string;
+ fs->stream.event_cb = filter_event;
+ fs->stream.event_mask = _MU_STR_EVMASK (_MU_STR_EVENT_CLRFLAG);
fs->stream.flags = flags;
mu_stream_ref (str);
diff --git a/libmailutils/stream/iostream.c b/libmailutils/stream/iostream.c
index 793c2e9ea..7b9eb50ed 100644
--- a/libmailutils/stream/iostream.c
+++ b/libmailutils/stream/iostream.c
@@ -364,6 +364,20 @@ _iostream_error_string (struct _mu_stream *str, int rc)
return mu_strerror (rc);
}
+static void
+_iostream_event (struct _mu_stream *str, int code,
+ unsigned long lval, void *pval)
+{
+ struct _mu_iostream *sp = (struct _mu_iostream *)str;
+ if (code == _MU_STR_EVENT_CLRFLAG && lval == _MU_STR_ERR)
+ {
+ if (sp->transport[_MU_STREAM_INPUT])
+ mu_stream_clearerr (sp->transport[_MU_STREAM_INPUT]);
+ if (sp->transport[_MU_STREAM_OUTPUT])
+ mu_stream_clearerr (sp->transport[_MU_STREAM_OUTPUT]);
+ }
+}
+
int
mu_iostream_create (mu_stream_t *pref, mu_stream_t in, mu_stream_t out)
{
@@ -386,7 +400,9 @@ mu_iostream_create (mu_stream_t *pref, mu_stream_t in, mu_stream_t out)
sp->stream.wait = _iostream_wait;
sp->stream.shutdown = _iostream_shutdown;
sp->stream.error_string = _iostream_error_string;
-
+ sp->stream.event_cb = _iostream_event;
+ sp->stream.event_mask = _MU_STR_EVMASK (_MU_STR_EVENT_CLRFLAG);
+
mu_stream_ref (in);
sp->transport[_MU_STREAM_INPUT] = in;
mu_stream_ref (out);

Return to:

Send suggestions and report system problems to the System administrator.