From 2cdab962670df394c28fb7858cb0d4f90f70f71c Mon Sep 17 00:00:00 2001 From: Timo Sirainen Date: Tue, 2 Mar 2021 15:23:46 +0200 Subject: [PATCH] lib-smtp: Rename conn_destroy() callback to conn_free() It's called when the final reference to connection is dropped, so this describes it better. --- src/lib-smtp/smtp-server-connection.c | 4 ++-- src/lib-smtp/smtp-server.h | 6 +++++- src/lib-smtp/test-smtp-payload.c | 6 +++--- src/lib-smtp/test-smtp-server-errors.c | 6 +++--- src/lmtp/lmtp-client.c | 4 ++-- src/submission-login/client.c | 4 ++-- src/submission/submission-client.c | 4 ++-- 7 files changed, 19 insertions(+), 15 deletions(-) diff --git a/src/lib-smtp/smtp-server-connection.c b/src/lib-smtp/smtp-server-connection.c index e4e9ee7f35..61fe00b592 100644 --- a/src/lib-smtp/smtp-server-connection.c +++ b/src/lib-smtp/smtp-server-connection.c @@ -1126,8 +1126,8 @@ bool smtp_server_connection_unref(struct smtp_server_connection **_conn) e_debug(conn->event, "Connection destroy"); - if (conn->callbacks != NULL && conn->callbacks->conn_destroy != NULL) - conn->callbacks->conn_destroy(conn->context); + if (conn->callbacks != NULL && conn->callbacks->conn_free != NULL) + conn->callbacks->conn_free(conn->context); connection_deinit(&conn->conn); diff --git a/src/lib-smtp/smtp-server.h b/src/lib-smtp/smtp-server.h index 30b6d9b5cb..0e91c6b835 100644 --- a/src/lib-smtp/smtp-server.h +++ b/src/lib-smtp/smtp-server.h @@ -302,8 +302,12 @@ struct smtp_server_callbacks { /* Connection */ int (*conn_start_tls)(void *conn_ctx, struct istream **input, struct ostream **output); + /* Connection is disconnected. This is always called before + conn_free(). */ void (*conn_disconnect)(void *context, const char *reason); - void (*conn_destroy)(void *context); + /* The last reference to connection is dropped, causing the connection + to be freed. */ + void (*conn_free)(void *context); /* Security */ bool (*conn_is_trusted)(void *context); diff --git a/src/lib-smtp/test-smtp-payload.c b/src/lib-smtp/test-smtp-payload.c index c9dfd795db..513a82cfcd 100644 --- a/src/lib-smtp/test-smtp-payload.c +++ b/src/lib-smtp/test-smtp-payload.c @@ -377,7 +377,7 @@ test_server_conn_cmd_data_continue(void *conn_ctx ATTR_UNUSED, /* client connection */ -static void test_server_connection_destroy(void *context); +static void test_server_connection_free(void *context); static const struct smtp_server_callbacks server_callbacks = { @@ -387,7 +387,7 @@ static const struct smtp_server_callbacks server_callbacks = .conn_trans_free = test_server_conn_trans_free, - .conn_destroy = test_server_connection_destroy, + .conn_free = test_server_connection_free, }; static void client_init(int fd) @@ -424,7 +424,7 @@ static void client_deinit(struct client **_client) pool_unref(&client->pool); } -static void test_server_connection_destroy(void *context) +static void test_server_connection_free(void *context) { struct client *client = context; diff --git a/src/lib-smtp/test-smtp-server-errors.c b/src/lib-smtp/test-smtp-server-errors.c index f592a4a5c9..796df21028 100644 --- a/src/lib-smtp/test-smtp-server-errors.c +++ b/src/lib-smtp/test-smtp-server-errors.c @@ -2867,12 +2867,12 @@ static void test_server_defaults(struct smtp_server_settings *smtp_set) /* client connection */ -static void server_connection_destroy(void *context) +static void server_connection_free(void *context) { struct server_connection *sconn = (struct server_connection *)context; if (debug) - i_debug("Connection destroyed"); + i_debug("Connection freed"); if (--server_pending == 0) io_loop_stop(ioloop); @@ -2898,7 +2898,7 @@ static void server_connection_accept(void *context ATTR_UNUSED) sconn = i_new(struct server_connection, 1); - server_callbacks.conn_destroy = server_connection_destroy; + server_callbacks.conn_free = server_connection_free; conn = smtp_server_connection_create(smtp_server, fd, fd, NULL, 0, FALSE, NULL, diff --git a/src/lmtp/lmtp-client.c b/src/lmtp/lmtp-client.c index 7cb9126873..498367f3d0 100644 --- a/src/lmtp/lmtp-client.c +++ b/src/lmtp/lmtp-client.c @@ -379,7 +379,7 @@ static void client_connection_disconnect(void *context, const char *reason) client_disconnect(client, NULL, reason); } -static void client_connection_destroy(void *context) +static void client_connection_free(void *context) { struct client *client = (struct client *)context; @@ -431,7 +431,7 @@ static const struct smtp_server_callbacks lmtp_callbacks = { .conn_proxy_data_updated = client_connection_proxy_data_updated, .conn_disconnect = client_connection_disconnect, - .conn_destroy = client_connection_destroy, + .conn_free = client_connection_free, .conn_is_trusted = client_connection_is_trusted }; diff --git a/src/submission-login/client.c b/src/submission-login/client.c index d2f03a0225..43ae9ee7c0 100644 --- a/src/submission-login/client.c +++ b/src/submission-login/client.c @@ -216,7 +216,7 @@ static void client_connection_disconnect(void *context, const char *reason) client_disconnect(&client->common, reason); } -static void client_connection_destroy(void *context) +static void client_connection_free(void *context) { struct submission_client *client = context; @@ -277,7 +277,7 @@ static const struct smtp_server_callbacks smtp_callbacks = { .conn_cmd_xclient = client_connection_cmd_xclient, .conn_disconnect = client_connection_disconnect, - .conn_destroy = client_connection_destroy, + .conn_free = client_connection_free, .conn_is_trusted = client_connection_is_trusted }; diff --git a/src/submission/submission-client.c b/src/submission/submission-client.c index 877a948caf..c40f6d3474 100644 --- a/src/submission/submission-client.c +++ b/src/submission/submission-client.c @@ -406,7 +406,7 @@ static void client_connection_disconnect(void *context, const char *reason) client_disconnect(client, NULL, reason); } -static void client_connection_destroy(void *context) +static void client_connection_free(void *context) { struct client *client = context; @@ -561,7 +561,7 @@ static const struct smtp_server_callbacks smtp_callbacks = { .conn_state_changed = client_connection_state_changed, .conn_disconnect = client_connection_disconnect, - .conn_destroy = client_connection_destroy, + .conn_free = client_connection_free, }; static const struct submission_client_vfuncs submission_client_vfuncs = { -- 2.47.3