]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
*-login: Add client_vfuncs.free() that is called when client refcount=0
authorTimo Sirainen <timo.sirainen@dovecot.fi>
Fri, 16 Jun 2017 11:34:24 +0000 (14:34 +0300)
committerVille Savolainen <ville.savolainen@dovecot.fi>
Fri, 16 Jun 2017 13:08:22 +0000 (16:08 +0300)
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.

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

index d2673bfe97e39aeee075b768e50e54b7522b5ab8..93b5be7524b124a3b12530b20ffd0250aa06fffe 100644 (file)
@@ -768,6 +768,7 @@ static struct client_vfuncs imap_client_vfuncs = {
        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 = {
index 439ed89dedfb91efd8f41cb1bedbdcf43676d56e..5184559ac8bdbd7389de66647adf922bb21a59d8 100644 (file)
@@ -176,6 +176,7 @@ static struct client_vfuncs imap_urlauth_vfuncs = {
        NULL,
        client_common_send_raw_data,
        NULL,
+       client_common_default_free,
 };
 
 static const struct login_binary imap_urlauth_login_binary = {
index ab4656301056c1e4d7ca9c8d45f4f93e0995b32c..e62a8fef1f406045e7096bed93d61f51eeba34c5 100644 (file)
@@ -337,6 +337,9 @@ bool client_unref(struct client **_client)
        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 @@ bool client_unref(struct client **_client)
        return FALSE;
 }
 
+void client_common_default_free(struct client *client ATTR_UNUSED)
+{
+}
+
 void client_destroy_oldest(void)
 {
        struct client *client;
index c8142ab52d9dfc41f70773d539629dae6096f724..09e1c37d9cbbf527a9e2ca3c882dabcfd2826d65 100644 (file)
@@ -106,6 +106,7 @@ struct client_vfuncs {
        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_data(struct client *client, const void *data, size_t size);
 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);
index ae9c2ddb7c471b5bed648c25bd5c93a5ce536d3a..6b67507ff25113f16d218d35ed2e22ae1ab9916d 100644 (file)
@@ -334,6 +334,7 @@ static struct client_vfuncs pop3_client_vfuncs = {
        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 = {