Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 7513

SDK • Another tcp_client issue

$
0
0
Once again an obscure bug. First let me thank the rpi guys for both the tcp_client example and the python server to test it. Great.

I am deconstructing the example to be more generic so I can do a pico to pico connection to pass server state around. Using the sample code and test server I can successfully handle a connection to a linux server and pass the data. My stuff is also running a httpd server (more later).

I have found a failure in the LWIP tcp code, that is reproducible but still obscure.

1) If I connect to the server, pass the data everything is good.

2) If I don't find the server either by dns or ip addressing, it fails - expected.

3) If I find the server but it does not have a port listener it fails and continues as expected. BUT!

The sample tcp_client handles all 3 of these cases and exits when done, even on failure. Fine.

In my code, for cases 1 and 2 of the client start, the httpd stuff works fine for many times. On case 3, my problem is I can fetch the website html one time. But on the second attempt (either browser or wget), I get this:

Code:

                                                                                                                                       *** PANIC ***                                                                                                                          tcp_pcbs_sane: tw pcb->state == TIME-WAIT
This comes out of the tcp.c tcp_pcbs_sane function, looking at internal pcb->state of all its active pcbs. I certainly don't understand the lwip state machine. Things work when there is no server or when there is a server and a port, but it seems we have a pcb uncleaned situation where a connect fails when the server exists on the network but does not have a server on the port.

A comment on the tcp.c tcp_err function says:
@note The corresponding pcb is already freed when this callback is called!

The problem is future tcp calls (like wget) reveals the pcb corruption and lwip crashes.

The example just exits and will never see the problem, which lives in the tcp lists. Anyone know how to clean up and continue after this half connected failure state?

Statistics: Posted by nospamcalfee — Sat Jun 28, 2025 11:54 pm — Replies 0 — Views 30



Viewing all articles
Browse latest Browse all 7513

Trending Articles