You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by Dean Gaudet <dg...@arctic.org> on 1997/09/13 07:33:12 UTC

[PATCH] PR#1107: defend against linux select EFAULT

There's a dozen PRs about this and we really do think it's the kernel... 
but this does appear to be one way to work around it:  kill off the child
that gets stuck in an EFAULT select loop.

For 1.3 and 1.2 (with the appropriate logging change). 

Dean

Index: http_main.c
===================================================================
RCS file: /export/home/cvs/apachen/src/main/http_main.c,v
retrieving revision 1.221
diff -u -r1.221 http_main.c
--- http_main.c	1997/09/12 21:48:36	1.221
+++ http_main.c	1997/09/13 05:29:36
@@ -2851,8 +2851,18 @@
 		memcpy(&main_fds, &listenfds, sizeof(fd_set));
 		srv = ap_select(listenmaxfd+1, &main_fds, NULL, NULL, NULL);
 
-		if (srv < 0 && errno != EINTR)
+		if (srv < 0 && errno != EINTR) {
+#ifdef LINUX
+		    if (errno == EFAULT) {
+			aplog_error(APLOG_MARK, APLOG_ERR, server_conf,
+			    "select: (listen) fatal, exiting");
+			child_exit_modules (pconf, server_conf);
+			destroy_pool(pconf);
+			exit(1);
+		    }
+#endif
 		    aplog_error(APLOG_MARK, APLOG_ERR, server_conf, "select: (listen)");
+		}
 		
 		if (srv <= 0)
 		    continue;



Re: [PATCH] PR#1107: defend against linux select EFAULT

Posted by Marc Slemko <ma...@worldgate.com>.
+1.  Perhaps a comment saying "hmm... Linux seems broken, although it
could be Apache, so we have to do foo for bar".

I am quite suprised that this works; I had assumed that if the socket was
messed up it would be messed up for all the processes, but that doesn't
appear to be the way it is.

 On Fri, 12 Sep 1997, Dean Gaudet wrote:

> There's a dozen PRs about this and we really do think it's the kernel... 
> but this does appear to be one way to work around it:  kill off the child
> that gets stuck in an EFAULT select loop.
> 
> For 1.3 and 1.2 (with the appropriate logging change). 
> 
> Dean
> 
> Index: http_main.c
> ===================================================================
> RCS file: /export/home/cvs/apachen/src/main/http_main.c,v
> retrieving revision 1.221
> diff -u -r1.221 http_main.c
> --- http_main.c	1997/09/12 21:48:36	1.221
> +++ http_main.c	1997/09/13 05:29:36
> @@ -2851,8 +2851,18 @@
>  		memcpy(&main_fds, &listenfds, sizeof(fd_set));
>  		srv = ap_select(listenmaxfd+1, &main_fds, NULL, NULL, NULL);
>  
> -		if (srv < 0 && errno != EINTR)
> +		if (srv < 0 && errno != EINTR) {
> +#ifdef LINUX
> +		    if (errno == EFAULT) {
> +			aplog_error(APLOG_MARK, APLOG_ERR, server_conf,
> +			    "select: (listen) fatal, exiting");
> +			child_exit_modules (pconf, server_conf);
> +			destroy_pool(pconf);
> +			exit(1);
> +		    }
> +#endif
>  		    aplog_error(APLOG_MARK, APLOG_ERR, server_conf, "select: (listen)");
> +		}
>  		
>  		if (srv <= 0)
>  		    continue;
> 
>