]> Zhao Yanbai Git Server - minix.git/commitdiff
LWIP - fixed TCP panic when shutting down
authorTomas Hruby <tom@minix3.org>
Sun, 14 Oct 2012 20:18:12 +0000 (20:18 +0000)
committerLionel Sambuc <lionel@minix3.org>
Mon, 25 Mar 2013 15:51:25 +0000 (16:51 +0100)
- listening sockets do not handle some callbacks

servers/lwip/tcp.c

index 077b964df0318cd5d77defc38f59e9765967a55d..086484f0ad8e6ca30dbd57a1a72d0c9f70de43da 100644 (file)
@@ -156,10 +156,12 @@ static void tcp_op_close(struct socket * sock, __unused message * m)
                int err;
 
                /* we are not able to handle any callback anymore */
-               tcp_arg((struct tcp_pcb *)sock->pcb, NULL);
-               tcp_err((struct tcp_pcb *)sock->pcb, NULL);
-               tcp_sent((struct tcp_pcb *)sock->pcb, NULL);
-               tcp_recv((struct tcp_pcb *)sock->pcb, NULL);
+               if (((struct tcp_pcb *)sock->pcb)->state != LISTEN) {
+                       tcp_arg((struct tcp_pcb *)sock->pcb, NULL);
+                       tcp_err((struct tcp_pcb *)sock->pcb, NULL);
+                       tcp_sent((struct tcp_pcb *)sock->pcb, NULL);
+                       tcp_recv((struct tcp_pcb *)sock->pcb, NULL);
+               }
 
                err = tcp_close(sock->pcb);
                assert(err == ERR_OK);