From 2a19702a928d016a90e598c8ed4ecde24bfbe8f0 Mon Sep 17 00:00:00 2001 From: Timo Sirainen Date: Wed, 11 Jan 2023 16:02:38 +0200 Subject: [PATCH] lib: Add connection_vfuncs.init() --- src/lib/connection.c | 10 ++++++++++ src/lib/connection.h | 1 + 2 files changed, 11 insertions(+) diff --git a/src/lib/connection.c b/src/lib/connection.c index bb9d181ff3..1ffb0415af 100644 --- a/src/lib/connection.c +++ b/src/lib/connection.c @@ -591,6 +591,8 @@ void connection_init_server(struct connection_list *list, e_debug(e->event(), "Server accepted connection (fd=%d)", fd_in); connection_init_streams(conn); + if (conn->v.init != NULL) + conn->v.init(conn); } void connection_init_server_ip(struct connection_list *list, @@ -622,6 +624,8 @@ void connection_init_client_fd(struct connection_list *list, also be obvious that fd_out=1. */ e_debug(e->event(), "Client connected (fd=%d)", fd_in); + if (conn->v.init != NULL) + conn->v.init(conn); connection_client_connected(conn, TRUE); } @@ -650,6 +654,9 @@ void connection_init_client_ip_from(struct connection_list *list, if (hostname != NULL) event_add_str(conn->event, "dest_host", hostname); connection_update_event(conn); + + if (conn->v.init != NULL) + conn->v.init(conn); } void connection_init_client_ip(struct connection_list *list, @@ -668,6 +675,9 @@ void connection_init_client_unix(struct connection_list *list, connection_init(list, conn, path); event_add_str(conn->event, "socket_path", path); + + if (conn->v.init != NULL) + conn->v.init(conn); } void connection_init_from_streams(struct connection_list *list, diff --git a/src/lib/connection.h b/src/lib/connection.h index 4bd836e2c9..1ed112f950 100644 --- a/src/lib/connection.h +++ b/src/lib/connection.h @@ -29,6 +29,7 @@ enum connection_disconnect_reason { }; struct connection_vfuncs { + void (*init)(struct connection *conn); void (*destroy)(struct connection *conn); /* For UNIX socket clients this gets called immediately (unless delayed_unix_client_connected_callback=TRUE) with success=TRUE, -- 2.47.3