diff src/imap-login/client-authenticate.c @ 2421:d141e1bfdd63 HEAD

We never do blocking reads/writes to network anymore. Changed imap and pop3 processes to use a single I/O loop. Not much tested yet, and currently LIST/LSUB may eat too much memory and APPEND eats all CPU.
author Timo Sirainen <tss@iki.fi>
date Sun, 15 Aug 2004 06:40:30 +0300
parents df0b936ae3ed
children d2fe9172e408
line wrap: on
line diff
--- a/src/imap-login/client-authenticate.c	Sun Aug 15 05:54:47 2004 +0300
+++ b/src/imap-login/client-authenticate.c	Sun Aug 15 06:40:30 2004 +0300
@@ -53,7 +53,6 @@
 	client_send_tagline(client, msg != NULL ?
 			    t_strconcat("NO ", msg, NULL) :
 			    "NO Authentication failed.");
-	o_stream_flush(client->output);
 
 	/* get back to normal client input */
 	if (client->common.io != NULL)
@@ -86,6 +85,9 @@
 				  const unsigned char *data, size_t size)
 {
 	buffer_t *buf;
+	const void *buf_data;
+	size_t buf_size;
+	ssize_t ret;
 
 	t_push();
 
@@ -95,9 +97,11 @@
 	base64_encode(data, size, buf);
 	buffer_append(buf, "\r\n", 2);
 
-	o_stream_send(client->output, buffer_get_data(buf, NULL),
-		      buffer_get_used_size(buf));
-	o_stream_flush(client->output);
+	buf_data = buffer_get_data(buf, &buf_size);
+	if ((ret = o_stream_send(client->output, buf_data, buf_size) < 0))
+		client_destroy(client, "Disconnected");
+	else if ((size_t)ret != buf_size)
+		client_destroy(client, "Transmit buffer full");
 
 	t_pop();
 }
@@ -315,6 +319,8 @@
 	info.remote_ip = client->common.ip;
 
 	client_ref(client);
+	o_stream_uncork(client->output);
+
 	client->common.auth_request =
 		auth_client_request_new(auth_client, NULL, &info,
 					authenticate_callback, client, &error);