[En-Nut-Discussion] Thread stops executing after some time.

Erik L erik.lindstein at gmail.com
Fri Apr 4 09:36:24 CEST 2008


Thanks you very much for taking time to help me solve this problem Henrik
Maier!
I looked into the source and i found a couple of places where we seem to
have the same problem.

I will change them and recompile nut/os and se what happens. 

FILE: tcpsm.c

01634                 /*
01635                  * Process retransmit timer.
01636                  */
01637                 if (sock->so_tx_nbq && sock->so_retran_time) {
01638                     if ((u_short)((u_short)NutGetMillis() -
sock->so_retran_time) > sock->so_rtto) {
01639                         NutTcpStateRetranTimeout(sock);
01640                     }
01641                 }

--------------------------------------------------------

00493     /*
00494      * Reset retransmit timer and wake up waiting transmissions.
00495      */
00496     if (sock->so_tx_nbq) {
00497         sock->so_retran_time = (u_short) NutGetMillis();
00498     } else {
00499         sock->so_retran_time = 0;
00500     }
00501     sock->so_retransmits = 0;

--------------------------------------------------------

00930         } else {
00931             /* Restart the retransmission timer. */
00932             sock->so_retran_time = (u_short) NutGetMillis();
00933             return 0;
00934         }

--------------------------------------------------------

FILE: tcpout.c

00327         if ((nbp = sock->so_tx_nbq) == 0) {
00328             sock->so_tx_nbq = nb;
00329             /*
00330              * First entry, so initialize our retransmission timer.
00331              * It is also set at various places in the state machine,
00332              * but here is the best central point to do it. We may
00333              * carefully check later, if we can remove some in the
00334              * state machine.
00335              */
00336             sock->so_retran_time = (u_short) NutGetMillis();
00337         }
00338         else {
00339             while (nbp->nb_next)
00340                 nbp = nbp->nb_next;
00341             nbp->nb_next = nb;
00342         }






