dovecot-2.0: lib-master has now a global master_service variable...

dovecot at dovecot.org dovecot at dovecot.org
Sat May 23 00:40:56 EEST 2009


details:   http://hg.dovecot.org/dovecot-2.0/rev/0c587f108916
changeset: 9348:0c587f108916
user:      Timo Sirainen <tss at iki.fi>
date:      Fri May 22 17:26:27 2009 -0400
description:
lib-master has now a global master_service variable that all binaries use.
There should always be only one of them anyway.

diffstat:

34 files changed, 142 insertions(+), 146 deletions(-)
src/anvil/main.c                     |   14 ++++++--------
src/auth/auth-common.h               |    1 -
src/auth/auth-master-connection.c    |    2 +-
src/auth/auth-worker-client.c        |    2 +-
src/auth/main.c                      |   20 ++++++++++----------
src/config/doveconf.c                |   16 ++++++++--------
src/config/main.c                    |   16 +++++++---------
src/imap-login/client.c              |    5 +++--
src/imap/imap-client.c               |   10 +++++-----
src/imap/imap-common.h               |    2 --
src/imap/main.c                      |   16 ++++++++--------
src/lda/main.c                       |   22 ++++++++++++----------
src/lib-master/master-service.c      |    2 ++
src/lib-master/master-service.h      |    2 +-
src/lmtp/client.c                    |    4 ++--
src/lmtp/main.c                      |   12 ++++++------
src/lmtp/main.h                      |    1 -
src/log/common.h                     |    1 -
src/log/log-connection.c             |    2 +-
src/log/main.c                       |   16 ++++++++--------
src/login-common/common.h            |    1 -
src/login-common/login-proxy.c       |    2 +-
src/login-common/main.c              |   31 ++++++++++++++++---------------
src/login-common/sasl-server.c       |    3 ++-
src/login-common/ssl-proxy-openssl.c |    2 +-
src/master/common.h                  |    1 -
src/master/service-process.c         |    1 +
src/plugins/convert/convert-tool.c   |   15 +++++++--------
src/plugins/expire/expire-tool.c     |   16 ++++++++--------
src/pop3-login/client.c              |    5 +++--
src/pop3/main.c                      |   16 ++++++++--------
src/pop3/pop3-client.c               |   10 +++++-----
src/pop3/pop3-common.h               |    2 --
src/util/doveadm.c                   |   17 +++++++++--------

diffs (truncated from 1031 to 300 lines):

diff -r 79174ec42414 -r 0c587f108916 src/anvil/main.c
--- a/src/anvil/main.c	Fri May 22 13:07:17 2009 -0400
+++ b/src/anvil/main.c	Fri May 22 17:26:27 2009 -0400
@@ -12,8 +12,6 @@
 
 struct connect_limit *connect_limit;
 
-static struct master_service *service;
-
 static void client_connected(const struct master_service_connection *conn)
 {
 	anvil_connection_create(conn->fd);
@@ -23,20 +21,20 @@ int main(int argc, char *argv[])
 {
 	int c;
 
-	service = master_service_init("anvil", 0, argc, argv);
+	master_service = master_service_init("anvil", 0, argc, argv);
 	while ((c = getopt(argc, argv, master_service_getopt_string())) > 0) {
-		if (!master_service_parse_option(service, c, optarg))
+		if (!master_service_parse_option(master_service, c, optarg))
 			exit(FATAL_DEFAULT);
 	}
 
-	master_service_init_log(service, "anvil: ", 0);
-	master_service_init_finish(service);
+	master_service_init_log(master_service, "anvil: ", 0);
+	master_service_init_finish(master_service);
 	connect_limit = connect_limit_init();
 
-	master_service_run(service, client_connected);
+	master_service_run(master_service, client_connected);
 
 	connect_limit_deinit(&connect_limit);
 	anvil_connections_destroy_all();
-	master_service_deinit(&service);
+	master_service_deinit(&master_service);
         return 0;
 }
diff -r 79174ec42414 -r 0c587f108916 src/auth/auth-common.h
--- a/src/auth/auth-common.h	Fri May 22 13:07:17 2009 -0400
+++ b/src/auth/auth-common.h	Fri May 22 17:26:27 2009 -0400
@@ -4,7 +4,6 @@
 #include "lib.h"
 #include "auth.h"
 
-extern struct master_service *service;
 extern bool worker, shutdown_request;
 extern time_t process_start_time;
 
diff -r 79174ec42414 -r 0c587f108916 src/auth/auth-master-connection.c
--- a/src/auth/auth-master-connection.c	Fri May 22 13:07:17 2009 -0400
+++ b/src/auth/auth-master-connection.c	Fri May 22 17:26:27 2009 -0400
@@ -425,7 +425,7 @@ void auth_master_connection_destroy(stru
 		conn->fd = -1;
 	}
 
-        master_service_client_connection_destroyed(service);
+        master_service_client_connection_destroyed(master_service);
 	auth_master_connection_unref(&conn);
 }
 
