buglwIP - A Lightweight TCP/IP stack - Bugs: bug #38853, connect() use a wrong errno

 
 

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

bug #38853: connect() use a wrong errno

Submitter:  hanhui <hanhui03>
Submitted:  Mon 29 Apr 2013 03:51:35 PM UTC
   
 
Category:  sockets/netconn Severity:  3 - Normal
Item Group:  Faulty Behaviour Status:  Fixed
Privacy:  Public Assigned to:  goldsimon
Open/Closed:  Closed Planned Release:  None
lwIP version:  git head

Tue 17 Feb 2015 09:11:00 PM UTC, comment #3: 

Fixed, thanks for the input.

Simon Goldschmidt <goldsimon>
Group administrator
Mon 17 Mar 2014 03:21:31 PM UTC, comment #2: 

Agreed.

I attach a patch that changes the following:
1) introduces ERR_ALREADY in the LwIP errors
2) uses ERR_ALREADY in lwip_netconn_do_connect() if already called and connection not yet established, but ERR_ISCONN is used when it is established
3) in sockets.c, added ERR_ALREADY => EALREADY to the err_to_errno table and changed ERR_ISCONN to be EISCONN as it's supposed to be

(file #30928)

TabascoEye <tabascoeye>
Mon 29 Apr 2013 03:56:13 PM UTC, comment #1: 

Add tcp_connect() do not use LWIP_ERROR(...) to check pcb state!

hanhui <hanhui03>
Mon 29 Apr 2013 03:51:35 PM UTC, original submission:  

EALREADY : A connection request is already in progress for the specified socket.

EISCONN: The specified socket is connection-mode and is already connected.

EALREADY is NOT same as EISCONN, but lwip is only use "ERR_ISCONN" as EALREADY.

Some software(for example Qt/Embedded) whill check EISCONN to determine whether the connection is successful!

I suggest that add a netconn error code : ERR_ALREADY used to distinguish these two cases.

err_t
tcp_connect(struct tcp_pcb *pcb, ip_addr_t *ipaddr, u16_t port, tcp_connected_fn connected)
{
  if (pcb->state == ESTABLISHED) {
    return ERR_ISCONN;
  } else if (pcb->state != CLOSED) {
    return ERR_ALREADY;
  }

  ...
}

hanhui <hanhui03>

 

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

Attached Files
file #30928:  lwip_connect_errnos.patch added by tabascoeye (3KiB - application/octet-stream)

 

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 tabascoeye (Updated the item)
  • -email is unavailable- added by hanhui03 (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 4 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2015-02-17 goldsimon StatusNone Fixed
        Assigned toNone goldsimon
        Open/ClosedOpen Closed
    2014-03-17 tabascoeye Attached File- Added lwip_connect_errnos.patch, #30928

    Back to the top

    Powered by Savane 3.13-bb6a.
    Corresponding source code