]> 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)
committerTimo Sirainen <timo.sirainen@dovecot.fi>
Fri, 16 Jun 2017 11:41:53 +0000 (14:41 +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 15e0539e7fd6c43e21a0bf38b386d6768fdb59a8..f6e1d01febe8ef21ebfcbdeb40534bc6dcbe2b75 100644 (file)
@@ -786,6 +786,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 004ac95b4af66ef4ea6c0081ada467af1a754b32..fe0d4558828b795441099673d6ab983b920366db 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 5648be3188d0665ad28291e779362a8abee3aa79..2f5f696c2e267ae7eee58ebc9464817728309f15 100644 (file)
@@ -335,6 +335,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)
@@ -359,6 +362,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 ff5ba0a1dfddad8c853e21cb316ceafea738b42a..90b57c86662eeced41c2bcc7bfff910d0d401060 100644 (file)
@@ -123,6 +123,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 {
@@ -273,6 +274,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 = {