lwip-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [lwip-devel] [task #6930] Implement SO_LINGER


From: Berglund Magnus
Subject: Re: [lwip-devel] [task #6930] Implement SO_LINGER
Date: Thu, 28 Jun 2007 08:55:05 +0200

> Follow-up Comment #9, task #6930 (project lwip):
> 
> Not that I would really need netconn_close() since lwip_close() calls
> netconn_delete() but doesn't netconn_close/do_close simply have to call
> tcp_close() instead of tcp_output()? That way it would be the same behaviour
> for both (tcp timers and wait-states handle unsent/unacked data).
> 
> I've attached a patch for this. We then can also remove conn->sem since it
> was only used for write/close errors.

I've been seeing some strange behaviour in 1.2.0 related to the fact that 
do_close does not call tcp_close if the state is ESTABLISHED.

What happens is the following:

1. The app calls:
   netconn_write() (a couple of time really fast),
   netconn_close()
   netconn_delete()

2. netconn_write() fills up the send queue to TCP_SND_QUEUELEN
   The loop condition in netconn_write loops until there is room on the 
sendqueue.

3. netconn_close() does nothing in do_close() since the state is ESTABLISHED.

4. netconn_delete()/do_delconn() does the following:
   - Calls tcp_close(). At this time the send queue is still full since no ack 
has been
     received for the sent packets. tcp_close() will therefore fail with EMEM.
   - tcp_abort is called, and the connection is aborted.

I have done a similar patch to your patch to do_close, and this seems to fix my 
problem.
This is due to the fact that netconn_close will loop and wait for space to be 
available on the sendqueue before returning.

I think your patch to do_close is correct since tcp_close handles all the pcb 
states.
But I think maybe a loop similiar to the one in netconn_close is still needed. 
Otherwise, if the sendqueue is full the close will fail.

What do you think?

--
/Magnus Berglund




reply via email to

[Prev in Thread] Current Thread [Next in Thread]