D&C Lug - Home Page
Devon & Cornwall Linux Users' Group

[ Date Index ][ Thread Index ]
[ <= Previous by date / thread ] [ Next by date / thread => ]

Re: [LUG] Strange network / perl problem



On Mon, Jul 08, 2002 at 02:34:18PM +0100, Theo Zourzouvillys wrote:

server writing faster than client could read?

doh, yup - that one :p

Surely the server blocks until the client's buffer is not full.

That sounds pretty fscked up. I was under the impression you only got
a sigpipe when it was all a bit broken. eg. you were writing to a
socket that your peer closed.

you get a pIPE when the connection is closed, whatever
cuircumstances, iirc.

That's just not true, I'm afraid.
 
IT's to insicate to the process that tehre is activity on the socket and it 
needs to do something.

Nah, you can select() on the socket (and others) to get that kind of
information.  There is no need to jump out of your code for that.

 for somereason the default sigaction is terminate though.

Well, that's easy:

cat very big log files over a month | logmaker | head

cat is cat

logmaker takes stdin andproduces a summary for each day. 

head is something like:

while (<>) {

     print;
     exit if ++$line == 10; # yes I know there is a perlvar for this
}

So this unix command line will show us the first 10 days produced by
the log summary process.

OK, so head exits after the 10th day. Its end of the pipe is closed.

logmaker writes the 11th summary
logmaker gets a sigpipe for writing to a pipe with the other end closed
logmaker exits. Other pipe is closed.

cat gets a sigpipe for writing to a pipe with the other end closed
cat exits

processor gasps with relief

It would be a waste of tome keep catting and making logs, since
they are going nowhere. This is why the default action for SIGPIPE is
exit, since in the general case, it means the reciever of your data
has lost interest in you and you should stop trying to talk to it.

Anyway ...

If you are getting is sigpipe, its cos your writing to a file handle
that's got nowt on the other end. 

So, what's getting the sigpipe, the client or the server?

Steve

--
The Mailing List for the Devon & Cornwall LUG
Mail majordomo@xxxxxxxxxxxx with "unsubscribe list" in the
message body to unsubscribe.


Lynx friendly