#include "istream.h"
#include "istream-concat.h"
#include "ostream.h"
+#include "ostream-multiplex.h"
#include "time-util.h"
#include "var-expand.h"
#include "settings.h"
client->input = i_stream_create_fd(fd_in,
set->imap_max_line_length);
client->output = o_stream_create_fd(fd_out, SIZE_MAX);
+ if ((flags & CLIENT_CREATE_FLAG_MULTIPLEX_OUTPUT) != 0) {
+ client->multiplex_output =
+ o_stream_create_multiplex(client->output, SIZE_MAX,
+ OSTREAM_MULTIPLEX_FORMAT_STREAM_CONTINUE);
+ o_stream_unref(&client->output);
+ client->output = client->multiplex_output;
+ }
o_stream_set_no_error_handling(client->output, TRUE);
i_stream_set_name(client->input, "<imap client>");
o_stream_set_name(client->output, "<imap client>");
enum client_create_flags {
CLIENT_CREATE_FLAG_UNHIBERNATED = BIT(0),
+ CLIENT_CREATE_FLAG_MULTIPLEX_OUTPUT = BIT(1),
};
struct mailbox_keywords {
struct io *io;
struct istream *input, *pre_rawlog_input, *post_rawlog_input;
struct ostream *output, *pre_rawlog_output, *post_rawlog_output;
+ struct ostream *multiplex_output;
struct timeout *to_idle, *to_idle_output, *to_delayed_input;
guid_128_t anvil_conn_guid;
struct client *client;
struct imap_login_request imap_request;
enum login_request_flags flags = request->auth_req.flags;
+ enum client_create_flags create_flags = 0;
const char *error;
i_zero(&input);
input.session_id = request->session_id;
if ((flags & LOGIN_REQUEST_FLAG_END_CLIENT_SECURED_TLS) != 0)
input.end_client_tls_secured = TRUE;
+ if ((flags & LOGIN_REQUEST_FLAG_MULTIPLEX_OUTPUT) != 0)
+ create_flags |= CLIENT_CREATE_FLAG_MULTIPLEX_OUTPUT;
client_parse_imap_login_request(request->data,
request->auth_req.data_size,
&imap_request);
if (client_create_from_input(&input, request->fd, request->fd,
- 0, &client, &error) < 0) {
+ create_flags, &client, &error) < 0) {
int fd = request->fd;
struct ostream *output =
o_stream_create_fd_autoclose(&fd, IO_BLOCK_SIZE);
LOGIN_REQUEST_FLAG_END_CLIENT_SECURED_TLS = BIT(2),
/* This login is implicit; no command reply is expected */
LOGIN_REQUEST_FLAG_IMPLICIT = BIT(3),
+ /* The output stream is ostream-multiplex */
+ LOGIN_REQUEST_FLAG_MULTIPLEX_OUTPUT = BIT(4),
};
/* Login request. File descriptor may be sent along with the request. */
{
int fds[2];
- if (client->ssl_iostream == NULL && client->multiplex_output == NULL) {
+ if (client->ssl_iostream == NULL) {
/* Plaintext connection - We can send the fd directly to
the post-login process without any proxying. */
*fd_r = client->fd;
req.local_port = client->local_port;
req.remote_port = client->remote_port;
req.client_pid = getpid();
+ if (client->multiplex_output != NULL)
+ req.flags |= LOGIN_REQUEST_FLAG_MULTIPLEX_OUTPUT;
if (client->ssl_iostream != NULL &&
ssl_iostream_get_compression(client->ssl_iostream) != NULL)
req.flags |= LOGIN_REQUEST_FLAG_TLS_COMPRESSION;