[dovecot-cvs] dovecot/src/master mail-process.c,1.71,1.72

cras at dovecot.org cras at dovecot.org
Sat Feb 12 16:05:45 EET 2005


Update of /var/lib/cvs/dovecot/src/master
In directory talvi:/tmp/cvs-serv3495/src/master

Modified Files:
	mail-process.c 
Log Message:
If setpriority() is found, allow userdb set mail processes' priority by
returning nice parameter.



Index: mail-process.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/master/mail-process.c,v
retrieving revision 1.71
retrieving revision 1.72
diff -u -d -r1.71 -r1.72
--- mail-process.c	12 Feb 2005 13:47:23 -0000	1.71
+++ mail-process.c	12 Feb 2005 14:05:41 -0000	1.72
@@ -18,6 +18,10 @@
 #include <syslog.h>
 #include <sys/stat.h>
 
+#ifdef HAVE_SYS_RESOURCE_H
+#  include <sys/resource.h>
+#endif
+
 static unsigned int mail_process_count = 0;
 
 static int validate_uid_gid(struct settings *set, uid_t uid, gid_t gid,
@@ -306,7 +310,7 @@
 	pid_t pid;
 	uid_t uid;
 	gid_t gid;
-	int i, err, ret, log_fd;
+	int i, err, ret, log_fd, nice;
 
 	// FIXME: per-group
 	if (mail_process_count == set->max_mail_processes) {
@@ -315,7 +319,7 @@
 	}
 
 	mail = home_dir = chroot_dir = system_user = "";
-	uid = gid = 0;
+	uid = gid = 0; nice = 0;
 	for (; *args != NULL; args++) {
 		if (strncmp(*args, "home=", 5) == 0)
 			home_dir = *args + 5;
@@ -323,6 +327,8 @@
 			mail = *args + 5;
 		else if (strncmp(*args, "chroot=", 7) == 0)
 			chroot_dir = *args + 7;
+		else if (strncmp(*args, "nice=", 5) == 0)
+			nice = atoi(*args + 5);
 		else if (strncmp(*args, "system_user=", 12) == 0)
 			system_user = *args + 12;
 		else if (strncmp(*args, "uid=", 4) == 0) {
@@ -383,6 +389,13 @@
 		return TRUE;
 	}
 
+#ifdef HAVE_SETPRIORITY
+	if (nice != 0) {
+		if (setpriority(PRIO_PROCESS, 0, nice) < 0)
+			i_error("setpriority(%d) failed: %m", nice);
+	}
+#endif
+
 	str_append(str, "master-");
 	var_expand(str, set->mail_log_prefix, var_expand_table);
 	log_set_prefix(log, str_c(str));



More information about the dovecot-cvs mailing list