Erik L wrote:
> 
> Oh.. two of the ones with pointer debug just died.
> 
> Here is the output from two clients ( 192.168.0.103 AND 192.168.0.104 )
> ------------------------------------------------------------------------------
> s
> 222 List of sockets
> 
> SYN SENT        3A24     TCP     192.168.0.103:5202     
> 192.168.0.115:9050
> last_error:0    so_retran_time:0        so_rtto:1000    so_retransmits:0,      
> NutGetMillis:34782
> nbq=0x3755 ac_tq=0x2c85 pc_tq=0x0
> 
> ESTABLISHED     3B73     TCP     192.168.0.103:23       
> 192.168.0.115:15485
> last_error:0    so_retran_time:0        so_rtto:710     so_retransmits:0,      
> NutGetMillis:34786
> nbq=0x0 ac_tq=0xffff pc_tq=0x0
> s
> 222 List of sockets
> 
> SYN SENT        3A24     TCP     192.168.0.103:5202     
> 192.168.0.115:9050
> last_error:0    so_retran_time:0        so_rtto:1000    so_retransmits:0,      
> NutGetMillis:36933
> nbq=0x3755 ac_tq=0x2c85 pc_tq=0x0
> 
> ESTABLISHED     3B73     TCP     192.168.0.103:23       
> 192.168.0.115:15485
> last_error:0    so_retran_time:0        so_rtto:640     so_retransmits:0,      
> NutGetMillis:36936
> nbq=0x0 ac_tq=0xffff pc_tq=0x0
> 
> s
> 222 List of sockets
> 
> SYN SENT        3A24     TCP     192.168.0.103:5202     
> 192.168.0.115:9050
> last_error:0    so_retran_time:0        so_rtto:1000    so_retransmits:0,      
> NutGetMillis:65159
> nbq=0x3755 ac_tq=0x2c85 pc_tq=0x0
> 
> ESTABLISHED     3B73     TCP     192.168.0.103:23       
> 192.168.0.115:15485
> last_error:0    so_retran_time:0        so_rtto:470     so_retransmits:0,      
> NutGetMillis:65163
> nbq=0x0 ac_tq=0xffff pc_tq=0x0
> m
> 210 17337 bytes RAM free
> 
> s
> 222 List of sockets
> 
> SYN SENT        3A24     TCP     192.168.0.103:5202     
> 192.168.0.115:9050
> last_error:0    so_retran_time:0        so_rtto:1000    so_retransmits:0,      
> NutGetMillis:65159
> nbq=0x3755 ac_tq=0x2c85 pc_tq=0x0
> 
> ESTABLISHED     3B73     TCP     192.168.0.103:23       
> 192.168.0.115:15485
> last_error:0    so_retran_time:0        so_rtto:470     so_retransmits:0,      
> NutGetMillis:65163
> nbq=0x0 ac_tq=0xffff pc_tq=0x0
> m
> 210 17337 bytes RAM free
> kill
> Posting event to kill socket..
> m
> 210 17495 bytes RAM free
> s
> 222 List of sockets
> 
> ESTABLISHED     3B73     TCP     192.168.0.103:23       
> 192.168.0.115:15485
> last_error:0    so_retran_time:0        so_rtto:356     so_retransmits:0,      
> NutGetMillis:16133
> nbq=0x0 ac_tq=0xffff pc_tq=0x0
> 
> ------------------------------------------------------------------------------
> 
> ------------------------------------------------------------------------------
> 222 List of sockets
> 
> SYN SENT        3A24     TCP     192.168.0.104:8610     
> 192.168.0.115:9050
> last_error:0    so_retran_time:0        so_rtto:1000    so_retransmits:8,      
> NutGetMillis:3621
> nbq=0x37b0 ac_tq=0x2c85 pc_tq=0x0
> 
> ESTABLISHED     3B73     TCP     192.168.0.104:23       
> 192.168.0.115:15491
> last_error:0    so_retran_time:0        so_rtto:716     so_retransmits:0,      
> NutGetMillis:3625
> nbq=0x0 ac_tq=0xffff pc_tq=0x0
> 
> 
> 
> kill
> Posting event to kill socket..
> s
> 222 List of sockets
> 
> ESTABLISHED     3B73     TCP     192.168.0.104:23       
> 192.168.0.115:15491
> last_error:0    so_retran_time:0        so_rtto:571     so_retransmits:0,      
> NutGetMillis:32794
> nbq=0x0 ac_tq=0xffff pc_tq=0x0
> 
> ------------------------------------------------------------------------------
> 
> 
> 
> 
> 
> Erik L wrote:
>> 
>> Because of the long time it takes before i can see the result of the
>> tests only the ones without debuging of the pointers have falled now. 
>> 
>> But i did get some interesting info out of that one.
>> The printout i get from the one that faild is the following (I listed the
>> sockets 3 times)
>> 
>> -----------
>> 222 List of sockets
>> 
>> (DEAD SOCKET)
>> SYN SENT        220F     TCP     192.168.0.112:6130     
>> 192.168.0.115:9050
>> last_error:0    so_retran_time:0        so_rtto:1000    so_retransmits:2,      
>> NutGetMillis:35943
>> 
>> (ME CONNECTED)
>> ESTABLISHED     2181     TCP     192.168.0.112:23       
>> 192.168.0.115:15293
>> last_error:0    so_retran_time:0        so_rtto:612     so_retransmits:0,      
>> NutGetMillis:35946
>> 
>> s
>> 222 List of sockets
>> 
>> SYN SENT        220F     TCP     192.168.0.112:6130     
>> 192.168.0.115:9050
>> last_error:0    so_retran_time:0        so_rtto:1000    so_retransmits:2,      
>> NutGetMillis:38312
>> 
>> ESTABLISHED     2181     TCP     192.168.0.112:23       
>> 192.168.0.115:15293
>> last_error:0    so_retran_time:0        so_rtto:542     so_retransmits:0,      
>> NutGetMillis:38315
>> 
>> s
>> 222 List of sockets
>> 
>> SYN SENT        220F     TCP     192.168.0.112:6130     
>> 192.168.0.115:9050
>> last_error:0    so_retran_time:0        so_rtto:1000    so_retransmits:2,      
>> NutGetMillis:39424
>> 
>> ESTABLISHED     2181     TCP     192.168.0.112:23       
>> 192.168.0.115:15293
>> last_error:0    so_retran_time:0        so_rtto:500     so_retransmits:0,      
>> NutGetMillis:39426
>> ---------
>> 
>> So one can see that se socket just gets stuck there.
>> But i did add the following code bellow just to test if i could kick the
>> socket in the a*s and get it working again. And it worked, so by using
>> the kill command the socket / NutTcpConnect came thru and the thread
>> started execute again. 
>> 
>> ----
>>         if (strncmp("kill", buff, got) == 0) 
>>         {
>> 					extern TCPSOCKET *tcpSocketList;					
>> 					TCPSOCKET *ts;
>> 					for (ts = tcpSocketList; ts; ts = ts->so_next)
>> 					{
>> 						switch (ts->so_state) 
>> 						{
>> 			        case TCPS_SYN_SENT:
>> 								NutEventBroadcast(&ts->so_rx_tq);
>> 								NutEventBroadcast(&ts->so_pc_tq);
>> 								NutEventBroadcast(&ts->so_ac_tq);
>> 			        	fputs("Posting event to kill socket..\r\n", stream);
>> 			        break;
>> 		        }
>> 					}
>> 					continue;
>>         }
>> ----
>> 
>> 
>> After i run that code i get:
>> --------------
>> 222 List of sockets
>> 
>> SYN SENT        220F     TCP     192.168.0.112:6130     
>> 192.168.0.115:9050
>> last_error:0    so_retran_time:0        so_rtto:1000    so_retransmits:2,      
>> NutGetMillis:19124
>> 
>> ESTABLISHED     2181     TCP     192.168.0.112:23       
>> 192.168.0.115:15293
>> last_error:0    so_retran_time:0        so_rtto:360     so_retransmits:0,      
>> NutGetMillis:19127
>> 
>> kill
>> Killing sockets
>> 
>> s
>> 222 List of sockets
>> 
>> ESTABLISHED     2181     TCP     192.168.0.112:23       
>> 192.168.0.115:15293
>> last_error:0    so_retran_time:0        so_rtto:334     so_retransmits:0,      
>> NutGetMillis:40380
>> --------------
>> 
>> So the question is why don´t NutEventBroadcast get called (as i guess it
>> should.)
>> 
>> Regards/Erik
>> 
>> 
>> 
>> 
>> Henrik Maier wrote:
>>> 
>>>> -----Original Message-----
>>>> From: en-nut-discussion-bounces at egnite.de [mailto:en-nut-discussion-
>>>> bounces at egnite.de] On Behalf Of Erik L
>>>>
>>>> Also i'm not sure how to debug this ones:
>>>> sock->so_tx_nbq
>>>> sock->so_ac_tq
>>> 
>>> They are both pointers, so fprintf(stream,"nbq=%p tq=%p\n",
>>> sock->so_tx_nbq,
>>> sock->so_ac_tq) should do the job. In only want to know if they are 0,
>>> 0xFFFF or anything else.
>>> 
>>> Henrik
>>> http://www.proconx.com
>>> 
>>> 
>>> _______________________________________________
>>> http://lists.egnite.de/mailman/listinfo/en-nut-discussion
>>> 
>>> 
>> 
>> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Thread-stops-executing-after-some-time.-tp16299152p16486806.html
Sent from the MicroControllers - Ethernut mailing list archive at Nabble.com.




More information about the En-Nut-Discussion mailing list