]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-smtp: client: Flush and check output for errors after uncorking.
authorStephan Bosch <stephan.bosch@dovecot.fi>
Fri, 16 Feb 2018 22:49:31 +0000 (23:49 +0100)
committerVille Savolainen <ville.savolainen@dovecot.fi>
Mon, 12 Mar 2018 08:42:26 +0000 (10:42 +0200)
Otherwise, a disconnection event may be missed.

src/lib-smtp/smtp-client-connection.c

index 2221f7de40cdfeff24619819d21753afbf537f61..347b8dad7a71bd0116a998555b9529e5609309eb 100644 (file)
@@ -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
@@ -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);
 }