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);
/* 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);
/* 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 =
{
.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)
pool_unref(&client->pool);
}
-static void test_server_connection_destroy(void *context)
+static void test_server_connection_free(void *context)
{
struct client *client = context;
/* 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);
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,
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;
.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
};
client_disconnect(&client->common, reason);
}
-static void client_connection_destroy(void *context)
+static void client_connection_free(void *context)
{
struct submission_client *client = context;
.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
};
client_disconnect(client, NULL, reason);
}
-static void client_connection_destroy(void *context)
+static void client_connection_free(void *context)
{
struct client *client = context;
.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 = {