break;
}
if (res == OSTREAM_SEND_ISTREAM_RESULT_FINISHED) {
- if ((ret = o_stream_flush(conn->cmd_output)) == 0)
+ if ((ret = o_stream_finish(conn->cmd_output)) == 0)
return 0;
else if (ret < 0) {
i_error("write(%s) failed: %s",
bool force_extra_crlf;
};
-static int
-o_stream_dot_flush(struct ostream_private *stream)
+static int o_stream_dot_finish(struct ostream_private *stream)
{
struct dot_ostream *dstream = (struct dot_ostream *)stream;
int ret;
+ if (dstream->state == STREAM_STATE_DONE)
+ return 1;
+
if (o_stream_get_buffer_avail_size(stream->parent) < 5) {
/* make space for the dot line */
if ((ret = o_stream_flush(stream->parent)) <= 0) {
}
}
- if (dstream->state == STREAM_STATE_DONE)
- ;
- else if (dstream->state == STREAM_STATE_CRLF &&
- !dstream->force_extra_crlf) {
+ if (dstream->state == STREAM_STATE_CRLF &&
+ !dstream->force_extra_crlf) {
ret = o_stream_send(stream->parent, ".\r\n", 3);
i_assert(ret == 3);
} else {
i_assert(ret == 5);
}
dstream->state = STREAM_STATE_DONE;
+ return 1;
+}
+
+static int
+o_stream_dot_flush(struct ostream_private *stream)
+{
+ int ret;
+
+ if (stream->finished) {
+ if ((ret = o_stream_dot_finish(stream)) <= 0)
+ return ret;
+ }
if ((ret = o_stream_flush(stream->parent)) < 0)
o_stream_copy_error_from_parent(stream);
test_assert(test_input->eof);
- test_assert(o_stream_flush(output) > 0);
+ test_assert(o_stream_finish(output) > 0);
test_assert(output->offset == strlen(test->input));
test_assert(test_output->offset == strlen(test->output));
o_stream_unref(&output);
if (input == NULL &&
output != NULL &&
pclient->dot_output != NULL) {
- if ((ret = o_stream_flush(pclient->dot_output)) <= 0) {
+ if ((ret = o_stream_finish(pclient->dot_output)) <= 0) {
if (ret < 0) {
i_error("write(%s) failed: %s",
o_stream_get_name(output),
} else if (strcmp(args[0], "test_program_io")==0) {
os = o_stream_create_dot(client->out, FALSE);
o_stream_send_istream(os, client->body);
- test_assert(o_stream_flush(os) > 0);
+ test_assert(o_stream_finish(os) > 0);
o_stream_unref(&os);
o_stream_nsend_str(client->out, "+\n");
} else if (strcmp(args[0], "test_program_failure")==0) {