Skip to content

Commit

Permalink
lib-smtp: server: Flush and check output for errors after uncorking.
Browse files Browse the repository at this point in the history
Otherwise, a disconnection event may be missed.
  • Loading branch information
stephanbosch authored and villesavolainen committed Mar 12, 2018
1 parent a7bff44 commit 4a82326
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/lib-smtp/smtp-server-connection.c
Expand Up @@ -683,11 +683,14 @@ void smtp_server_connection_cork(struct smtp_server_connection *conn)

void smtp_server_connection_uncork(struct smtp_server_connection *conn)
{
conn->corked = FALSE;
if (conn->conn.output != NULL) {
o_stream_uncork(conn->conn.output);
if (o_stream_uncork_flush(conn->conn.output) < 0) {
smtp_server_connection_handle_output_error(conn);
return;
}
smtp_server_connection_trigger_output(conn);
}
conn->corked = FALSE;
}

static void
Expand Down Expand Up @@ -730,8 +733,10 @@ smtp_server_connection_output(struct smtp_server_connection *conn)
smtp_server_connection_timeout_reset(conn);
smtp_server_connection_send_replies(conn);
}
if (!conn->corked && conn->conn.output != NULL)
o_stream_uncork(conn->conn.output);
if (ret >= 0 && !conn->corked && conn->conn.output != NULL) {
if ((ret=o_stream_uncork_flush(conn->conn.output)) < 0)
smtp_server_connection_handle_output_error(conn);
}
smtp_server_connection_unref(&conn);
return ret;
}
Expand Down

0 comments on commit 4a82326

Please sign in to comment.