conn->list->set.unix_client_connect_msecs);
}
+static void connection_client_connect_failed(struct connection *conn)
+{
+ timeout_remove(&conn->to);
+ errno = conn->connect_failed_errno;
+ conn->v.client_connected(conn, FALSE);
+ connection_closed(conn, CONNECTION_DISCONNECT_CONN_CLOSED);
+}
+
+int connection_client_connect_async(struct connection *conn)
+{
+ i_assert(conn->v.client_connected != NULL);
+
+ if (connection_client_connect(conn) < 0) {
+ i_assert(conn->to == NULL);
+ conn->connect_failed_errno = errno;
+ conn->to = timeout_add_short(0, connection_client_connect_failed, conn);
+ return -1;
+ }
+ return 0;
+}
+
static void connection_update_counters(struct connection *conn)
{
if (conn->input != NULL)
/* handlers */
struct connection_vfuncs v;
+ int connect_failed_errno;
enum connection_disconnect_reason disconnect_reason;
bool version_received:1;
struct istream *input,
struct ostream *output) ATTR_NULL(3);
+/* connect() to the server. If the connect() fails immediately, return -1. */
int connection_client_connect(struct connection *conn);
+/* connect() to the server. If the connect() fails immediately, call the
+ client_connected() and destroy() asynchronously from a timeout. This
+ simulates what happens on a delayed connect() failure. */
+int connection_client_connect_async(struct connection *conn);
/* Connect to UNIX socket. If it fails, try it up to msecs is reached.
Overrides connection_settings.unix_client_connect_msecs. */
int connection_client_connect_with_retries(struct connection *conn,