int fd;
struct istream *ext_in;
struct ostream *ext_out;
- bool flushed;
+ bool finished;
};
static void
return ret;
}
-static int o_stream_mail_filter_flush(struct ostream_private *stream)
+static int o_stream_mail_filter_finish(struct ostream_private *stream)
{
struct mail_filter_ostream *mstream =
(struct mail_filter_ostream *)stream;
/* connect failed */
return -1;
}
- if (mstream->flushed)
+ if (mstream->finished)
return 0;
if (shutdown(mstream->fd, SHUT_WR) < 0)
return -1;
}
- ret = o_stream_flush(stream->parent);
- if (ret < 0)
+ mstream->finished = TRUE;
+ return ret;
+}
+
+static int o_stream_mail_filter_flush(struct ostream_private *stream)
+{
+ int ret;
+
+ if (stream->finished) {
+ if ((ret = o_stream_mail_filter_finish(stream)) <= 0)
+ return ret;
+ }
+ if ((ret = o_stream_flush(stream->parent)) < 0)
o_stream_copy_error_from_parent(stream);
- else
- mstream->flushed = TRUE;
return ret;
}