Hi,
I'm having trouble with my http webserver, if I write
a lot of data to the outgoing socket. I'm basically
copying a file that is being POST'ed to the http server
back to the http client. Very predictably, after 69K of
data has been read and 79K of data has been written
(basically a copy of the input + HTML dressing), the
final call to sockets.c:lwip_write() hangs.
I've traced the hang to the infinite timeout at
lwip_write()
lwip_send()
netconn_write_partly()
TCPIP_APIMSG()
tcpip.c:tcpip_apimsg()
sys_arch_sem_wait(&apimsg->msg.conn->op_completed,
0); <- here
I've disabled almost everything in my application,
except for the LWIP related code and some trivial code
that flashes the LEDs and is unrelated. When I dump the
state of the FreeRTOS stack, I can see everything is
happily chugging along ... except for my suspended HTTP
task. So it is not the case that the stack is wedged,
but it seems to have ignored or did not reply to my API
call.
state name-------- free-- stk_top-
where-------------------------------------
Rdy0 IDLE 452 20000E7C
tasks(1933:4)
*Rdy3 tcpip_thread 5844 20002E9C
sys_arch(192:2)
Dlyd Eth_if 3084 20003CAC
xQueueGenericReceive/ethernetif(331:5)
Dlyd LEDx 44 20006D44
vTaskDelay/led_task(34:13)
Dlyd MAIN 1164 20000BB4
vTaskDelay/housekeeping(57:9)
Dlyd Tmr Svc 916 200013C4
timers(404:6)
Susp HTTP 3148 200049E4
xQueueGenericReceive/sys_arch(313:3)
-----------------------------------------------------------------------------
The code is basically calling read(socket, ...),
buffering it into single lines, then echo'ing the single
lines to write(socket,...). If I echo everything, it
hangs pretty repeated in the exact same line number of
data it reads from the scoket, around 1500. If I don't
echo everything, but just summarize the output, then it
doesn't hang.
I don't see any exception messages, no memory
errors, no nothing on my debug output. Here's what it
looks like-- you can see the last line before it hangs
is the call to lwip_send, without the confirmation back
from the tcpip thread.
... <snip several hundred calls to lwip_send (about
3000)> ....
lwip_recvfrom(1, 2001d544, 1500z, 0x0, ..)
lwip_recvfrom: top while
sock->lastdata=2001798c
lwip_recvfrom: buflen=1260 len=1500z off=0
sock->lastoffset=480
lwip_recvfrom: deleting netbuf=2001798c
lwip_recvfrom: top while sock->lastdata=0
lwip_recvfrom: netconn_recv err=0,
netbuf=20017f98
lwip_recvfrom: buflen=1260 len=720z off=780
sock->lastoffset=0
lwip_recvfrom(1): addr=192.168.0.125 port=61108
len=1500
lwip_recvfrom: lastdata now netbuf=20017f98
:1060A000020080B2EEE740F00400FAE740F008009A
lwip_send(1, data="" size=44z,
flags=0x0)
lwip_send(1) err=0 written=44z
lwip_send(1, data="" size=5z, flags=0x0)
lwip_send(1) err=0 written=5z
:1060B000F7E740F01000F4E72A290DD131680A1DF6
lwip_send(1, data="" size=44z,
flags=0x0)
lwip_send(1) err=0 written=44z
lwip_send(1, data="" size=5z, flags=0x0)
lwip_send(1) err=0 written=5z
:1060C00032600968F962002904D54942F96240F05A
lwip_send(1, data="" size=44z,
flags=0x0)
lwip_send(1) err=0 written=44z
lwip_send(1, data="" size=5z, flags=0x0)
lwip_send(1) err=0 written=5z
:1060D000040080B26D1C12E00021F96209E0F96A47
lwip_send(1, data="" size=44z,
flags=0x0)
lwip_send(1) err=0 written=44z
lwip_send(1, data="" size=5z, flags=0x0)
lwip_send(1) err=0 written=5z
:1060E000494505D001EB810302EB43013039F962E8
lwip_send(1, data="" size=44z,
flags=0x0)
lwip_send(1) err=0 written=44z
lwip_send(1, data="" size=5z, flags=0x0)
lwip_send(1) err=0 written=5z
:1060F0006D1C2A78A2F13001C9B20A29EFD32978A0
lwip_send(1, data="" size=44z,
flags=0x0)
lwip_send(1) err=0 written=44z
lwip_send(1, data="" size=5z, flags=0x0)
lwip_send(1) err=0 written=5z
:106100002E2903D04FF0FF31B9621DE015F8011FB1
lwip_send(1, data="" size=44z,
flags=0x0)