]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib: Removed ostream.last_failed_errno
authorTimo Sirainen <timo.sirainen@dovecot.fi>
Mon, 16 May 2016 13:58:44 +0000 (16:58 +0300)
committerGitLab <gitlab@git.dovecot.net>
Wed, 18 May 2016 12:21:30 +0000 (15:21 +0300)
It's been identical to ostream.stream_errno for a while now.

src/lib-index/mail-index-strmap.c
src/lib-storage/index/index-attachment.c
src/lib-storage/index/maildir/maildir-save.c
src/lib/ostream.c
src/lib/ostream.h

index 549eaf45f1e1eb9666608893a62f3d50f00f139a..88f06cd83cef0f63928b0085dc930880b63b3ef3 100644 (file)
@@ -958,7 +958,7 @@ static void mail_index_strmap_write_block(struct mail_index_strmap_view *view,
        o_stream_nsend(output, &block_size, sizeof(block_size));
        (void)o_stream_seek(output, end_offset);
 
-       if (output->last_failed_errno != 0)
+       if (output->stream_errno != 0)
                return;
 
        i_assert(view->last_added_uid == recs[count-1].uid);
index 4b7abd9129d32ecddac007df284dcebae5f0cf58..3bfb3d387e580119b224958f710b492ff5dfe787 100644 (file)
@@ -193,7 +193,7 @@ void index_attachment_save_begin(struct mail_save_context *ctx,
 static int save_check_write_error(struct mail_storage *storage,
                                  struct ostream *output)
 {
-       if (output->last_failed_errno == 0)
+       if (output->stream_errno == 0)
                return 0;
 
        if (!mail_storage_set_error_from_errno(storage)) {
index f20fd76afbfc14028b75fc5f9fb0248beaf0cf08..c3ac128f6b9d33cc9ba5c4be11d731c9fa27b1c4 100644 (file)
@@ -570,7 +570,7 @@ static int maildir_save_finish_real(struct mail_save_context *_ctx)
                                  &ctx->file_last->vsize) < 0)
                ctx->file_last->vsize = (uoff_t)-1;
 
-       output_errno = _ctx->data.output->last_failed_errno;
+       output_errno = _ctx->data.output->stream_errno;
        output_errstr = t_strdup(o_stream_get_error(_ctx->data.output));
        o_stream_destroy(&_ctx->data.output);
 
index ac34338ded09da64a2ff8d1463688d1f0b31f901..6eef92d29417445ac2a8cc7c45e1d80947dc5b63 100644 (file)
@@ -55,12 +55,8 @@ static void o_stream_close_full(struct ostream *stream, bool close_parents)
                stream->closed = TRUE;
        }
 
-       if (stream->stream_errno != 0)
-               i_assert(stream->last_failed_errno != 0);
-       else {
+       if (stream->stream_errno == 0)
                stream->stream_errno = EPIPE;
-               stream->last_failed_errno = EPIPE;
-       }
 }
 
 void o_stream_destroy(struct ostream **stream)
@@ -155,8 +151,6 @@ void o_stream_uncork(struct ostream *stream)
                return;
 
        _stream->cork(_stream, FALSE);
-       if (stream->stream_errno != 0)
-               errno = stream->last_failed_errno = stream->stream_errno;
 }
 
 bool o_stream_is_corked(struct ostream *stream)
@@ -178,7 +172,6 @@ int o_stream_flush(struct ostream *stream)
 
        if (unlikely((ret = _stream->flush(_stream)) < 0)) {
                i_assert(stream->stream_errno != 0);
-               stream->last_failed_errno = stream->stream_errno;
                errno = stream->stream_errno;
        }
        return ret;
@@ -220,7 +213,6 @@ int o_stream_seek(struct ostream *stream, uoff_t offset)
 
        if (unlikely(_stream->seek(_stream, offset) < 0)) {
                i_assert(stream->stream_errno != 0);
-               stream->last_failed_errno = stream->stream_errno;
                errno = stream->stream_errno;
                return -1;
        }