diff -r 79174ec42414 -r 0c587f108916 src/auth/auth-worker-client.c
--- a/src/auth/auth-worker-client.c	Fri May 22 13:07:17 2009 -0400
+++ b/src/auth/auth-worker-client.c	Fri May 22 17:26:27 2009 -0400
@@ -617,7 +617,7 @@ void auth_worker_client_destroy(struct a
 	net_disconnect(client->fd);
 	client->fd = -1;
 
-        master_service_client_connection_destroyed(service);
+        master_service_client_connection_destroyed(master_service);
 }
 
 void auth_worker_client_unref(struct auth_worker_client **_client)
diff -r 79174ec42414 -r 0c587f108916 src/auth/main.c
--- a/src/auth/main.c	Fri May 22 13:07:17 2009 -0400
+++ b/src/auth/main.c	Fri May 22 17:26:27 2009 -0400
@@ -31,7 +31,6 @@ enum auth_socket_type {
 	AUTH_SOCKET_MASTER
 };
 
-struct master_service *service;
 bool worker = FALSE, shutdown_request = FALSE;
 time_t process_start_time;
 
@@ -54,7 +53,7 @@ static void main_preinit(struct auth_set
 	passdbs_init();
 	userdbs_init();
 	modules = module_dir_load(AUTH_MODULE_DIR, NULL, TRUE,
-				  master_service_get_version_string(service));
+			master_service_get_version_string(master_service));
 	module_dir_init(modules);
 	auth = auth_preinit(set);
 
@@ -85,7 +84,7 @@ static void main_init(void)
 	if (worker) {
 		/* workers have only a single connection from the master
 		   auth process */
-		master_service_set_client_limit(service, 1);
+		master_service_set_client_limit(master_service, 1);
 	} else if (getenv("MASTER_AUTH_FD") != NULL) {
 		(void)auth_master_connection_create(auth, MASTER_AUTH_FD);
 	}
@@ -163,8 +162,8 @@ int main(int argc, char *argv[])
 	const char *getopt_str, *auth_name = "default";
 	int c;
 
-	service = master_service_init("auth", 0, argc, argv);
-	master_service_init_log(service, "auth: ", 0);
+	master_service = master_service_init("auth", 0, argc, argv);
+	master_service_init_log(master_service, "auth: ", 0);
 
         getopt_str = t_strconcat("w", master_service_getopt_string(), NULL);
 	while ((c = getopt(argc, argv, getopt_str)) > 0) {
@@ -176,19 +175,20 @@ int main(int argc, char *argv[])
 			worker = TRUE;
 			break;
 		default:
-			if (!master_service_parse_option(service, c, optarg))
+			if (!master_service_parse_option(master_service,
+							 c, optarg))
 				exit(FATAL_DEFAULT);
 			break;
 		}
 	}
 
-	main_preinit(auth_settings_read(service, auth_name));
+	main_preinit(auth_settings_read(master_service, auth_name));
 
-	master_service_init_finish(service);
+	master_service_init_finish(master_service);
 	main_init();
-	master_service_run(service, worker ? worker_connected :
+	master_service_run(master_service, worker ? worker_connected :
 			   client_connected);
 	main_deinit();
-	master_service_deinit(&service);
+	master_service_deinit(&master_service);
         return 0;
 }
diff -r 79174ec42414 -r 0c587f108916 src/config/doveconf.c
--- a/src/config/doveconf.c	Fri May 22 13:07:17 2009 -0400
+++ b/src/config/doveconf.c	Fri May 22 17:26:27 2009 -0400
@@ -20,8 +20,6 @@ struct config_request_get_string_ctx {
 	pool_t pool;
 	ARRAY_TYPE(const_string) strings;
 };
-
-static struct master_service *service;
 
 static void
 config_request_get_strings(const char *key, const char *value,
@@ -212,8 +210,9 @@ int main(int argc, char *argv[])
 	int c;
 
 	memset(&filter, 0, sizeof(filter));
-	service = master_service_init("config", MASTER_SERVICE_FLAG_STANDALONE,
-				      argc, argv);
+	master_service = master_service_init("config",
+					     MASTER_SERVICE_FLAG_STANDALONE,
+					     argc, argv);
 	i_set_failure_prefix("doveconf: ");
 	getopt_str = t_strconcat("am:np:e", master_service_getopt_string(), NULL);
 	while ((c = getopt(argc, argv, getopt_str)) > 0) {
@@ -232,11 +231,12 @@ int main(int argc, char *argv[])
 			filter.service = optarg;
 			break;
 		default:
-			if (!master_service_parse_option(service, c, optarg))
+			if (!master_service_parse_option(master_service,
+							 c, optarg))
 				exit(FATAL_DEFAULT);
 		}
 	}
-	config_path = master_service_get_config_path(service);
+	config_path = master_service_get_config_path(master_service);
 
 	if (argv[optind] != NULL)
 		exec_args = &argv[optind];
@@ -246,7 +246,7 @@ int main(int argc, char *argv[])
 		printf("# "VERSION": %s\n", config_path);
 		fflush(stdout);
 	}
-	master_service_init_finish(service);
+	master_service_init_finish(master_service);
 
 	config_parse_file(config_path, FALSE);
 
