[dovecot-cvs] dovecot/src/master main.c,1.97,1.98

tss at dovecot.org tss at dovecot.org
Thu Jan 25 14:58:51 UTC 2007


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

Modified Files:
	main.c 
Log Message:
If we see exit for unknown child process, log an error but don't crash. If
net_listen() fails with EINTR, try again unless it was interrupted by
INT/TERM signal.



Index: main.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/master/main.c,v
retrieving revision 1.97
retrieving revision 1.98
diff -u -d -r1.97 -r1.98
--- main.c	28 Dec 2006 19:59:37 -0000	1.97
+++ main.c	25 Jan 2007 14:58:48 -0000	1.98
@@ -203,7 +203,8 @@
 	while ((pid = waitpid(-1, &status, WNOHANG)) > 0) {
 		/* get the type and remove from hash */
 		process_type = PID_GET_PROCESS_TYPE(pid);
-		PID_REMOVE_PROCESS_TYPE(pid);
+		if (process_type != PROCESS_TYPE_UNKNOWN)
+			PID_REMOVE_PROCESS_TYPE(pid);
 
 		abnormal_exit = TRUE;
 
@@ -211,9 +212,13 @@
 		process_type_name = process_names[process_type];
 		if (WIFEXITED(status)) {
 			status = WEXITSTATUS(status);
-			if (status == 0)
+			if (status == 0) {
 				abnormal_exit = FALSE;
-			else {
+				if (process_type == PROCESS_TYPE_UNKNOWN) {
+					i_error("unknown child %s exited "
+						"successfully", dec2str(pid));
+				}
+			} else {
 				msg = get_exit_status_message(status);
 				msg = msg == NULL ? "" :
 					t_strconcat(" (", msg, ")", NULL);
@@ -421,8 +426,18 @@
 		else {
 			for (i = 0; i < 10; i++) {
 				*fd = net_listen(ip, &port, 8);
-				if (*fd != -1 || errno != EADDRINUSE)
+				if (*fd != -1)
 					break;
+				if (errno == EADDRINUSE) {
+					/* retry */
+				} else if (errno == EINTR &&
+					   io_loop_is_running(ioloop)) {
+					/* SIGHUPing sometimes gets us here.
+					   we don't want to die. */
+				} else {
+					/* error */
+					break;
+				}
 
 				check_conflicts(ip, port, *proto);
 				if (!retry)



More information about the dovecot-cvs mailing list