changeset 22242:589993f80eda

*-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.
author Timo Sirainen <timo.sirainen@dovecot.fi>
date Fri, 16 Jun 2017 14:34:24 +0300
parents 5f3709d309b9
children 72574d93be61
files src/imap-login/imap-login-client.c src/imap-urlauth/imap-urlauth-login.c src/login-common/client-common.c src/login-common/client-common.h src/pop3-login/client.c
diffstat 5 files changed, 12 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- 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 = {
--- 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 = {
--- 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;
--- 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);
--- 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 = {