changeset 406:d12fa0b21a59 HEAD

STARTTLS was broken
author Timo Sirainen <tss@iki.fi>
date Thu, 10 Oct 2002 22:35:37 +0300
parents 576967cbd064
children 6edfb92319cf
files src/login/client.c src/login/ssl-proxy.c
diffstat 2 files changed, 11 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/login/client.c	Thu Oct 10 05:07:55 2002 +0300
+++ b/src/login/client.c	Thu Oct 10 22:35:37 2002 +0300
@@ -51,17 +51,25 @@
 	client_send_tagline(client, "OK Begin TLS negotiation now.");
 	io_buffer_send_flush(client->outbuf);
 
+	/* must be removed before ssl_proxy_new(), since it may
+	   io_add() the same fd. */
+	io_remove(client->io);
+
 	fd_ssl = ssl_proxy_new(client->fd);
 	if (fd_ssl != -1) {
 		client->tls = TRUE;
 		client->fd = fd_ssl;
 		client->inbuf->fd = fd_ssl;
 		client->outbuf->fd = fd_ssl;
+
+		i_assert(client->inbuf->io == NULL);
+		i_assert(client->outbuf->io == NULL);
 	} else {
 		client_send_line(client, " * BYE TLS handehake failed.");
 		client_destroy(client, "TLS handshake failed");
 	}
 
+	client->io = io_add(client->fd, IO_READ, client_input, client);
 	return TRUE;
 }
 
--- a/src/login/ssl-proxy.c	Thu Oct 10 05:07:55 2002 +0300
+++ b/src/login/ssl-proxy.c	Thu Oct 10 22:35:37 2002 +0300
@@ -290,6 +290,9 @@
 		return -1;
 	}
 
+	net_set_nonblock(sfd[0], TRUE);
+	net_set_nonblock(sfd[1], TRUE);
+
 	proxy = i_new(SSLProxy, 1);
 	proxy->refcount = 1;
 	proxy->state = state;