ostream.c revision 981139bb2e446bb2050c1158614725f8413fd709
c25356d5978632df6203437e1953bcb29e0c736fTimo Sirainen/* Copyright (c) 2002-2015 Dovecot authors, see the included COPYING file */
c5794838af9995f50bfecb06a3cd4f9a0ac77858Timo Sirainenvoid o_stream_set_name(struct ostream *stream, const char *name)
8d80659e504ffb34bb0c6a633184fece35751b18Timo Sirainen stream->real_stream->iostream.name = i_strdup(name);
bb10ebcf076c959c752f583746d83805d7686df8Timo Sirainenconst char *o_stream_get_name(struct ostream *stream)
81a5d8714c566ce50c4a2409f59e82e716d576d2Timo Sirainen while (stream->real_stream->iostream.name == NULL) {
46c31f64b9f0949f00b7819f45b22f2d64b2ea27Timo Sirainenconst char *o_stream_get_error(struct ostream *stream)
09c3a491f4f6ccebe290c7709bdc0d79a187610bTimo Sirainen /* we'll only return errors for streams that have stream_errno set.
d6badc27cd6e8d3398877b6766cb0aaeef3a7800Timo Sirainen we might be returning unintended error otherwise. */
d6badc27cd6e8d3398877b6766cb0aaeef3a7800Timo Sirainen return "<no error>";
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen for (s = stream; s != NULL; s = s->real_stream->parent) {
8d80659e504ffb34bb0c6a633184fece35751b18Timo Sirainenstatic void o_stream_close_full(struct ostream *stream, bool close_parents)
c251a38df327599a62d341bf5c2282f31352faa5Timo Sirainen if (!stream->closed && !stream->real_stream->closing) {
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen /* first mark the stream as being closed so the
aa38d1a0945f0bc13a225d043f53fad2eec666b1Timo Sirainen o_stream_copy_error_from_parent() won't recurse us back
aa38d1a0945f0bc13a225d043f53fad2eec666b1Timo Sirainen here. but don't immediately mark the stream closed, because
aa38d1a0945f0bc13a225d043f53fad2eec666b1Timo Sirainen we may still want to write something to it. */
e06c0b65c16ccce69bbee009ead14d7d3d17a256Timo Sirainen io_stream_close(&stream->real_stream->iostream, close_parents);
46c31f64b9f0949f00b7819f45b22f2d64b2ea27Timo Sirainen io_stream_ref(&stream->real_stream->iostream);
aa38d1a0945f0bc13a225d043f53fad2eec666b1Timo Sirainen if (stream->real_stream->last_errors_not_checked &&
aa38d1a0945f0bc13a225d043f53fad2eec666b1Timo Sirainen !stream->real_stream->error_handling_disabled &&
ae8817f05005f57bba32479a610b52d083e2b6ebTimo Sirainen stream->real_stream->iostream.refcount == 1) {
a022088674a5ae72ed29ae001834cbad62a4f19fTimo Sirainen i_panic("output stream %s is missing error handling",
a2cbf1d392ee983520451bc9b849a490f28ac298Timo Sirainen io_stream_unref(&stream->real_stream->iostream);
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainenvoid o_stream_add_destroy_callback(struct ostream *stream,
d6badc27cd6e8d3398877b6766cb0aaeef3a7800Timo Sirainen io_stream_add_destroy_callback(&stream->real_stream->iostream,
24fc71a693331ffe77e2b6d81c70aca6fa055e47Timo Sirainenvoid o_stream_remove_destroy_callback(struct ostream *stream,
d5cebe7f98e63d4e2822863ef2faa4971e8b3a5dTimo Sirainen io_stream_remove_destroy_callback(&stream->real_stream->iostream,
3fe9483b2b412a14493e3120751b0e99ecfe9388Timo Sirainenvoid o_stream_set_flush_callback(struct ostream *stream,
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen struct ostream_private *_stream = stream->real_stream;
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainen _stream->set_flush_callback(_stream, callback, context);
1279090ba03f9c176976a69ab7718f0ed77b19afTimo Sirainenvoid o_stream_unset_flush_callback(struct ostream *stream)
5a07b37a9df398b5189c14872a600384208ab74bTimo Sirainen struct ostream_private *_stream = stream->real_stream;
return ret;
unsigned int iov_count)
if (total_size == 0)
if (ret < 0) {
return ret;
unsigned int iov_count)
return ret;
int ret;
return ret;
const unsigned char *data;
if (ret <= 0) {
if (ret == 0)
bool close_parent)
if (set) {
int ret;
return ret;
void *context)
static size_t
static ssize_t
return ret;
struct ostream *
return output;
struct ostream *
return output;