buglwIP - A Lightweight TCP/IP stack - Bugs: bug #37958, netconn API doesn't handle...

 
 

You are not allowed to post comments on this tracker with your current authentication level.

bug #37958: netconn API doesn't handle correctly connections half-closed by peer

Submitter:  Valery Ushakov <uwe>
Submitted:  Wed 19 Dec 2012 03:26:21 PM UTC
   
 
Category:  None Severity:  3 - Normal
Item Group:  Faulty Behaviour Status:  Fixed
Privacy:  Public Assigned to:  goldsimon
Open/Closed:  Closed Planned Release:  None
lwIP version:  CVS Head

Wed 18 Feb 2015 09:23:11 PM UTC, comment #1: 

Fixed, thanks for reporting.

I've chosen to call 'netconn_close_shutdown(conn, NETCONN_SHUT_RD)' instead of your suggested 'sys_mbox_free/sys_mbox_set_invalid' as that seemed to introduce less change of behaviour.

Simon Goldschmidt <goldsimon>
Group administrator
Wed 19 Dec 2012 03:26:21 PM UTC, original submission:  

Half-open connections that were half-closed by peer are stuck with netconn::last_err = ERR_CLSD, which prevents further writes over them.  Cf. netconn_recv_data:


    if (buf == NULL) {
      API_EVENT(conn, NETCONN_EVT_RCVMINUS, 0);
      /* Avoid to lose any previous error code */
      NETCONN_SET_SAFE_ERR(conn, ERR_CLSD);
      return ERR_CLSD;
    }


As a quick kludge I changed that to


      sys_mbox_free(&conn->recvmbox);
      sys_mbox_set_invalid(&conn->recvmbox);


which, from a quick look, should be thread-safe, since recv_tcp() won't send anything after sending NULL pbuf to indicate that peer has performed close.

And changed LWIP_ERROR checks for sys_mbox_valid(&conn->recvmbox) in netconn_recv() and netconn_recv_data() with explicit


  if (!sys_mbox_valid(&conn->recvmbox)) {
    return sys_mbox_valid(&conn->acceptmbox) ? ERR_CONN : ERR_CLSD;
  }


which seems to work, but I haven't investigated/tested this thoroughly.

Valery Ushakov <uwe>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by goldsimon (Posted a comment)
  • -email is unavailable- added by uwe (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

     

    Follow 3 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2015-02-18 goldsimon Open/ClosedOpen Closed
    2015-02-18 goldsimon StatusNone Fixed
        Assigned toNone goldsimon

    Back to the top

    Powered by Savane 3.13-d3ae.
    Corresponding source code