]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
fixes. maybe it works now.
authorTimo Sirainen <tss@iki.fi>
Fri, 22 Aug 2003 18:56:59 +0000 (21:56 +0300)
committerTimo Sirainen <tss@iki.fi>
Fri, 22 Aug 2003 18:56:59 +0000 (21:56 +0300)
--HG--
branch : HEAD

src/imap-login/client-authenticate.c
src/imap-login/client.c
src/imap-login/client.h
src/lib-auth/auth-server-request.c
src/lib-index/mail-cache.c
src/pop3-login/client-authenticate.c
src/pop3-login/client.c
src/pop3-login/client.h

index 0452c2807a23285c0f7282c286a30cbf2ff07a7f..6ff93ad0ed527f5a4df06d7630bd675cf7efad74 100644 (file)
@@ -80,6 +80,8 @@ static void client_auth_abort(struct imap_client *client, const char *msg)
                io_remove(client->common.io);
        client->common.io = client->common.fd == -1 ? NULL :
                io_add(client->common.fd, IO_READ, client_input, client);
+
+       client_unref(client);
 }
 
 static void master_callback(struct client *_client, int success)
@@ -146,6 +148,7 @@ static void login_callback(struct auth_request *request,
                   disconnect the client. */
                 client->authenticating = FALSE;
                client_send_tagline(client, "OK Logged in.");
+               client_unref(client);
        }
 }
 
@@ -181,6 +184,7 @@ int cmd_login(struct imap_client *client, struct imap_arg *args)
        buffer_append_c(client->plain_login, '\0');
        buffer_append(client->plain_login, pass, strlen(pass));
 
+       client_ref(client);
        client->common.auth_request =
                auth_client_request_new(auth_client, AUTH_MECH_PLAIN,
                                        AUTH_PROTOCOL_IMAP, login_callback,
@@ -188,6 +192,7 @@ int cmd_login(struct imap_client *client, struct imap_arg *args)
        if (client->common.auth_request == NULL) {
                client_send_tagline(client, t_strconcat(
                        "NO Login failed: ", error, NULL));
+               client_unref(client);
                return TRUE;
        }
 
@@ -224,6 +229,7 @@ static void authenticate_callback(struct auth_request *request,
                   disconnect the client. */
                 client->authenticating = FALSE;
                client_send_tagline(client, "OK Logged in.");
+               client_unref(client);
        }
 }
 
@@ -304,6 +310,7 @@ int cmd_authenticate(struct imap_client *client, struct imap_arg *args)
                return TRUE;
        }
 
+       client_ref(client);
        client->common.auth_request =
                auth_client_request_new(auth_client, mech->mech,
                                        AUTH_PROTOCOL_IMAP,
@@ -319,6 +326,7 @@ int cmd_authenticate(struct imap_client *client, struct imap_arg *args)
        } else {
                client_send_tagline(client, t_strconcat(
                        "NO Authentication failed: ", error, NULL));
+               client_unref(client);
        }
 
        return TRUE;
index a844c71b30534655e825c2a1cbdc95b8c316de28..35da157a3c5a26ae91b25361047846bdbc689d45 100644 (file)
@@ -41,8 +41,6 @@
 static struct hash_table *clients;
 static struct timeout *to_idle;
 
-static int client_unref(struct imap_client *client);
-
 static void client_set_title(struct imap_client *client)
 {
        const char *addr;
@@ -286,7 +284,7 @@ void client_input(void *context)
                return;
        }
 
-       client->refcount++;
+       client_ref(client);
 
        o_stream_cork(client->output);
        while (client_handle_input(client)) ;
@@ -409,7 +407,12 @@ void client_destroy(struct imap_client *client, const char *reason)
        client_unref(client);
 }
 
-static int client_unref(struct imap_client *client)
+void client_ref(struct imap_client *client)
+{
+       client->refcount++;
+}
+
+int client_unref(struct imap_client *client)
 {
        if (--client->refcount > 0)
                return TRUE;
index e963bc494da1cbcc5a690f157d9ca611c4e0225a..ffb219b1cd8e6553a023b5259dc73c303638f33f 100644 (file)
@@ -40,6 +40,9 @@ void client_syslog(struct imap_client *client, const char *text);
 int client_read(struct imap_client *client);
 void client_input(void *context);
 
+void client_ref(struct imap_client *client);
+int client_unref(struct imap_client *client);
+
 void clients_init(void);
 void clients_deinit(void);
 
index cba0be7fe2e15d0156de975c26a4f9ffd43e99c0..abd15186ee59641dc0b08c84f119461b8e0f9737 100644 (file)
@@ -147,17 +147,28 @@ void auth_server_request_handle_reply(struct auth_server_connection *conn,
 }
 
 static void request_hash_remove(void *key __attr_unused__, void *value,
-                               void *context __attr_unused__)
+                               void *context)
 {
        struct auth_request *request = value;
-
-       request->callback(request, NULL, NULL, request->context);
-       request->conn = NULL;
+        struct auth_server_connection *conn = context;
+
+       if (request->conn == conn) {
+               if (request->next_conn == NULL) {
+                       request->callback(request, NULL, NULL,
+                                         request->context);
+                       request->conn = NULL;
+               } else {
+                       request->conn = request->next_conn;
+                       request->next_conn = NULL;
+               }
+       } else {
+               request->next_conn = NULL;
+       }
 }
 
 void auth_server_requests_remove_all(struct auth_server_connection *conn)
 {
-       hash_foreach(conn->requests, request_hash_remove, NULL);
+       hash_foreach(conn->requests, request_hash_remove, conn);
 }
 
 struct auth_request *
