lwip-users
[Top][All Lists]
Advanced

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

[lwip-users] netconn/netbuf api with receiving timeout missing closed co


From: Dmitri Snejko
Subject: [lwip-users] netconn/netbuf api with receiving timeout missing closed connection
Date: Sat, 24 Oct 2009 00:29:02 -0400
User-agent: Thunderbird 2.0.0.23 (Windows/20090812)

Hello,

I am trying to use netconn api with receiving timeout other then 0. I am using Lwip 1.3.0 with FreeRtos 5.4.2/ColdFire and applied the patch for 1.3.1

http://cvs.savannah.gnu.org/viewvc/lwip/src/include/lwip/err.h?root=lwip&r1=1.13&r2=1.14 
<http://cvs.savannah.gnu.org/viewvc/lwip/src/include/lwip/err.h?root=lwip&r1=1.13&r2=1.14>

My application is a server listening for incoming connections, opening a new netconn for any client (telnet like) and allocates a static buffer from a pool to receive a stream. The receiving connection is not blocked any more and I found I have a problem when the connection is closed on the remote side. My first impression was I could read netconn err field when netconn_recv returns NULL and based on the error code decide if the remote side closed the connection or a fatal error happened. That would be a reason to close the connection on the sever side. It works fine for some time but after a few hundred open/close cycles the server stops seeing the other side closed its end. I assume netconn_recv returns ERR_TIMEOUT which is not fatal. As result the buffer stays allocated and I am running out resources.
The simplified code looks like one below:

listener->recv_timeout=1;
for(;;){
   new_conn = netconn_accept(listener);
if(new_conn) if((cb = find_free_cb()) == NULL){
           netconn_close(new_conn);
           netconn_delete(new_conn);
      }
      else{
           new_conn->recv_timeout=1;
           cb->conn = new_conn;
      }
   for(i = 0; i < MAX_CB; i++){
       if(cb_pool[i].conn != NULL)
           if( netbuff = netconn_recv(cb_pool[i].conn)  != NULL)
               read(netbuff, cb_pool[i]);
           else{
                 if(EER_IS_FATAL(cb_pool[i].conn->err)){
                       netconn_close(cb_pool[i].conn);
                       netconn_delete(cb_pool[i].conn);
                       cb_pool[i].conn = NULL;
                 }
          }
   }
}

Is this right way to proceed with netconns? Or I should  do something else?

Regards, Dmitri.







reply via email to

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