[dovecot-cvs] dovecot/src/dict dict-server.c, 1.5, 1.6 dict-server.h, 1.1, 1.2 main.c, 1.3, 1.4

cras at dovecot.org cras at dovecot.org
Thu Jan 12 01:47:07 EET 2006


Update of /var/lib/cvs/dovecot/src/dict
In directory talvi:/tmp/cvs-serv30509/dict

Modified Files:
	dict-server.c dict-server.h main.c 
Log Message:
Start dict server automatically when a client tries to connect to it.



Index: dict-server.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/dict/dict-server.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- dict-server.c	11 Jan 2006 21:48:14 -0000	1.5
+++ dict-server.c	11 Jan 2006 23:47:02 -0000	1.6
@@ -410,20 +410,21 @@
 	}
 }
 
-struct dict_server *dict_server_init(const char *path)
+struct dict_server *dict_server_init(const char *path, int fd)
 {
 	struct dict_server *server;
 	int i;
 
 	server = i_new(struct dict_server, 1);
 	server->path = i_strdup(path);
+	server->fd = fd;
 
-	for (i = 0; i < 2; i++) {
+	while (server->fd == -1) {
 		server->fd = net_listen_unix(path, 64);
 		if (server->fd != -1)
 			break;
 
-		if (errno != EADDRINUSE)
+		if (errno != EADDRINUSE || ++i == 2)
 			i_fatal("net_listen_unix(%s) failed: %m", path);
 
 		/* see if it really exists */

Index: dict-server.h
===================================================================
RCS file: /var/lib/cvs/dovecot/src/dict/dict-server.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- dict-server.h	30 Dec 2005 22:09:03 -0000	1.1
+++ dict-server.h	11 Jan 2006 23:47:02 -0000	1.2
@@ -3,7 +3,7 @@
 
 struct dict;
 
-struct dict_server *dict_server_init(const char *path);
+struct dict_server *dict_server_init(const char *path, int fd);
 void dict_server_deinit(struct dict_server *server);
 
 #endif

Index: main.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/dict/main.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- main.c	30 Dec 2005 22:18:44 -0000	1.3
+++ main.c	11 Jan 2006 23:47:02 -0000	1.4
@@ -14,6 +14,8 @@
 #include <stdlib.h>
 #include <syslog.h>
 
+#define DICT_MASTER_LISTENER_FD 3
+
 struct ioloop *ioloop;
 
 static struct module *modules;
@@ -42,6 +44,9 @@
 
 static void main_init(void)
 {
+	const char *path;
+	int fd;
+
 	lib_signals_init();
         lib_signals_set_handler(SIGINT, TRUE, sig_die, NULL);
         lib_signals_set_handler(SIGTERM, TRUE, sig_die, NULL);
@@ -54,7 +59,12 @@
 	modules = getenv("MODULE_DIR") == NULL ? NULL :
 		module_dir_load(getenv("MODULE_DIR"), TRUE);
 
-	dict_server = dict_server_init(DEFAULT_DICT_SERVER_SOCKET_PATH);
+	path = getenv("DICT_LISTEN_FROM_FD");
+	fd = path == NULL ? -1 : DICT_MASTER_LISTENER_FD;
+	if (path == NULL)
+		path = DEFAULT_DICT_SERVER_SOCKET_PATH;
+
+	dict_server = dict_server_init(path, fd);
 }
 
 static void main_deinit(void)
@@ -75,7 +85,7 @@
 {
 #ifdef DEBUG
 	if (getenv("GDB") == NULL)
-		fd_debug_verify_leaks(3, 1024);
+		fd_debug_verify_leaks(DICT_MASTER_LISTENER_FD+1, 1024);
 #endif
 
 	/* NOTE: we start rooted, so keep the code minimal until



More information about the dovecot-cvs mailing list