[En-Nut-Discussion] Race condition and stack overflow in tcpsm.c

Philipp Burch phip at hb9etc.ch
Fri Nov 21 08:10:05 CET 2014


Hi Ole!

On 20.11.2014 23:43, Ole Reinhardt wrote:
> Hi Philipp, Hi Harald,
> 
>>>> [...]
> 
> Well, but what about the following solution? This should fix the problem
> with standard Nut/OS functions instead of using application candy and
> does not allow other threads to use the thread variables...
> 
> HANDLE tcp_initialised = SIGNALED;
> 
> int NutTcpInitStateMachine(void)
> {
>     int rc = 0;
>     NutEventWait(&tcp_initialised, NUT_WAIT_INFINITE);
>     if (tcpThread == NULL) {
>         tcpThread = NutThreadCreate("tcpsm", NutTcpSm, NULL,
> NUT_THREAD_TCPSMSTACK * NUT_THREAD_STACK_MULT + NUT_THREAD_STACK_ADD);
>         if (tcpThread == NULL) {
>             rc = -1;
>         }
>     }
>     NutEventPost(&tcp_initialised);
>     return rc;
> }

Hm, using an already SIGNALED queue seems clever ;)
I'll test that and post back the results.

Thanks!

Regards,
Philipp


More information about the En-Nut-Discussion mailing list