Re: select()/socket has problems under 2.2.x.

Andi Kleen (ak@muc.de)
Sun, 7 Mar 1999 19:56:48 +0100


On Sun, Mar 07, 1999 at 07:19:36PM +0100, Andrea Arcangeli wrote:
> Today I again thought a bit about the issue.
>
> Since I still think that the user can set any sndbuf/rcvbuf and expect to
> still have a working socket, and I think that sndbuf/rcvbuf is just an
> hint on how much data to queue, I taken the approch to smart change rcvbuf
> when it is going to cause deadlocking. I think this approch is better than
> going to play with the mss of the sender because the other end could not
> care about our advertised mss and because this way will automagically work
> also if somebody will set the rcvbuf while the tcp connection is just
> established.

The MSS idea would not have worked anyways. The broken programs usually do:

sk = accept(...);
silly_value = 512;
setsockopt(sk, SO_RCVBUF, &silly_value, ...);

And after the accept the 3way handshake is already finished and you can't change
the MSS anymore.
>
> I also fixed the TCP to always send back an ack to the other end (since I
> understood by Alan's email of yesterday, that this thing has to happen) if
> we are forced to drop the incoming packet because we have just a lot of
> data queued.

If the data is dropped it cannot be acked. Acking earlier data does not make
any sense, because the other end cannot do anything more than to retransmit,
and it should do that anyways even when we send no ack. What Alan said is that
Linux must process all ack or window update information in the dropped packet,
and this is guaranteed anyways because tcp_ack is unconditionally called before
tcp_data. Sending an ack is only required when out of order data arrives (but strictly
only when it is accepted,which it isn't in this case). It may still be nice.
Also disabling header prediction is not required (the user may eat the buffer backlog
and everything could be fine again when the next retransmit arrives)

Now I must say your latest iteration of the deadlock fix looks ok for me, although
I think you should move the logic to a common function that is called by both prune_queue
and the setsockopt code.

-Andi

-
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/