lwip-devel
[Top][All Lists]
Advanced

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

[lwip-devel] [bug #62231] LwIP tcp socket stalls when "plug pulled", cre


From: Brendan McDonnell
Subject: [lwip-devel] [bug #62231] LwIP tcp socket stalls when "plug pulled", creates leak when closed
Date: Thu, 4 Jul 2024 13:52:04 -0400 (EDT)

Follow-up Comment #15, bug #62231 (group lwip):

[comment #13 comment #13:]
> Re comment #12:
> Looks like that patch may be correct.

Good news, thanks.

> However, I still don't get why we need this in the first place. Does anyone
think there's a memory leak bug in lwip that we want to work around by using
linger(0)? That would not be the best thing to do, in my opinion! If there's a
memory leak, try to find it and report us the fix! I'm not aware of any
problems in this area!

= Summary =

If an application times out on a TCP download, there are no unacked nor unsent
packets. The application wants to abort the transfer, close the socket and
free its resources immediately. Is linger(0) the way to do so? If not, what
is?

= Details =

My simplified test setup:

lwip_httpClient <---> ethSwitch1 <---> ethSwitch2 <---> httpServerPC

For the data download of an HTTP GET operation, my HTTP client application
uses lwip_select() (with a nonzero struct timeval) and lwip_recv(). While the
download is in progress, I break the link between ethSwitch[12], such that the
client application times out (lwip_select() returns 0). At the time, there are
neither any unsent nor any unacked data in the tcp pcb. My application -
wishing to send a TCP RST, abort the socket, and free the pcb/resources
immediately - calls its hardDisconnect() function (quoted below for
convenience).

Without my patch, lwip sends a TCP FIN (not RST), and the resources (tcp pcb,
etc) remain allocated until the TCP_MAXRTX (12) FIN retries timeout.

void hardDisconnect(int sock)
{
   struct linger linger =
   {
     .l_onoff  = 1,
     .l_linger = 0,
   };

   lwip_setsockopt(sock, SOL_SOCKET, SO_LINGER, &linger, sizeof linger);
   lwip_shutdown(sock, SHUT_RDWR);
   lwip_close(sock);
}




    _______________________________________________________

Reply to this item at:

  <https://savannah.nongnu.org/bugs/?62231>

_______________________________________________
Message sent via Savannah
https://savannah.nongnu.org/

Attachment: signature.asc
Description: PGP signature


reply via email to

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