changeset 1714:96dab004a87a HEAD

fixes. maybe it works now.
author Timo Sirainen <tss@iki.fi>
date Fri, 22 Aug 2003 21:56:59 +0300
parents 6a1586f04640
children 8bb3216773d6
files 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
diffstat 8 files changed, 54 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/src/imap-login/client-authenticate.c	Fri Aug 22 18:40:12 2003 +0300
+++ b/src/imap-login/client-authenticate.c	Fri Aug 22 21:56:59 2003 +0300
@@ -80,6 +80,8 @@
 		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 @@
 		   disconnect the client. */
                 client->authenticating = FALSE;
 		client_send_tagline(client, "OK Logged in.");
+		client_unref(client);
 	}
 }
 
@@ -181,6 +184,7 @@
 	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 @@
 	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 @@
 		   disconnect the client. */
                 client->authenticating = FALSE;
 		client_send_tagline(client, "OK Logged in.");
+		client_unref(client);
 	}
 }
 
@@ -304,6 +310,7 @@
 		return TRUE;
 	}
 
+	client_ref(client);
 	client->common.auth_request =
 		auth_client_request_new(auth_client, mech->mech,
 					AUTH_PROTOCOL_IMAP,
@@ -319,6 +326,7 @@
 	} else {
 		client_send_tagline(client, t_strconcat(
 			"NO Authentication failed: ", error, NULL));
+		client_unref(client);
 	}
 
 	return TRUE;
--- a/src/imap-login/client.c	Fri Aug 22 18:40:12 2003 +0300
+++ b/src/imap-login/client.c	Fri Aug 22 21:56:59 2003 +0300
@@ -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 @@
 		return;
 	}
 
-	client->refcount++;
+	client_ref(client);
 
 	o_stream_cork(client->output);
 	while (client_handle_input(client)) ;
@@ -409,7 +407,12 @@
 	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;
--- a/src/imap-login/client.h	Fri Aug 22 18:40:12 2003 +0300
+++ b/src/imap-login/client.h	Fri Aug 22 21:56:59 2003 +0300
@@ -40,6 +40,9 @@
 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);
 
--- a/src/lib-auth/auth-server-request.c	Fri Aug 22 18:40:12 2003 +0300
+++ b/src/lib-auth/auth-server-request.c	Fri Aug 22 21:56:59 2003 +0300
@@ -147,17 +147,28 @@
 }
 
 static void request_hash_remove(void *key __attr_unused__, void *value,
-				void *context __attr_unused__)
+				void *context)
 {
 	struct auth_request *request = value;
+        struct auth_server_connection *conn = context;
 
-	request->callback(request, NULL, NULL, request->context);
-	request->conn = NULL;
+	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 @@
 	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);
 }
--- a/src/lib-index/mail-cache.c	Fri Aug 22 18:40:12 2003 +0300
+++ b/src/lib-index/mail-cache.c	Fri Aug 22 21:56:59 2003 +0300
@@ -727,7 +727,7 @@
 		return TRUE;
 	}
 
-	ret = mail_cache_open_and_verify(cache, FALSE);
+	ret = mail_cache_open_and_verify(cache, TRUE);
 	if (ret != 0)
 		return ret > 0;
 
--- a/src/pop3-login/client-authenticate.c	Fri Aug 22 18:40:12 2003 +0300
+++ b/src/pop3-login/client-authenticate.c	Fri Aug 22 21:56:59 2003 +0300
@@ -83,6 +83,8 @@
 		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 @@
 		/* 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 @@
 	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 @@
 	} else {
 		client_send_line(client,
 			t_strconcat("-ERR Login failed: ", error, NULL));
+		client_unref(client);
 		return TRUE;
 	}
 }
@@ -220,6 +225,7 @@
 		/* 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 @@
 		return TRUE;
 	}
 
+	client_ref(client);
 	client->common.auth_request =
 		auth_client_request_new(auth_client, mech->mech,
 					AUTH_PROTOCOL_POP3,
@@ -297,6 +304,7 @@
 	} else {
 		client_send_line(client, t_strconcat(
 			"-ERR Authentication failed: ", error, NULL));
+		client_unref(client);
 	}
 
 	return TRUE;
--- a/src/pop3-login/client.c	Fri Aug 22 18:40:12 2003 +0300
+++ b/src/pop3-login/client.c	Fri Aug 22 21:56:59 2003 +0300
@@ -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 @@
 		return;
 	}
 
-	client->refcount++;
+	client_ref(client);
 
 	o_stream_cork(client->output);
 	while (!client->output->closed &&
@@ -301,7 +299,12 @@
 	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;
--- a/src/pop3-login/client.h	Fri Aug 22 18:40:12 2003 +0300
+++ b/src/pop3-login/client.h	Fri Aug 22 21:56:59 2003 +0300
@@ -33,6 +33,9 @@
 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);