@@ -265,6 +265,6 @@ int main(int argc, char *argv[])
 		execvp(exec_args[0], exec_args);
 		i_fatal("execvp(%s) failed: %m", exec_args[0]);
 	}
-	master_service_deinit(&service);
+	master_service_deinit(&master_service);
         return 0;
 }
diff -r 79174ec42414 -r 0c587f108916 src/config/main.c
--- a/src/config/main.c	Fri May 22 13:07:17 2009 -0400
+++ b/src/config/main.c	Fri May 22 17:26:27 2009 -0400
@@ -11,8 +11,6 @@
 #include <stdlib.h>
 #include <unistd.h>
 
-static struct master_service *service;
-
 static void client_connected(const struct master_service_connection *conn)
 {
 	config_connection_create(conn->fd);
@@ -22,18 +20,18 @@ int main(int argc, char *argv[])
 {
 	int c;
 
-	service = master_service_init("config", 0, argc, argv);
+	master_service = master_service_init("config", 0, argc, argv);
 	while ((c = getopt(argc, argv, master_service_getopt_string())) > 0) {
-		if (!master_service_parse_option(service, c, optarg))
+		if (!master_service_parse_option(master_service, c, optarg))
 			exit(FATAL_DEFAULT);
 	}
 
-	master_service_init_log(service, "config: ", 0);
-	master_service_init_finish(service);
-	config_parse_file(master_service_get_config_path(service), TRUE);
+	master_service_init_log(master_service, "config: ", 0);
+	master_service_init_finish(master_service);
+	config_parse_file(master_service_get_config_path(master_service), TRUE);
 
-	master_service_run(service, client_connected);
+	master_service_run(master_service, client_connected);
 	config_connections_destroy_all();
-	master_service_deinit(&service);
+	master_service_deinit(&master_service);
         return 0;
 }
diff -r 79174ec42414 -r 0c587f108916 src/imap-login/client.c
--- a/src/imap-login/client.c	Fri May 22 13:07:17 2009 -0400
+++ b/src/imap-login/client.c	Fri May 22 17:26:27 2009 -0400
@@ -575,7 +575,8 @@ void client_destroy(struct imap_client *
 	if (client->common.master_tag != 0) {
 		i_assert(client->common.auth_request == NULL);
 		i_assert(client->common.authenticating);
-		master_auth_request_abort(service, client->common.master_tag);
+		master_auth_request_abort(master_service,
+					  client->common.master_tag);
 	} else if (client->common.auth_request != NULL) {
 		i_assert(client->common.authenticating);
 		sasl_server_auth_client_error(&client->common, NULL);
@@ -653,7 +654,7 @@ bool client_unref(struct imap_client *cl
 
 	if (!client->common.proxying) {
 		i_assert(client->common.proxy == NULL);
-		master_service_client_connection_destroyed(service);
+		master_service_client_connection_destroyed(master_service);
 	}
 
 	i_free(client->common.virtual_user);
diff -r 79174ec42414 -r 0c587f108916 src/imap/imap-client.c
--- a/src/imap/imap-client.c	Fri May 22 13:07:17 2009 -0400
+++ b/src/imap/imap-client.c	Fri May 22 17:26:27 2009 -0400
@@ -72,8 +72,8 @@ struct client *client_create(int fd_in, 
 
 	ident = mail_user_get_anvil_userip_ident(client->user);
 	if (ident != NULL) {
-		master_service_anvil_send(service, t_strconcat("CONNECT\t",
-			my_pid, "\t", ident, "/imap\n", NULL));
+		master_service_anvil_send(master_service, t_strconcat(
+			"CONNECT\t", my_pid, "\t", ident, "/imap\n", NULL));
 		client->anvil_sent = TRUE;
 	}
 
@@ -184,8 +184,8 @@ void client_destroy(struct client *clien
 		mailbox_close(&client->mailbox);
 	}
 	if (client->anvil_sent) {
-		master_service_anvil_send(service, t_strconcat("DISCONNECT\t",
-			my_pid, "\t",
+		master_service_anvil_send(master_service, t_strconcat(
+			"DISCONNECT\t", my_pid, "\t",
 			mail_user_get_anvil_userip_ident(client->user), "/imap"
 			"\n", NULL));
 	}
@@ -219,7 +219,7 @@ void client_destroy(struct client *clien
 
 	/* quit the program */
 	my_client = NULL;
-	master_service_stop(service);
+	master_service_stop(master_service);
 }
 
 void client_disconnect(struct client *client, const char *reason)
diff -r 79174ec42414 -r 0c587f108916 src/imap/imap-common.h
--- a/src/imap/imap-common.h	Fri May 22 13:07:17 2009 -0400
+++ b/src/imap/imap-common.h	Fri May 22 17:26:27 2009 -0400
@@ -23,8 +23,6 @@ enum client_workarounds {
 #include "imap-client.h"
 #include "imap-settings.h"
 
-extern struct master_service *service;
-
 extern void (*hook_client_created)(struct client **client);


More information about the dovecot-cvs mailing list