#include <unistd.h>
-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)
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;
} else if (ret == 0) {
return;
} else {
- connection_handshake_ready(conn);
+ connection_set_handshake_ready(conn);
}
}
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;
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 */
/* 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);