[En-Nut-Discussion] NutTcpConnect freeze

András Szemző szemzo.andras at gmail.com
Tue Jan 5 13:15:02 CET 2010


Hi,

I have a couple of AVR based modules with GPRS connection. There are a very rare cases ( It can be 3 weeks, or 3 months without a restart)
when NutTcpConnect fails to return. Nut 4.3.3 is the base, there was a commit for such a bug, but that one is before this release.

Becouse it's very rare case, I cannot debug this easily, but in my opinion there must be something happen with the other side, strange network done etc..
and what I seen before the socket will remain in SYN SENT state, and than nothing happens, that thread will be blocked forever.

I don't really know Nut tcp state machine internals, but could't these block come from here?

int NutTcpStateActiveOpenEvent(TCPSOCKET * sock)
{
    /*
     * Switch state to SYN_SENT. This will
     * transmit a SYN packet.
     */
    NutTcpStateChange(sock, TCPS_SYN_SENT);

    /*
     * Block application.
     */
	 if(sock->so_state == TCPS_SYN_SENT)
		NutEventWait(&sock->so_ac_tq, 0);

    if (sock->so_state != TCPS_ESTABLISHED)
        return -1;

    return 0;
}


The NutEventWait will block forever.  It's safe to add a relative big timeout to event wait? Or there are other ideas?


Best Regards,
Andras
 


More information about the En-Nut-Discussion mailing list