@@ -260,7 +252,6 @@ ssize_t o_stream_sendv(struct ostream *stream, const struct const_iovec *iov,
        if (unlikely(ret != (ssize_t)total_size)) {
                if (ret < 0) {
                        i_assert(stream->stream_errno != 0);
-                       stream->last_failed_errno = stream->stream_errno;
                        errno = stream->stream_errno;
                } else {
                        stream->overflow = TRUE;
@@ -311,8 +302,7 @@ int o_stream_nfinish(struct ostream *stream)
 {
        o_stream_nflush(stream);
        o_stream_ignore_last_errors(stream);
-       errno = stream->last_failed_errno;
-       return stream->last_failed_errno != 0 ? -1 : 0;
+       return stream->stream_errno != 0 ? -1 : 0;
 }
 
 void o_stream_ignore_last_errors(struct ostream *stream)
@@ -343,7 +333,6 @@ off_t o_stream_send_istream(struct ostream *outstream,
        ret = _outstream->send_istream(_outstream, instream);
        if (unlikely(ret < 0)) {
                if (outstream->stream_errno != 0) {
-                       outstream->last_failed_errno = outstream->stream_errno;
                        errno = outstream->stream_errno;
                } else {
                        i_assert(instream->stream_errno != 0);
@@ -366,7 +355,6 @@ int o_stream_pwrite(struct ostream *stream, const void *data, size_t size,
                                            data, size, offset);
        if (unlikely(ret < 0)) {
                i_assert(stream->stream_errno != 0);
-               stream->last_failed_errno = stream->stream_errno;
                errno = stream->stream_errno;
        }
        return ret;
@@ -457,7 +445,6 @@ void o_stream_copy_error_from_parent(struct ostream_private *_stream)
        struct ostream *dest = &_stream->ostream;
 
        dest->stream_errno = src->stream_errno;
-       dest->last_failed_errno = src->last_failed_errno;
        dest->overflow = src->overflow;
        if (src->closed)
                o_stream_close(dest);
@@ -525,7 +512,6 @@ o_stream_default_seek(struct ostream_private *_stream,
                      uoff_t offset ATTR_UNUSED)
 {
        _stream->ostream.stream_errno = ESPIPE;
-       _stream->ostream.last_failed_errno = ESPIPE;
        return -1;
 }
 
@@ -549,7 +535,6 @@ o_stream_default_write_at(struct ostream_private *_stream,
                          size_t size ATTR_UNUSED, uoff_t offset ATTR_UNUSED)
 {
        _stream->ostream.stream_errno = ESPIPE;
-       _stream->ostream.last_failed_errno = ESPIPE;
        return -1;
 }
 
@@ -625,7 +610,6 @@ struct ostream *o_stream_create_error(int stream_errno)
        stream = i_new(struct ostream_private, 1);
        stream->ostream.closed = TRUE;
        stream->ostream.stream_errno = stream_errno;
-       stream->ostream.last_failed_errno = stream_errno;
 
        output = o_stream_create(stream, NULL, -1);
        o_stream_set_no_error_handling(output, TRUE);
index 3eaf4366eb59be177eefd4891f8eaef4f1c35f36..08503e42e6d8043acfec9f9f7166105b29182732 100644 (file)
@@ -9,8 +9,6 @@ struct ostream {
        /* errno for the last operation send/seek operation. cleared before
           each call. */
        int stream_errno;
-       /* errno of the last failed send/seek. never cleared. */
-       int last_failed_errno;
 
        /* overflow is set when some of the data given to send()
           functions was neither sent nor buffered. It's never unset inside
@@ -56,8 +54,7 @@ const char *o_stream_get_name(struct ostream *stream);
 
 /* Return file descriptor for stream, or -1 if none is available. */
 int o_stream_get_fd(struct ostream *stream);
-/* Returns error string for the previous error (stream_errno,
-   not last_failed_errno). */
+/* Returns error string for the previous error. */
 const char *o_stream_get_error(struct ostream *stream);
 
 /* Close this stream (but not its parents) and unreference it. */
@@ -130,9 +127,8 @@ void o_stream_nsendv(struct ostream *stream, const struct const_iovec *iov,
                     unsigned int iov_count);
 void o_stream_nsend_str(struct ostream *stream, const char *str);
 void o_stream_nflush(struct ostream *stream);
-/* Flushes the stream and returns -1 if stream->last_failed_errno is
-   non-zero. Marks the stream's error handling as completed. errno is also set
-   to last_failed_errno. */
+/* Flushes the stream and returns -1 if stream->stream_errno is non-zero.
+   Marks the stream's error handling as completed. */
 int o_stream_nfinish(struct ostream *stream);
 /* Marks the stream's error handling as completed to avoid i_panic() on
    destroy. */