Re: Socket termination problem

Andi Kleen (ak@muc.de)
Fri, 26 Mar 1999 21:04:56 +0100


On Fri, Mar 26, 1999 at 07:43:36PM +0100, Henrik Laurila wrote:
> On 26 Mar 1999, Andi Kleen wrote:
>
> > > 3) The socket-state becomes CLOSE_WAIT, and will stay so until the
> > > sending process is killed.
> >
> > This is correct. CLOSE_WAIT means it waits for a close() from the
> > application, and a kill closes all open file descriptors.
> > Fix: call close() at the right time in your app.
>
> OK, from the kernels point of view this might be correct. The problem is
> that none of the failing applications have been mine... sendmail 8.9.0
> and several different POP3 daemons. So either all these are broken or the
> kernel has failed to notifies the applications. Shouldn't the socket send
> an EOF to the application if the peer terminates?

It does. The application is waken up if it is sleeping in poll/select,
otherwise it gets a SIGPIPE or SIGIO if any one of those is enabled.

>
>
> > > 4) If the sending process is killed, the socket-state will turn into
> > > LAST_ACK, and will stay so "forever".
> > >
> > > 5) This "forever", might sometimes only last for a few weeks or months.
> >
> > This should not happen. What does netstat -t --timers output for such a
> > socket?
>
> Proto Recv-Q Send-Q Local Address Foreign Address State Timer
> tcp 30 22112 130.235.92.230:18697 132.68.1.8:25 CLOSE_WAIT off(0.00/0)
> tcp 30 18433 130.235.92.230:6569 132.68.1.8:25 LAST_ACK off(0.00/0)
>
>
> > LAST-ACK means that it is waiting for the ack of the FIN just send.
> > If it does not appear the socket should be destroyed via a timer
> > after some time. When the other end retransmits packets (e.g. its FIN)
> > it is possible that the timer is always restarted. So what OS is the
> > peer running?
>
> In most cases, I have no idea. But in all cases I have known about the
> peer OS, it has been MacOS...
>
>
> > Is there any activity still on the connection (check with tcpdump) ?
>
> No activity.

If you can reproduce it could you supply a tcpdump of a connection that leads
to such a stuck socket?

-A.

-- 
This is like TV. I don't like TV.

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