Re: Problem with recv syscall on socket when other side closed connection

Denis Perchine (dyp@solo.iis.nsk.su)
Tue, 27 Jun 2000 13:48:28 +0700


> >> > > > The if I try to continue read I will get the rest of the data which arrived between last read and
> >> > > > connection close... Very strange logic... Any comments on this.
> >> > >
> >> > > Indeed strange..
> >> >
> >> > That's why some people do not like linux... Such behavior breaks lots of programs.
> >>
> >> Assuming it is indeed the kernel that makes the error, and not your
> >> program that screws things up.
>
> > The problem occured in postgreSQL 7.0.2. And there is everything fine on FreeBSD & IRIX.
> > Only Linux have this problem.
>
> Which problem ? Why you can not stop clients and THEN stop server ? Or there
> STILL will be some problems ?

This is another question, but here is the answer.
Because sometimes they are situations happend when you cannot rely on the
assumption that client will react on you server's request to close the socket.
In the case of PostgreSQL it was the situation when server should die immediatly.
This happend when you do shutdown or when part of the shared memory is corrupted
and futher work will lead to data inconsistency. In such cases server writes the reason to
socket and closes connection.

There's the following behavior seen on other platforms:
1. Just allow to read all data which was send before connection close, then
return 0. Similar to EOF.
2. Allow to read all data and then return ECONNRESET.

As far as I can understand correct behavior is (1). At least in Socket FAQ it is stated
that programming logic which will assume closed by other side connection means
'QUIT' on the protocol level is acceptable.

Also such kernel behavior leads to the situation like this:
Client send: 'quit'
Server replies 'OK Bye!' and closed connection.
And on the client side I get EPIPE and sometimes full reply, sometimes
only part of it, or nothing.

> > But I still do not hear the voice of the people who maintain this part of the kernel...
>
> You assuming there are such person :-) It's wrong assumation. AFAIK it was
> written by Alan Cox and last who played with is was Andrea Arcangeli so there
> are no special maintainer for that code...

:-((((

-- 
Sincerely Yours,
Denis Perchine

---------------------------------- E-Mail: dyp@perchine.com HomePage: http://www.perchine.com/dyp/ FidoNet: 2:5000/120.5 ----------------------------------

- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.tux.org/lkml/