httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dean gaudet <d...@arctic.org>
Subject pipelined HTTP/1.1 request
Date Sun, 07 Jan 2001 19:27:41 GMT
% cat >req
GET /index.html.en HTTP/1.1
Host: arctic.org:8888

GET /index.html.en HTTP/1.1
Host: arctic.org:8888

^D
% nc arctic.org 8888 < req > resp

results in this strace:

accept(5, {sin_family=AF_INET, sin_port=htons(2151), sin_addr=inet_addr("204.107.140.52")}},
[16]) = 8
rt_sigaction(SIGUSR1, {SIG_IGN}, {0x807f774, [], SA_INTERRUPT|0x4000000}, 8) = 0
setsockopt(8, IPPROTO_TCP1, [1], 4)     = 0
getsockname(8, {sin_family=AF_INET, sin_port=htons(8888), sin_addr=inet_addr("204.107.140.52")}},
[16]) = 0
fcntl(8, F_GETFL)                       = 0x2 (flags O_RDWR)
fcntl(8, F_SETFL, O_RDWR|O_NONBLOCK)    = 0
read(8, "GET /index.html.en HTTP/1.1\nHost"..., 8192) = 102
gettimeofday({978894801, 277613}, NULL) = 0
stat("/home/dean/ap2/htdocs/index.html.en", {st_mode=S_IFREG|0664, st_size=1349, ...}) = 0
open("/home/dean/ap2/htdocs/index.html.en", O_RDONLY) = 9
write(4, "204.107.140.52 - - [07/Jan/2001:"..., 87) = 87
gettimeofday({978894801, 278770}, NULL) = 0
stat("/home/dean/ap2/htdocs/index.html.en", {st_mode=S_IFREG|0664, st_size=1349, ...}) = 0
open("/home/dean/ap2/htdocs/index.html.en", O_RDONLY) = 10
getsockopt(8, IPPROTO_TCP, 1, [1], [4]) = 0
setsockopt(8, IPPROTO_TCP1, [0], 4)     = 0
setsockopt(8, IPPROTO_TCP3, [1], 4)     = 0
writev(8, [{"HTTP/1.1 200 OK\r\nDate: Sun, 07 J"..., 275}], 1) = 275
sendfile(8, 9, [0], 1349)               = 1349
writev(8, [{"HTTP/1.1 200 OK\r\nDate: Sun, 07 J"..., 275}], 1) = 275
setsockopt(8, IPPROTO_TCP3, [0], 4)     = 0
setsockopt(8, IPPROTO_TCP1, [1], 4)     = 0
read(8, 0x814cfb0, 8192)                = -1 EAGAIN (Resource temporarily unavailable)
sendfile(8, 10, [0], 1349)              = 1349
write(4, "204.107.140.52 - - [07/Jan/2001:"..., 87) = 87
read(8, 0x814cfb0, 8192)                = -1 EAGAIN (Resource temporarily unavailable)
select(9, [8], NULL, NULL, {15, 0})     = 0 (Timeout)
gettimeofday({978894816, 275011}, NULL) = 0
shutdown(8, 1 /* send */)               = 0
gettimeofday({978894816, 275329}, NULL) = 0
read(8, "", 512)                        = 0
close(8)                                = 0
rt_sigaction(SIGUSR1, {0x807f774, [], SA_INTERRUPT|0x4000000}, {SIG_IGN}, 8) = 0
close(10)                               = 0
close(9)                                = 0
accept(5,  <unfinished ...>

weird --  the "setsockopt(8, IPPROTO_TCP3, [0], 4)" is the popping of the
CORK.  why does it occur between the second writev and the second sendfile?
this will result in suboptimal network packets.

as i suggested in the last message i think the solution is to remember
the cork/NODELAY state in the socket and delay changes as long as possible.

note that this is the case where the "halfduplex"/"saferead" stuff in
1.3 comes into play.  i haven't yet looked through the i/o layer, but
the only way to properly pack network packets in a pipelined request is
to be able to test for a blocking read, and then cause a flush (to the
network) if the read would block.

in the context of 2.0 this means the CORK pretty much needs to be
controlled by httpd, not by APR...  or httpd needs to be able to set
something equivalent to SAFEREAD on the socket.

another bug is that the close(9) of the /index.html.en file is delayed
until the end of the connection rather than the end of the request.
this is a resource leak... i bet it's just registered into the wrong pool.
it should be on the request pool, not the connection pool.  (or maybe
we're just lacking a request cleanup?  it happens even when un-pipelined)

-dean


Mime
View raw message