#include "imap-commands.h"
#include "istream.h"
#include "ostream.h"
+#include "iostream-rawlog.h"
#include "str.h"
#include "compression.h"
client_skip_line(client);
client_send_tagline(cmd, "OK Begin compression.");
+ if (client->pre_rawlog_input != NULL) {
+ /* Rawlogging is currently enabled. Stop it. */
+ i_assert(client->pre_rawlog_output != NULL);
+ i_assert(client->pre_rawlog_input != client->post_rawlog_input);
+ i_assert(client->pre_rawlog_output != client->post_rawlog_output);
+ uoff_t prev_in_offset = client->input->v_offset;
+ /* Make sure the rawlog is the outermost stream, since we
+ can't remove it from the middle */
+ i_assert(client->post_rawlog_input == client->input);
+ i_assert(client->post_rawlog_output == client->output);
+ /* Pre-rawlog streams are referenced only by the outermost
+ stream, so make sure they don't get destroyed */
+ client->input = client->pre_rawlog_input;
+ client->output = client->pre_rawlog_output;
+ i_stream_ref(client->input);
+ o_stream_ref(client->output);
+ /* Destroy the rawlog streams. This closes the rawlogs, but
+ not the parent streams. */
+ i_stream_destroy(&client->post_rawlog_input);
+ o_stream_destroy(&client->post_rawlog_output);
+ io_remove(&client->io);
+ /* Make sure istream-rawlog updated the parent stream's seek
+ offset. */
+ i_assert(client->input->v_offset == prev_in_offset);
+ }
+
level = handler->get_default_level();
old_input = client->input;
old_output = client->output;
i_stream_unref(&old_input);
o_stream_unref(&old_output);
+ if (client->pre_rawlog_input != NULL) {
+ (void)iostream_rawlog_create(client->set->rawlog_dir,
+ &client->input, &client->output);
+ client->post_rawlog_input = client->input;
+ client->post_rawlog_output = client->output;
+ client_add_missing_io(client);
+ }
+
client_update_imap_parser_streams(client);
return TRUE;
}
void client_create_finish_io(struct client *client)
{
if (client->set->rawlog_dir[0] != '\0') {
+ client->pre_rawlog_input = client->input;
+ client->pre_rawlog_output = client->output;
(void)iostream_rawlog_create(client->set->rawlog_dir,
&client->input, &client->output);
+ if (client->input != client->pre_rawlog_input) {
+ /* rawlog enabled */
+ client->post_rawlog_input = client->input;
+ client->post_rawlog_output = client->output;
+ } else {
+ /* rawlog setting is set, but rawlog wasn't actually
+ started. */
+ client->pre_rawlog_input = NULL;
+ client->pre_rawlog_output = NULL;
+ }
}
client->io = io_add_istream(client->input, client_input, client);
}