From: Aki Tuomi Date: Wed, 28 Feb 2024 11:27:39 +0000 (+0200) Subject: lib: connection - Add connection_set_handshake_ready() X-Git-Tag: 2.4.0~1734 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f94fbb2e5d1e37ebf4ace4ae3f3a59fafd5658cb;p=thirdparty%2Fdovecot%2Fcore.git lib: connection - Add connection_set_handshake_ready() --- diff --git a/src/lib/connection.c b/src/lib/connection.c index e7dfba3694..f036ab154a 100644 --- a/src/lib/connection.c +++ b/src/lib/connection.c @@ -16,8 +16,9 @@ #include -static void connection_handshake_ready(struct connection *conn) +void connection_set_handshake_ready(struct connection *conn) { + i_assert(conn->handshake_finished.tv_sec == 0); conn->handshake_received = TRUE; conn->handshake_finished = ioloop_timeval; if (conn->v.handshake_ready != NULL) @@ -108,7 +109,7 @@ static int connection_input_parse_lines(struct connection *conn) conn->v.handshake_line != NULL) { ret = conn->v.handshake_line(conn, line); if (ret > 0) - connection_handshake_ready(conn); + connection_set_handshake_ready(conn); else if (ret == 0) /* continue reading */ ret = 1; @@ -160,7 +161,7 @@ void connection_input_default(struct connection *conn) } else if (ret == 0) { return; } else { - connection_handshake_ready(conn); + connection_set_handshake_ready(conn); } } @@ -244,7 +245,7 @@ int connection_input_line_default(struct connection *conn, const char *line) if ((ret = conn->v.handshake_args(conn, args)) == 0) ret = 1; /* continue reading */ else if (ret > 0) - connection_handshake_ready(conn); + connection_set_handshake_ready(conn); else { conn->disconnect_reason = CONNECTION_DISCONNECT_HANDSHAKE_FAILED; @@ -252,7 +253,7 @@ int connection_input_line_default(struct connection *conn, const char *line) return ret; } else if (!conn->handshake_received) { /* we don't do handshakes */ - connection_handshake_ready(conn); + connection_set_handshake_ready(conn); } /* version must be handled though, by something */ diff --git a/src/lib/connection.h b/src/lib/connection.h index cfdde7e897..8fbb913ba4 100644 --- a/src/lib/connection.h +++ b/src/lib/connection.h @@ -275,6 +275,11 @@ void connection_update_counters(struct connection *conn); /* This needs to be called if the input/output streams are changed */ void connection_streams_changed(struct connection *conn); +/* This function must be called if handshaking is handled without + connection API. This is automatically called once handshake + vfunctions return success and will call the handshake_ready() vfunction. */ +void connection_set_handshake_ready(struct connection *conn); + /* Returns -1 = disconnected, 0 = nothing new, 1 = something new. If input_full_behavior is ALLOW, may return also -2 = buffer full. */ int connection_input_read(struct connection *conn);