[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Chicken-users] pipeline.egg
From: |
Hans Bulfone |
Subject: |
Re: [Chicken-users] pipeline.egg |
Date: |
Tue, 10 Jan 2006 23:41:32 +0100 |
User-agent: |
Mutt/1.4.2.1i |
hi,
On Mon, Jan 09, 2006 at 08:21:28AM +0100, felix winkelmann wrote:
> > i'd suggest adding procedures like fd->input-port and fd->output-port
> > to chicken to reduce the amount of code duplication.
>
> Yes, that makes sense. I'm a bit busy in the moment but will do that
> as soon as I get around doing it.
thank you.
> > also, i've wondered why the ##sys#thread-block-for-i/o! call for the
> > output port is commented out in tcp.scm and not present at all in
> > posix.scm.
>
> I just tried to remove synchronization points, and it seems to work ok.
> Would it be safer to add it again?
imho yes, because if the reading end of the connection reads too slow,
the sender eats all cpu time repeatedly trying to write.
for example, if you serve a large file using spiffy (i've used a 100mb
file, but according to the truss output, 1mb would have been enough)
and fetch it using a very slow http client[1], the following happens:
fd 5 = http server listening socket
fd 6 = connection to slow http client
[...]
sendto(0x6,0xbfbf8a74,0,0x0,NULL,0x0) = 1 (0x1)
sendto(0x6,0x81487e4,0,0x0,NULL,0x0) = 10 (0xa)
sendto(0x6,0xbfbf7594,0,0x0,NULL,0x0) = 1 (0x1)
sendto(0x6,0xbfbf6ea4,0,0x0,NULL,0x0) = 1 (0x1)
sendto(0x6,0xbfbf67b4,0,0x0,NULL,0x0) = 1 (0x1)
sendto(0x6,0xbfbf60c4,0,0x0,NULL,0x0) = 1 (0x1)
==> http headers are sent...
open("./test.dat",0x0,0744) = 7 (0x7)
getrusage(0x0,0xbfbf4ce0) = 0 (0x0)
getrusage(0x0,0xbfbf4ce0) = 0 (0x0)
sigprocmask(0x3,0x2835a93c,0x0) = 0 (0x0)
break(0x81e3000) = 0 (0x0)
break(0x826a000) = 0 (0x0)
read(0x7,0x817e790,0x186a0) = 100000 (0x186a0)
sendto(0x6,0x817e790,0,0x0,NULL,0x0) = 42888 (0xa788)
sendto(0x6,0xbfbef624,0,0x0,NULL,0x0) = 43008 (0xa800)
sigprocmask(0x1,0x0,0x28311b5c) = 0 (0x0)
sigprocmask(0x3,0x2835a93c,0x0) = 0 (0x0)
sendto(0x6,0x81a4df4,0,0x0,NULL,0x0) = 14104 (0x3718)
read(0x7,0x817e790,0x186a0) = 100000 (0x186a0)
sendto(0x6,0x817e790,0,0x0,NULL,0x0) = 14568 (0x38e8)
==> test.dat is opened and the first few kb are sent
sigprocmask(0x1,0x0,0x28311b5c) = 0 (0x0)
sigprocmask(0x3,0x2835a93c,0x0) = 0 (0x0)
sendto(0x6,0x81a8590,0,0x0,NULL,0x0) ERR#35 'Resource temporarily
unavailable'
select(1024,{5},{},0x0,{0 0}) = 0 (0x0)
sendto(0x6,0x81a8590,0,0x0,NULL,0x0) ERR#35 'Resource temporarily
unavailable'
select(1024,{5},{},0x0,{0 0}) = 0 (0x0)
sendto(0x6,0x81a8590,0,0x0,NULL,0x0) ERR#35 'Resource temporarily
unavailable'
select(1024,{5},{},0x0,{0 0}) = 0 (0x0)
sendto(0x6,0x81a8590,0,0x0,NULL,0x0) ERR#35 'Resource temporarily
unavailable'
select(1024,{5},{},0x0,{0 0}) = 0 (0x0)
sendto(0x6,0x81a8590,0,0x0,NULL,0x0) ERR#35 'Resource temporarily
unavailable'
select(1024,{5},{},0x0,{0 0}) = 0 (0x0)
sendto(0x6,0x81a8590,0,0x0,NULL,0x0) ERR#35 'Resource temporarily
unavailable'
==> further sendto() calls fail because the output buffer space of the
socket is exhausted. the server now eats all available cpu time
trying to send the file. select() is only used for the
listening socket.
[1] i've used the following client:
#!/usr/local/bin/csi -script
(require-extension http-client posix)
(receive (r h i o) (http:send-request "http://localhost:1234/test.dat")
(printf "Result: ~a\n" r)
(for-each (lambda (x) (printf " ~a: ~a\n" (car x) (cdr x))) h)
(let loop ()
(unless (eof-object? (read-char i))
(sleep 1)
(loop))))
regards,
hans.