dovecot-2.2: master: host.domain lookups weren't cached, they we...

dovecot at dovecot.org dovecot at dovecot.org
Thu Oct 10 20:50:28 EEST 2013


details:   http://hg.dovecot.org/dovecot-2.2/rev/69179ca6007d
changeset: 16839:69179ca6007d
user:      Timo Sirainen <tss at iki.fi>
date:      Thu Oct 10 20:50:10 2013 +0300
description:
master: host.domain lookups weren't cached, they were done at the worst possible time.
This fixes "net_connect_unix(imap) failed: Resource temporarily unavailable"
and various other issues where processes weren't being created fast enough
if the host.domain lookup was slow (e.g. done via external DNS).

diffstat:

 src/master/service-process.c |  11 ++++++++---
 1 files changed, 8 insertions(+), 3 deletions(-)

diffs (49 lines):

diff -r dc46ae14008c -r 69179ca6007d src/master/service-process.c
--- a/src/master/service-process.c	Tue Oct 08 16:48:04 2013 +0300
+++ b/src/master/service-process.c	Thu Oct 10 20:50:10 2013 +0300
@@ -237,7 +237,8 @@
 }
 
 static void
-service_process_setup_environment(struct service *service, unsigned int uid)
+service_process_setup_environment(struct service *service, unsigned int uid,
+				  const char *hostdomain)
 {
 	master_service_env_clean();
 
@@ -257,7 +258,7 @@
 	}
 	env_put(t_strdup_printf(MASTER_UID_ENV"=%u", uid));
 	env_put(t_strdup_printf(MY_HOSTNAME_ENV"=%s", my_hostname));
-	env_put(t_strdup_printf(MY_HOSTDOMAIN_ENV"=%s", my_hostdomain()));
+	env_put(t_strdup_printf(MY_HOSTDOMAIN_ENV"=%s", hostdomain));
 
 	if (!service->set->master_set->version_ignore)
 		env_put(MASTER_DOVECOT_VERSION_ENV"="PACKAGE_VERSION);
@@ -291,6 +292,7 @@
 	static unsigned int uid_counter = 0;
 	struct service_process *process;
 	unsigned int uid = ++uid_counter;
+	const char *hostdomain;
 	pid_t pid;
 	bool process_forked;
 
@@ -305,6 +307,9 @@
 		   new processes now */
 		return NULL;
 	}
+	/* look this up before fork()ing so that it gets cached for all the
+	   future lookups. */
+	hostdomain = my_hostdomain();
 
 	if (service->type == SERVICE_TYPE_ANVIL &&
 	    service_anvil_global->pid != 0) {
@@ -323,7 +328,7 @@
 	}
 	if (pid == 0) {
 		/* child */
-		service_process_setup_environment(service, uid);
+		service_process_setup_environment(service, uid, hostdomain);
 		service_reopen_inet_listeners(service);
 		service_dup_fds(service);
 		drop_privileges(service);


More information about the dovecot-cvs mailing list