[En-Nut-Discussion] Suggested modification to nut\net\tcpsm.c

ennut at thezachariasgroup.com ennut at thezachariasgroup.com
Fri May 4 07:16:22 CEST 2007


   Harold,
  In THREAD NutTcpSm in the file nut\net\tcpsm.c I would like to 
suggest the following change:

Original Code:

                 /*
                  * Process retransmit timer.
                  */
                 if (sock->so_tx_nbq && sock->so_retran_time) {
                     if ((u_short) NutGetMillis() - 
sock->so_retran_time > sock->so_rtto) {
                         NutTcpStateRetranTimeout(sock);
                     }
                 }

Suggested Code:
                 /*
                  * Process retransmit timer.
                  */
                 if (sock->so_tx_nbq && sock->so_retran_time) {
                     if (  (u_short)((u_short) NutGetMillis() - 
sock->so_retran_time) > sock->so_rtto) {
                         NutTcpStateRetranTimeout(sock);
                     }
                 }


I'm using the arm-elf-gcc compiler and if the result of the 
subtraction is negative then the compiler seems to use a signed 
result instead of u_short for the comparison against sock->so_rtto.
If there is an ethernet connectivity problem then a thread can appear 
to lock-up when it calls NutTcpConnect because 
NutTcpStateRetranTimeout(sock) won't be executed for large values of 
sock->so_retran_time.

   Thoughts?

   Thanks!
   Zack




More information about the En-Nut-Discussion mailing list