]> 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)
committerStephan Bosch <stephan.bosch@dovecot.fi>
Sat, 17 Feb 2018 14:49:34 +0000 (15:49 +0100)
Otherwise, a disconnection event may be missed.

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

index a59955ca2481b900d10549292c39f8f62d3f6d9c..3994d13c69cf5f6f8cc2e62b0edbf6840dcf253e 100644 (file)
@@ -194,11 +194,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
@@ -1056,8 +1059,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);
 }