zhhyu7 opened a new pull request, #17709:
URL: https://github.com/apache/nuttx/pull/17709
## Summary
after the listener fd is closed, the half-open connections associated
with the listener are not reclaimed. According to the protocol standard,
they should be reclaimed in a timely manner.
## Impact
tcp::listen
## Testing
sim:matter with test code
```
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <arpa/inet.h>
#include <signal.h>
#include <poll.h>
#define SERVER_IP "10.0.1.2"
#define PORT 7777
#define BUFFER_SIZE 1024
int main(int argc, char *argv[]) {
int sockfd;
struct sockaddr_in server_addr;
if ((sockfd = socket(AF_INET, SOCK_STREAM, 0)) < 0) {
perror("socket creation failed");
exit(EXIT_FAILURE);
}
memset(&server_addr, 0, sizeof(server_addr));
server_addr.sin_family = AF_INET;
server_addr.sin_port = htons(PORT);
if (inet_pton(AF_INET, SERVER_IP, &server_addr.sin_addr) <= 0) {
perror("invalid address");
close(sockfd);
exit(EXIT_FAILURE);
}
bind(sockfd, (struct sockaddr *)&server_addr, sizeof(server_addr));
listen(sockfd, 5);
sleep(10);
close(sockfd);
return 0;
}
```
test log without this patch
```
NuttShell (NSH) NuttX-12.12.0-RC0
MOTD: username=admin password=Administrator
nsh> cat /proc/net/tcp
nsh> hello
nsh>
nsh> cat /proc/net/tcp
TCP sl st flg ref tmr uack nrt txsz rxsz local_address
remote_address
1: 02 0 1 3 1 0 0 0 10.0.1.2:7777
10.0.1.1:60678
nsh>
```
test log with this patch
```
NuttShell (NSH) NuttX-12.12.0-RC0
MOTD: username=admin password=Administrator
nsh> hello
nsh>
nsh> cat /proc/net/tcp
nsh>
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]