I ran into a problem today with apache blocking on a read. When
ap_http_filter was getting called with AP_MODE_EATCRLF and
block=APR_NONBLOCKREAD
the bucket brigade was blocking (see socket_bucket_read).
I am not 100% sure how the bucket brigades are supposed to work on a
nonblocking read, but please critique this patch. The patch applies to APR.
Backtrace:
#0 0x0fd10614 in read () from /lib/libc.so.6
#1 0x0fe86244 in apr_socket_recv (sock=0x10113f20,
buf=0x1011c370 "GET / HTTP/1.1\r\nHost: 192.168.0.120\r\nUser-Agent:
Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.1.3) Gecko/20070309
Firefox/2.0.0.3\r\nAccept:
text/xml,application/xml,application/xhtml+xml,text/html;q="...,
len=0x7fc298dc) at network_io/unix/sendrecv.c:81
#2 0x0ff00ba4 in socket_bucket_read (a=0x10118410, str=0x7fc298d8,
len=0x7fc298dc, block=Variable "block" is not available.
) at buckets/apr_buckets_socket.c:36
#3 0x44002082 in ?? ()
#4 0x1002c9cc in ap_core_input_filter (f=0x101144d0, b=0x1011b8b0,
mode=Variable "mode" is not available.
) at core_filters.c:188
#5 0x44002024 in ?? ()
#6 0x1003a00c in ap_get_brigade (next=Variable "next" is not available.
) at util_filter.c:489
#7 0x1003db70 in ap_http_filter (f=0x1011b4f8, b=0x1011b8b0,
mode=AP_MODE_EATCRLF, block=APR_NONBLOCK_READ, readbytes=0) at
http_filters.c:88
#8 0x1003a00c in ap_get_brigade (next=Variable "next" is not available.
) at util_filter.c:489
#9 0x1003d4b0 in ap_process_request (r=0x1011a390) at http_request.c:212
#10 0x1003a7fc in ap_process_http_connection (c=0x101140b8) at
http_core.c:184
#11 0x10036220 in ap_run_process_connection (c=0x101140b8) at
connection.c:43
#12 0x10041654 in child_main (child_num_arg=Variable "child_num_arg" is not
available.
) at prefork.c:640
#13 0x10041820 in make_child (s=0x10074f90, slot=0) at prefork.c:680
#14 0x100422f4 in ap_mpm_run (_pconf=Variable "_pconf" is not available.
) at prefork.c:956
#15 0x22002022 in ?? ()
#16 0x10018d64 in main (argc=2, argv=0x7fc29cf4) at main.c:717
Index: sockopt.c
===================================================================
--- sockopt.c (revision 532161)
+++ sockopt.c (working copy)
@@ -102,7 +102,7 @@
/* must disable the incomplete read support if we disable
* a timeout
*/
- if (t <= 0) {
+ if (t < 0) {
sock->options &= ~APR_INCOMPLETE_READ;
}
sock->timeout = t;