From: Aki Tuomi Date: Wed, 28 Nov 2018 18:17:23 +0000 (+0200) Subject: lib: connection - Use CONNECTION_DISCONNECT_HANDSHAKE_FAILED explicitly X-Git-Tag: 2.3.9~1053 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=a5d2c2b5ff848330df6dba1d2bcba6046071cef3;p=thirdparty%2Fdovecot%2Fcore.git lib: connection - Use CONNECTION_DISCONNECT_HANDSHAKE_FAILED explicitly Do not accidentically use it when connection was disconnected for some other reason. --- diff --git a/src/lib/connection.c b/src/lib/connection.c index 813f3c7488..16f718aac9 100644 --- a/src/lib/connection.c +++ b/src/lib/connection.c @@ -79,6 +79,9 @@ void connection_input_default(struct connection *conn) else if (ret == 0) /* continue reading */ ret = 1; + else + conn->disconnect_reason = + CONNECTION_DISCONNECT_HANDSHAKE_FAILED; } else { ret = conn->v.input_line(conn, line); } @@ -91,11 +94,10 @@ void connection_input_default(struct connection *conn) o_stream_unref(&output); } if (ret < 0 && !input->closed) { - enum connection_disconnect_reason reason; - if (conn->handshake_received) + enum connection_disconnect_reason reason = + conn->disconnect_reason; + if (reason == CONNECTION_DISCONNECT_NOT) reason = CONNECTION_DISCONNECT_DEINIT; - else - reason = CONNECTION_DISCONNECT_HANDSHAKE_FAILED; connection_closed(conn, reason); } i_stream_unref(&input); @@ -155,6 +157,8 @@ int connection_input_line_default(struct connection *conn, const char *line) ret = 1; /* continue reading */ else if (ret > 0) conn->handshake_received = TRUE; + else + conn->disconnect_reason = CONNECTION_DISCONNECT_HANDSHAKE_FAILED; return ret; } else if (!conn->handshake_received) { /* we don't do handshakes */