Skip to content

Commit

Permalink
lib-smtp: server: Delay handling initial input (from login service) u…
Browse files Browse the repository at this point in the history
…ntil after smtp_server_connection_start().

Instead, it is now handled in normal io callback.
  • Loading branch information
stephanbosch authored and cmouse committed Dec 28, 2017
1 parent 6b31294 commit 9a3c4a1
Showing 1 changed file with 5 additions and 15 deletions.
20 changes: 5 additions & 15 deletions src/lib-smtp/smtp-server-connection.c
Expand Up @@ -285,8 +285,6 @@ smtp_server_connection_timeout_update(struct smtp_server_connection *conn)
static void
smtp_server_connection_ready(struct smtp_server_connection *conn)
{
struct ostream *output;

conn->raw_input = conn->conn.input;
conn->raw_output = conn->conn.output;

Expand All @@ -297,10 +295,7 @@ smtp_server_connection_ready(struct smtp_server_connection *conn)
o_stream_set_flush_callback(conn->conn.output,
smtp_server_connection_output, conn);

output = conn->conn.output;
o_stream_ref(output);
o_stream_cork(output);

o_stream_cork(conn->conn.output);
if (conn->authenticated) {
/* RFC 4954, Section 4:
Should the client successfully complete the exchange, the
Expand All @@ -312,13 +307,8 @@ smtp_server_connection_ready(struct smtp_server_connection *conn)
"220 %s %s", conn->set.hostname,
conn->set.login_greeting);
}

if (i_stream_get_data_size(conn->conn.input) > 0)
smtp_server_connection_input(&conn->conn);

if (!conn->corked)
o_stream_uncork(output);
o_stream_unref(&output);
o_stream_uncork(conn->conn.output);
}

static void smtp_server_connection_destroy(struct connection *_conn)
Expand Down Expand Up @@ -1158,11 +1148,11 @@ void smtp_server_connection_start(struct smtp_server_connection *conn)
conn->raw_input = conn->conn.input;
conn->raw_output = conn->conn.output;

smtp_server_connection_timeout_start(conn);
smtp_server_connection_input_resume(conn);

if (!conn->ssl_start)
smtp_server_connection_ready(conn);

smtp_server_connection_timeout_start(conn);
smtp_server_connection_input_resume(conn);
}

void smtp_server_connection_close(struct smtp_server_connection **_conn,
Expand Down

0 comments on commit 9a3c4a1

Please sign in to comment.