dovecot-2.2: lib: ostream.stream_errno is now exactly the same a...
dovecot at dovecot.org
dovecot at dovecot.org
Thu Nov 13 08:10:53 UTC 2014
details: http://hg.dovecot.org/dovecot-2.2/rev/4d8a52f5839a
changeset: 18080:4d8a52f5839a
user: Timo Sirainen <tss at iki.fi>
date: Thu Nov 13 10:09:28 2014 +0200
description:
lib: ostream.stream_errno is now exactly the same as last_failed_errno.
There's a lot of code that checks only for stream_errno instead of
last_failed_errno at the flush time where the stream_errno might have
already been cleared.
I'm not sure why these were separated in the first place. I don't think
there are any stream errors which just correctly go away by retrying the
operation. Perhaps some code could have attempted seeking and try to handle
the ESPIPE error, but that kind of code paths are rare and they could clear
the errors themselves if needed.
diffstat:
src/lib/ostream.c | 33 +++++++++++----------------------
1 files changed, 11 insertions(+), 22 deletions(-)
diffs (133 lines):
diff -r 24d2d52d5355 -r 4d8a52f5839a src/lib/ostream.c
--- a/src/lib/ostream.c Thu Nov 13 10:01:37 2014 +0200
+++ b/src/lib/ostream.c Thu Nov 13 10:09:28 2014 +0200
@@ -125,7 +125,7 @@
{
struct ostream_private *_stream = stream->real_stream;
- if (unlikely(stream->closed))
+ if (unlikely(stream->closed || stream->stream_errno != 0))
return;
_stream->cork(_stream, TRUE);
@@ -135,10 +135,9 @@
{
struct ostream_private *_stream = stream->real_stream;
- if (unlikely(stream->closed))
+ if (unlikely(stream->closed || stream->stream_errno != 0))
return;
- stream->stream_errno = 0;
_stream->cork(_stream, FALSE);
if (stream->stream_errno != 0)
errno = stream->last_failed_errno = stream->stream_errno;
@@ -151,23 +150,16 @@
return _stream->corked;
}
-static void o_stream_clear_error(struct ostream *stream)
-{
- stream->stream_errno = 0;
- i_free_and_null(stream->real_stream->iostream.error);
-}
-
int o_stream_flush(struct ostream *stream)
{
struct ostream_private *_stream = stream->real_stream;
int ret = 1;
- if (unlikely(stream->closed)) {
+ if (unlikely(stream->closed || stream->stream_errno != 0)) {
errno = stream->stream_errno;
return -1;
}
- o_stream_clear_error(stream);
if (unlikely((ret = _stream->flush(_stream)) < 0)) {
i_assert(stream->stream_errno != 0);
stream->last_failed_errno = stream->stream_errno;
@@ -180,7 +172,7 @@
{
struct ostream_private *_stream = stream->real_stream;
- if (unlikely(stream->closed))
+ if (unlikely(stream->closed || stream->stream_errno != 0))
return;
_stream->flush_pending(_stream, set);
@@ -205,12 +197,11 @@
{
struct ostream_private *_stream = stream->real_stream;
- if (unlikely(stream->closed)) {
+ if (unlikely(stream->closed || stream->stream_errno != 0)) {
errno = stream->stream_errno;
return -1;
}
- o_stream_clear_error(stream);
if (unlikely(_stream->seek(_stream, offset) < 0)) {
i_assert(stream->stream_errno != 0);
stream->last_failed_errno = stream->stream_errno;
@@ -239,12 +230,11 @@
size_t total_size;
ssize_t ret;
- if (unlikely(stream->closed)) {
+ if (unlikely(stream->closed || stream->stream_errno != 0)) {
errno = stream->stream_errno;
return -1;
}
- o_stream_clear_error(stream);
for (i = 0, total_size = 0; i < iov_count; i++)
total_size += iov[i].iov_len;
if (total_size == 0)
@@ -282,7 +272,7 @@
void o_stream_nsendv(struct ostream *stream, const struct const_iovec *iov,
unsigned int iov_count)
{
- if (unlikely(stream->closed))
+ if (unlikely(stream->closed || stream->stream_errno != 0))
return;
(void)o_stream_sendv(stream, iov, iov_count);
stream->real_stream->last_errors_not_checked = TRUE;
@@ -295,7 +285,7 @@
void o_stream_nflush(struct ostream *stream)
{
- if (unlikely(stream->closed))
+ if (unlikely(stream->closed || stream->stream_errno != 0))
return;
(void)o_stream_flush(stream);
stream->real_stream->last_errors_not_checked = TRUE;
@@ -328,12 +318,12 @@
struct ostream_private *_outstream = outstream->real_stream;
off_t ret;
- if (unlikely(outstream->closed || instream->closed)) {
+ if (unlikely(outstream->closed || instream->closed ||
+ outstream->stream_errno != 0)) {
errno = outstream->stream_errno;
return -1;
}
- o_stream_clear_error(outstream);
ret = _outstream->send_istream(_outstream, instream);
if (unlikely(ret < 0)) {
if (outstream->stream_errno != 0) {
@@ -351,12 +341,11 @@
{
int ret;
- if (unlikely(stream->closed)) {
+ if (unlikely(stream->closed || stream->stream_errno != 0)) {
errno = stream->stream_errno;
return -1;
}
- o_stream_clear_error(stream);
ret = stream->real_stream->write_at(stream->real_stream,
data, size, offset);
if (unlikely(ret < 0)) {
More information about the dovecot-cvs
mailing list