[dovecot-cvs] dovecot/src/pop3 client.c, 1.60, 1.61 client.h, 1.11, 1.12

cras at dovecot.org cras at dovecot.org
Sun Jan 29 14:14:52 EET 2006


Update of /var/lib/cvs/dovecot/src/pop3
In directory talvi:/tmp/cvs-serv19474/pop3

Modified Files:
	client.c client.h 
Log Message:
Call io_remove() before closing the fd. It's required by kqueue.



Index: client.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/pop3/client.c,v
retrieving revision 1.60
retrieving revision 1.61
diff -u -d -r1.60 -r1.61
--- client.c	14 Jan 2006 18:48:17 -0000	1.60
+++ client.c	29 Jan 2006 12:14:50 -0000	1.61
@@ -13,6 +13,7 @@
 #include "mail-search.h"
 
 #include <stdlib.h>
+#include <unistd.h>
 
 /* max. length of input command line (spec says 512) */
 #define MAX_INBUF_SIZE 2048
@@ -127,24 +128,27 @@
 	return FALSE;
 }
 
-struct client *client_create(int hin, int hout, struct mail_storage *storage)
+struct client *client_create(int fd_in, int fd_out,
+			     struct mail_storage *storage)
 {
 	struct client *client;
         enum mailbox_open_flags flags;
 	bool syntax_error, temporary_error;
 
 	/* always use nonblocking I/O */
-	net_set_nonblock(hin, TRUE);
-	net_set_nonblock(hout, TRUE);
+	net_set_nonblock(fd_in, TRUE);
+	net_set_nonblock(fd_out, TRUE);
 
 	client = i_new(struct client, 1);
-	client->input = i_stream_create_file(hin, default_pool,
+	client->fd_in = fd_in;
+	client->fd_out = fd_out;
+	client->input = i_stream_create_file(fd_in, default_pool,
 					     MAX_INBUF_SIZE, FALSE);
-	client->output = o_stream_create_file(hout, default_pool,
+	client->output = o_stream_create_file(fd_out, default_pool,
 					      (size_t)-1, FALSE);
 	o_stream_set_flush_callback(client->output, client_output, client);
 
-	client->io = io_add(hin, IO_READ, client_input, client);
+	client->io = io_add(fd_in, IO_READ, client_input, client);
         client->last_input = ioloop_time;
 	client->storage = storage;
 
@@ -234,6 +238,13 @@
 	i_stream_unref(&client->input);
 	o_stream_unref(&client->output);
 
+	if (close(client->fd_in) < 0)
+		i_error("close(client in) failed: %m");
+	if (client->fd_in != client->fd_out) {
+		if (close(client->fd_out) < 0)
+			i_error("close(client out) failed: %m");
+	}
+
 	i_free(client);
 
 	/* quit the program */

Index: client.h
===================================================================
RCS file: /var/lib/cvs/dovecot/src/pop3/client.h,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -d -r1.11 -r1.12
--- client.h	14 May 2005 20:32:08 -0000	1.11
+++ client.h	29 Jan 2006 12:14:50 -0000	1.12
@@ -7,7 +7,7 @@
 typedef void command_func_t(struct client *client);
 
 struct client {
-	int socket;
+	int fd_in, fd_out;
 	struct io *io;
 	struct istream *input;
 	struct ostream *output;
@@ -46,7 +46,8 @@
 
 /* Create new client with specified input/output handles. socket specifies
    if the handle is a socket. */
-struct client *client_create(int hin, int hout, struct mail_storage *storage);
+struct client *client_create(int fd_in, int fd_out,
+			     struct mail_storage *storage);
 void client_destroy(struct client *client, const char *reason);
 
 /* Disconnect client connection */



More information about the dovecot-cvs mailing list