lwip-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [lwip-users] lwip_sendto hanging with lwip 2.0


From: Neerav Patel
Subject: Re: [lwip-users] lwip_sendto hanging with lwip 2.0
Date: Wed, 25 Jan 2017 07:02:39 +0000

Hi,


I read that same statement after I had posted and so I created another system thread (been debugging the whole day):


sys_thread_new("handle_thread", handle_thread, NULL, 400, 3);


and tried to send from it, and it also hung in the same way, seems to not return from a semaphore call deep in the bowls of lwip, still digging further into it.


Maybe this will do the same and call back from the tcpipthread.  


How would you propose structuring the code, I want one thread to receive packets and another to send out?  Is creating a system thread the right way to go?  Why would I be hanging with the code below?


Thanks for all the help!


void
handle_thread( )
{
      while ( 1 )
      {
            if ( send_actual_pkt ) 
            {
                  send_actual_pkt = 0;
                  uint8_t pkt[576];
                  // ... populate the pkt
                 uint16_t len = generate_pkt();
                 if ( lwip_sendto( s, pkt, len, 0, (struct sockaddr *)&from, sizeof(from) ) != len )   <---- hanging here!!!!
                 {
                       uart_printf( "Didnt send correctly %x\n", len );
                 }
            }
       }
}


while( 1 )
   {
      if ( (lwip_recvfrom(s, raw_buf, sizeof(raw_buf), 0, (struct sockaddr*)&from, (socklen_t*)&fromlen)) > 0 )
      {
                  send_actual_pkt = 1;
      }
   }




From: lwip-users <lwip-users-bounces+address@hidden> on behalf of Dirk Ziegelmeier <address@hidden>
Sent: January 25, 2017 6:48 AM
To: Mailing list for lwIP users
Subject: Re: [lwip-users] lwip_sendto hanging with lwip 2.0
 
Calling sys_timeout() results in send_actual_pkt being called back from TCPIP thread. You must not call sequencial style functions from TCPIP thread.

http://www.nongnu.org/lwip/2_0_0/group__sequential__api.html says: "More overhead, but can be called from any thread except TCPIP thread."
www.nongnu.org
Detailed Description. Sequential-style APIs, blocking functions. More overhead, but can be called from any thread except TCPIP thread.



Dirk


reply via email to

[Prev in Thread] Current Thread [Next in Thread]