@@ -224,6 +235,8 @@ void auth_client_request_abort(struct auth_request *request)
        if (request->next_conn != NULL)
                hash_remove(request->next_conn->requests, id);
 
+       request->callback(request, NULL, NULL, request->context);
+
        i_free(request->plaintext_data);
        i_free(request);
 }
index f6e1649887263f9730141b42d695c93a2c3ad6a1..36c0860b6410a126f0e568f5f0cba15752de2514 100644 (file)
@@ -727,7 +727,7 @@ int mail_cache_truncate(struct mail_cache *cache)
                return TRUE;
        }
 
-       ret = mail_cache_open_and_verify(cache, FALSE);
+       ret = mail_cache_open_and_verify(cache, TRUE);
        if (ret != 0)
                return ret > 0;
 
index 1cb028031e7021b6cb17c2d6cfbc4b503b17391c..9fcc3ea49405c79422d69ba52cbd21f7dc3dcf49 100644 (file)
@@ -83,6 +83,8 @@ static void client_auth_abort(struct pop3_client *client, const char *msg)
                io_remove(client->common.io);
        client->common.io = client->common.fd == -1 ? NULL :
                io_add(client->common.fd, IO_READ, client_input, client);
+
+       client_unref(client);
 }
 
 static void master_callback(struct client *_client, int success)
@@ -148,6 +150,7 @@ static void login_callback(struct auth_request *request,
                /* success, we should be able to log in. if we fail, just
                   disconnect the client. */
                client_send_line(client, "+OK Logged in.");
+               client_unref(client);
        }
 }
 
@@ -180,6 +183,7 @@ int cmd_pass(struct pop3_client *client, const char *args)
        buffer_append_c(client->plain_login, '\0');
        buffer_append(client->plain_login, args, strlen(args));
 
+       client_ref(client);
        client->common.auth_request =
                auth_client_request_new(auth_client, AUTH_MECH_PLAIN,
                                        AUTH_PROTOCOL_POP3,
@@ -194,6 +198,7 @@ int cmd_pass(struct pop3_client *client, const char *args)
        } else {
                client_send_line(client,
                        t_strconcat("-ERR Login failed: ", error, NULL));
+               client_unref(client);
                return TRUE;
        }
 }
@@ -220,6 +225,7 @@ static void authenticate_callback(struct auth_request *request,
                /* success, we should be able to log in. if we fail, just
                   disconnect the client. */
                client_send_line(client, "+OK Logged in.");
+               client_unref(client);
        }
 }
 
@@ -284,6 +290,7 @@ int cmd_auth(struct pop3_client *client, const char *args)
                return TRUE;
        }
 
+       client_ref(client);
        client->common.auth_request =
                auth_client_request_new(auth_client, mech->mech,
                                        AUTH_PROTOCOL_POP3,
@@ -297,6 +304,7 @@ int cmd_auth(struct pop3_client *client, const char *args)
        } else {
                client_send_line(client, t_strconcat(
                        "-ERR Authentication failed: ", error, NULL));
+               client_unref(client);
        }
 
        return TRUE;
index 4d45addaade87f00feff2efad3921e29306e9c48..95db8d7b7a2062900ebcec21ed316a81a9d88927 100644 (file)
@@ -35,8 +35,6 @@
 static struct hash_table *clients;
 static struct timeout *to_idle;
 
-static int client_unref(struct pop3_client *client);
-
 static void client_set_title(struct pop3_client *client)
 {
        const char *addr;
@@ -166,7 +164,7 @@ void client_input(void *context)
                return;
        }
 
-       client->refcount++;
+       client_ref(client);
 
        o_stream_cork(client->output);
        while (!client->output->closed &&
@@ -301,7 +299,12 @@ void client_destroy(struct pop3_client *client, const char *reason)
        client_unref(client);
 }
 
-static int client_unref(struct pop3_client *client)
+void client_ref(struct pop3_client *client)
+{
+       client->refcount++;
+}
+
+int client_unref(struct pop3_client *client)
 {
        if (--client->refcount > 0)
                return TRUE;
index a1742a95a0db43587aae75d5b5854de61d1f040b..ede69f871e86384408735f5fddde051a80613a44 100644 (file)
@@ -33,6 +33,9 @@ void client_syslog(struct pop3_client *client, const char *text);
 int client_read(struct pop3_client *client);
 void client_input(void *context);
 
+void client_ref(struct pop3_client *client);
+int client_unref(struct pop3_client *client);
+
 void clients_init(void);
 void clients_deinit(void);