Skip to content

Commit

Permalink
lib: Removed ostream.last_failed_errno
Browse files Browse the repository at this point in the history
It's been identical to ostream.stream_errno for a while now.
  • Loading branch information
sirainen authored and GitLab committed May 18, 2016
1 parent 08ab0b2 commit f988b93
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 28 deletions.
2 changes: 1 addition & 1 deletion src/lib-index/mail-index-strmap.c
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/lib-storage/index/index-attachment.c
Expand Up @@ -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)) {
Expand Down
2 changes: 1 addition & 1 deletion src/lib-storage/index/maildir/maildir-save.c
Expand Up @@ -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);

Expand Down
20 changes: 2 additions & 18 deletions src/lib/ostream.c
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand All @@ -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;
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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);
Expand All @@ -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;
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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;
}

Expand All @@ -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;
}

Expand Down Expand Up @@ -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);
Expand Down
10 changes: 3 additions & 7 deletions src/lib/ostream.h
Expand Up @@ -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
Expand Down Expand Up @@ -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. */
Expand Down Expand Up @@ -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. */
Expand Down

0 comments on commit f988b93

Please sign in to comment.