# HG changeset patch # User Timo Sirainen # Date 1497612864 -10800 # Node ID 589993f80edaae45ef1a53738570f68fd24ba6ba # Parent 5f3709d309b92779b8c055d5157ba0afb49318b7 *-login: Add client_vfuncs.free() that is called when client refcount=0 This can be useful for plugins that want to run something after proxying ends. Use an empty default function so plugins can call super.free() without having to check if it's NULL. diff -r 5f3709d309b9 -r 589993f80eda src/imap-login/imap-login-client.c --- a/src/imap-login/imap-login-client.c Mon Jun 12 22:52:56 2017 +0300 +++ b/src/imap-login/imap-login-client.c Fri Jun 16 14:34:24 2017 +0300 @@ -768,6 +768,7 @@ imap_proxy_get_state, client_common_send_raw_data, imap_client_input_next_cmd, + client_common_default_free, }; static const struct login_binary imap_login_binary = { diff -r 5f3709d309b9 -r 589993f80eda src/imap-urlauth/imap-urlauth-login.c --- a/src/imap-urlauth/imap-urlauth-login.c Mon Jun 12 22:52:56 2017 +0300 +++ b/src/imap-urlauth/imap-urlauth-login.c Fri Jun 16 14:34:24 2017 +0300 @@ -176,6 +176,7 @@ NULL, client_common_send_raw_data, NULL, + client_common_default_free, }; static const struct login_binary imap_urlauth_login_binary = { diff -r 5f3709d309b9 -r 589993f80eda src/login-common/client-common.c --- a/src/login-common/client-common.c Mon Jun 12 22:52:56 2017 +0300 +++ b/src/login-common/client-common.c Fri Jun 16 14:34:24 2017 +0300 @@ -337,6 +337,9 @@ i_assert(client->destroyed); i_assert(client->login_proxy == NULL); + if (client->v.free != NULL) + client->v.free(client); + if (client->ssl_proxy != NULL) ssl_proxy_free(&client->ssl_proxy); if (client->input != NULL) @@ -361,6 +364,10 @@ return FALSE; } +void client_common_default_free(struct client *client ATTR_UNUSED) +{ +} + void client_destroy_oldest(void) { struct client *client; diff -r 5f3709d309b9 -r 589993f80eda src/login-common/client-common.h --- a/src/login-common/client-common.h Mon Jun 12 22:52:56 2017 +0300 +++ b/src/login-common/client-common.h Fri Jun 16 14:34:24 2017 +0300 @@ -106,6 +106,7 @@ void (*send_raw_data)(struct client *client, const void *data, size_t size); bool (*input_next_cmd)(struct client *client); + void (*free)(struct client *client); }; struct client { @@ -259,6 +260,7 @@ void client_send_raw(struct client *client, const char *data); void client_common_send_raw_data(struct client *client, const void *data, size_t size); +void client_common_default_free(struct client *client); void client_set_auth_waiting(struct client *client); void client_auth_send_challenge(struct client *client, const char *data); diff -r 5f3709d309b9 -r 589993f80eda src/pop3-login/client.c --- a/src/pop3-login/client.c Mon Jun 12 22:52:56 2017 +0300 +++ b/src/pop3-login/client.c Fri Jun 16 14:34:24 2017 +0300 @@ -334,6 +334,7 @@ pop3_proxy_get_state, client_common_send_raw_data, pop3_client_input_next_cmd, + client_common_default_free, }; static const struct login_binary pop3_login_binary = {