]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
Make sure calling client_destroy() multiple times doesn't break anything.
authorTimo Sirainen <tss@iki.fi>
Tue, 11 Feb 2003 16:56:35 +0000 (18:56 +0200)
committerTimo Sirainen <tss@iki.fi>
Tue, 11 Feb 2003 16:56:35 +0000 (18:56 +0200)
--HG--
branch : HEAD

src/imap-login/client.c
src/imap-login/client.h
src/pop3-login/client.c
src/pop3-login/client.h

index e1627d46b1b3ac5a4ea69c7543510d16feabfac0..543cdb9593f678e49caf0b251ed4ae0579d9a049 100644 (file)
@@ -362,12 +362,18 @@ struct client *client_create(int fd, struct ip_addr *ip, int ssl)
 
 void client_destroy(struct imap_client *client, const char *reason)
 {
+       if (client->destroyed)
+               return;
+       client->destroyed = TRUE;
+
        if (reason != NULL)
                client_syslog(client, reason);
 
        hash_remove(clients, client);
 
        imap_parser_destroy(client->parser);
+       client->parser = NULL;
+
        i_stream_close(client->input);
        o_stream_close(client->output);
 
@@ -381,7 +387,6 @@ void client_destroy(struct imap_client *client, const char *reason)
                client->common.fd = -1;
        }
 
-       i_free(client->common.virtual_user);
        client_unref(client);
 }
 
@@ -399,6 +404,7 @@ int client_unref(struct imap_client *client)
        o_stream_unref(client->output);
 
        buffer_free(client->plain_login);
+       i_free(client->common.virtual_user);
        i_free(client);
 
        main_unref();
index 77ce15465302f0c0e88d5bbe4d09552a093854a8..1bdc7fe9091399166fbf9517c3bca5107dc825e8 100644 (file)
@@ -25,6 +25,7 @@ struct imap_client {
        unsigned int tls:1;
        unsigned int cmd_finished:1;
        unsigned int skip_line:1;
+       unsigned int destroyed:1;
 };
 
 struct client *client_create(int fd, struct ip_addr *ip, int ssl);
index 4b56ae25b680604ce0692d4a307c301813b5ef1b..9626a8da69f8b0ad96101aec721b59daff1a72ab 100644 (file)
@@ -261,6 +261,10 @@ struct client *client_create(int fd, struct ip_addr *ip, int ssl)
 
 void client_destroy(struct pop3_client *client, const char *reason)
 {
+       if (client->destroyed)
+               return;
+       client->destroyed = TRUE;
+
        if (reason != NULL)
                client_syslog(client, reason);
 
@@ -277,7 +281,6 @@ void client_destroy(struct pop3_client *client, const char *reason)
        net_disconnect(client->common.fd);
        client->common.fd = -1;
 
-       i_free(client->common.virtual_user);
        client_unref(client);
 }
 
@@ -295,6 +298,7 @@ int client_unref(struct pop3_client *client)
        o_stream_unref(client->output);
 
        buffer_free(client->plain_login);
+       i_free(client->common.virtual_user);
        i_free(client);
 
        main_unref();
index f5487fd5b8117916ccdf8c53ad3e92f8a3cde0c3..cd5cd4b848e5da2424bc816c2e7780e9589e21ed 100644 (file)
@@ -20,6 +20,7 @@ struct pop3_client {
        buffer_t *plain_login;
 
        unsigned int tls:1;
+       unsigned int destroyed:1;
 };
 
 struct client *client_create(int fd, struct ip_addr *ip, int ssl);