Created attachment 24571 [details] The patch file for apr-1.3.5/network_io/sockets.c Problem description: The issue occurred when I used Apache HTTP server 2.2.11 and apr1.3.5 under PPC platform. The Apache HTTP server couldn't respond the HEAD message under following environment: 1. Apache HTTP server is configured with multiple ports. 2. When compiling APR, with APR_O_NONBLOCK_INHERITED enabled. 3. Apache HTTP server is running on PPC platform. Root Cause: After investigation, I found that there is a small bug when accepting a new conneciton. In function apr_socket_accept of file apr-1.3.5/network_io/sockets.c, if the new socket finds its father socket is in non-blocking mode, it calls apr_set_option to change the non-blocking mode. However, the function apr_set_option only changes the value in struct apr_socket_t, and the real non-blocking mode of the socket has not been modified. So I think we'd better call function apr_socket_opt_set to set the real non-blocking mode of the new socket. Please see attached for the patched file. Thanks, Tony
Problem description: The issue occurred when I used Apache HTTP server 2.2.11 and apr1.3.5 under PPC platform. The Apache HTTP server couldn't respond the HEAD message under following environment: 1. Apache HTTP server is configured with multiple ports. 2. When compiling APR, with APR_O_NONBLOCK_INHERITED enabled. 3. Apache HTTP server is running on PPC platform. Root Cause: After investigation, I found that there is a small bug when accepting a new conneciton. In function apr_socket_accept of file apr-1.3.5/network_io/sockets.c, if the new socket finds its father socket is in non-blocking mode, it calls apr_set_option to change the non-blocking mode. However, the function apr_set_option only changes the value in struct apr_socket_t, and the real non-blocking mode of the socket has not been modified. So I think we'd better call function apr_socket_opt_set to set the real non-blocking mode of the new socket. Please see attached for the patched file. Thanks, Tony
What exactly do you mean by >2. When compiling APR, with APR_O_NONBLOCK_INHERITED enabled. Did you set that yourself? If so, that's invalid. It isn't intended as a user setting except in the theoretical exceptional situation where APR configure doesn't set it properly. On my 2.6.27-someubuntufoo kernel APR sets it automatically to 0. I expect it should have the same setting on any somewhat modern Linux kernel regardless of architecture.
Hi Jeff, Thanks for your attention. I haven't set it myself. After running cnofigure` command, I found the macro has been set as 1. I guess maybe it's because I compiled it on the powerpc platform. And I still think it's a bug, because the function apr_set_option only set the flag in the structure apr_socket_t, and the non-blocking mode recorded by operating system hasn't been modified. I think here we should call function apr_socket_opt_set to set the non-blocking mode. This function can modify the real non-blocking mode. Thanks, Tony
>I haven't set it myself. After running cnofigure` command, I found the macro >has been set as 1. Thanks for the clarification. >I guess maybe it's because I compiled it on the powerpc platform. Who knows? >And I still think it's a bug, Sure; the behavior you see, and comparison with other Linux boxes, indicates that the macro should have been set to 0 by configure. > because the function apr_set_option only set the >flag in the structure apr_socket_t, and the non-blocking mode recorded by >operating system hasn't been modified. Note that this logic is controlled by the configure-time detection, so it is that detection we need to explore. Work-around: Set this in your environment before running configure: export ac_cv_o_nonblock_inherited="no" (make sure you run "make distclean" between different build attempts) Finding the problem: Look for the message starting with "checking if O_NONBLOCK setting" in your config.log. Here's what that section looks like in my Linux build. Please post your version. configure:45431: checking if O_NONBLOCK setting is inherited from listening sockets configure:45550: /usr/bin/gcc -m32 -o conftest -O0 -g -Wall -Wmissing-prototypes -Wstrict-prototypes -Wmissing-declarations -pthread -DLINUX=2 -D_REENTRANT -D_GNU_SOURCE -D_LARGEFILE64_SOURCE conftest.c -lrt -lcrypt -lpthread -ldl >&5 conftest.c: In function 'main': conftest.c:218: warning: implicit declaration of function 'exit' conftest.c:218: warning: incompatible implicit declaration of built-in function 'exit' conftest.c:220: warning: implicit declaration of function 'memset' conftest.c:220: warning: incompatible implicit declaration of built-in function 'memset' conftest.c:229: warning: incompatible implicit declaration of built-in function 'exit' conftest.c:236: warning: incompatible implicit declaration of built-in function 'exit' conftest.c:242: warning: incompatible implicit declaration of built-in function 'exit' conftest.c:247: warning: incompatible implicit declaration of built-in function 'exit' conftest.c:252: warning: incompatible implicit declaration of built-in function 'exit' conftest.c:264: warning: incompatible implicit declaration of built-in function 'exit' conftest.c:270: warning: incompatible implicit declaration of built-in function 'exit' conftest.c:275: warning: incompatible implicit declaration of built-in function 'exit' conftest.c:279: warning: incompatible implicit declaration of built-in function 'exit' configure:45553: $? = 0 configure:45559: ./conftest O_NONBLOCK is not set in the child. configure:45562: $? = 1