[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lwip-devel] [bug #64780] sockets.c: avoid useless events on accept
From: |
renzo davoli |
Subject: |
[lwip-devel] [bug #64780] sockets.c: avoid useless events on accept |
Date: |
Mon, 16 Oct 2023 09:40:16 -0400 (EDT) |
URL:
<https://savannah.nongnu.org/bugs/?64780>
Summary: sockets.c: avoid useless events on accept
Group: lwIP - A Lightweight TCP/IP stack
Submitter: rd235
Submitted: Mon 16 Oct 2023 03:40:14 PM CEST
Category: Contrib
Severity: 3 - Normal
Item Group: None
Status: None
Privacy: Public
Assigned to: None
Open/Closed: Open
Discussion Lock: Any
Planned Release: None
lwIP version: 2.2.0
_______________________________________________________
Follow-up Comments:
-------------------------------------------------------
Date: Mon 16 Oct 2023 03:40:14 PM CEST By: renzo davoli <rd235>
In src/api/sockets.c, in function lwip_accept, around line 700 the code has
the following structure:
---
send pending RECVPLUS events <---------------------------- XXX
if ((addr != NULL) && (addrlen != NULL)) {
/* get the IP address and port of the remote host */
err = netconn_peer(newconn, &naddr, &port);
if (err != ERR_OK) { <----------------------------------- YYY
abort
return -1
}
...
... print debug msg including addr and port
} else
... print debug msg (without addr/port)
...
return newsock
----
the code at XXX can send events to a socket that will never exist because
netconn_peer fails at YYY
This patch simply moves the code at XXX after YYY so that events will be
generated only for sockets that will be "seen" by the caller.
So the modified code is just
-----
if ((addr != NULL) && (addrlen != NULL)) {
/* get the IP address and port of the remote host */
err = netconn_peer(newconn, &naddr, &port);
if (err != ERR_OK) { <----------------------------------- YYY
abort
return -1
}
}
send pending RECVPLUS events <---------------------------- XXX
if ((addr != NULL) && (addrlen != NULL)) {
... print debug msg including addr and port
} else
... print debug msg (without addr/port)
...
return newsock
----
It is a simple, clean, reasonable, and, as far as I can see, safe patch.
_______________________________________________________
File Attachments:
-------------------------------------------------------
Date: Mon 16 Oct 2023 03:40:14 PM CEST Name:
socket_accept_avoid_useless_events.patch Size: 2KiB By: rd235
<http://savannah.nongnu.org/bugs/download.php?file_id=55245>
_______________________________________________________
Reply to this item at:
<https://savannah.nongnu.org/bugs/?64780>
_______________________________________________
Message sent via Savannah
https://savannah.nongnu.org/
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [lwip-devel] [bug #64780] sockets.c: avoid useless events on accept,
renzo davoli <=