Fix the nasty crash on socket closure bug. The bug was due to corrupting memory by wrongly assuming the LISTEN pcb had send, receive and error callbacks.

svn path=/branches/GSoC_2011/TcpIpDriver/; revision=52385
This commit is contained in:
Claudiu Mihail 2011-06-20 14:49:58 +00:00
parent 4b7e0f11d0
commit b320225fb2

View file

@ -330,20 +330,16 @@ void
LibTCPListenCallback(void *arg)
{
struct listen_callback_msg *msg = arg;
void *p;
ASSERT(msg);
DbgPrint("[lwIP, LibTCPListenCallback] Called\n");
p = msg->Pcb->callback_arg;
msg->NewPcb = tcp_listen_with_backlog(msg->Pcb, msg->Backlog);
if (msg->NewPcb)
{
tcp_arg(msg->NewPcb, p);
tcp_accept(msg->NewPcb, InternalAcceptEventHandler);
tcp_err(msg->NewPcb, InternalErrorEventHandler);
}
DbgPrint("[lwIP, LibTCPListenCallback] Done\n");
@ -641,9 +637,18 @@ LibTCPClose(struct tcp_pcb *pcb)
DbgPrint("[lwIP, LibTCPClose] pcb->state = %s\n", tcp_state_str[pcb->state]);
tcp_arg(pcb, NULL);
tcp_recv(pcb, NULL);
tcp_sent(pcb, NULL);
tcp_err(pcb, NULL);
/*
if this pcb is not in LISTEN state than it has
valid recv, send and err callbacks to cancel
*/
if (pcb->state != LISTEN)
{
tcp_recv(pcb, NULL);
tcp_sent(pcb, NULL);
tcp_err(pcb, NULL);
}
tcp_accept(pcb, NULL);
DbgPrint("[lwIP, LibTCPClose] Attempting to allocate memory for msg\n");