bool last_errors_not_checked:1;
bool error_handling_disabled:1;
bool noverflow:1;
+ bool finish_also_parent:1;
+ bool finish_via_child:1;
};
struct ostream *
return o_stream_flush(stream);
}
+void o_stream_set_finish_also_parent(struct ostream *stream, bool set)
+{
+ stream->real_stream->finish_also_parent = set;
+}
+
+void o_stream_set_finish_via_child(struct ostream *stream, bool set)
+{
+ stream->real_stream->finish_via_child = set;
+}
+
void o_stream_ignore_last_errors(struct ostream *stream)
{
while (stream != NULL) {
i_assert(_stream->parent != NULL);
- if (!_stream->finished)
+ if (!_stream->finished || !_stream->finish_also_parent ||
+ !_stream->parent->real_stream->finish_via_child)
ret = o_stream_flush(_stream->parent);
else
ret = o_stream_finish(_stream->parent);
struct ostream *
o_stream_create(struct ostream_private *_stream, struct ostream *parent, int fd)
{
+ _stream->finish_also_parent = TRUE;
+ _stream->finish_via_child = TRUE;
_stream->fd = fd;
_stream->ostream.real_stream = _stream;
if (parent != NULL) {
assert-crash. Returns the same as o_stream_flush(). Afterwards any calls to
this function are identical to o_stream_flush(). */
int o_stream_finish(struct ostream *stream);
+/* Specify whether calling o_stream_finish() will cause the parent stream to
+ be finished as well. The default is yes. */
+void o_stream_set_finish_also_parent(struct ostream *stream, bool set);
+/* Specify whether calling o_stream_finish() on a child stream will cause
+ this stream to be finished as well. The default is yes. */
+void o_stream_set_finish_via_child(struct ostream *stream, bool set);
/* Marks the stream's error handling as completed to avoid i_panic() on
destroy. */
void o_stream_ignore_last_errors(struct ostream *stream);