Skip to content

Commit

Permalink
lib-smtp: client: 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 3a6c4f9 commit d6f83e1
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/lib-smtp/smtp-client-connection.c
Expand Up @@ -220,11 +220,14 @@ void smtp_client_connection_cork(struct smtp_client_connection *conn)

void smtp_client_connection_uncork(struct smtp_client_connection *conn)
{
conn->corked = FALSE;
if (conn->conn.output != NULL) {
if (o_stream_uncork_flush(conn->conn.output) < 0) {
smtp_client_connection_handle_output_error(conn);
return;
}
smtp_client_connection_trigger_output(conn);
o_stream_uncork(conn->conn.output);
}
conn->corked = FALSE;
}

enum smtp_client_connection_state
Expand Down Expand Up @@ -1082,8 +1085,10 @@ static void smtp_client_connection_input(struct connection *_conn)
error));
}
}
if (conn->conn.output != NULL && !conn->corked)
o_stream_uncork(conn->conn.output);
if (ret >= 0 && conn->conn.output != NULL && !conn->corked) {
if (o_stream_uncork_flush(conn->conn.output) < 0)
smtp_client_connection_handle_output_error(conn);
}
smtp_client_connection_unref(&conn);
}

Expand Down

0 comments on commit d6f83e1

Please sign in to comment.