buglwIP - A Lightweight TCP/IP stack - Bugs: bug #48416, Problem with nonblocking connect

 
 

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

bug #48416: Problem with nonblocking connect

Submitted by:  Christian Prochaska <cproc>
Submitted on:  Tue 05 Jul 2016 06:29:25 PM UTC  
 
Category: sockets/netconnSeverity: 3 - Normal
Item Group: NoneStatus: Works For Me
Privacy: PublicAssigned to: Simon Goldschmidt <goldsimon>
Open/Closed: ClosedPlanned Release: None
lwIP version: git head

Wed 06 Jul 2016 05:18:18 AM UTC, comment #1:

This should work: when LWIP_ERROR is correctly defined to execute "handler", tcp_connect() returns ERR_ISCONN. It does raise an error message by default unless LWIP_NOASSERT is defined to help you finding bugs in your application during development.

If you can't get your application to not behave like this, you can change the LWIP_ERROR define to only execute "handler".

Simon Goldschmidt <goldsimon>
Project AdministratorIn charge of this item.
Tue 05 Jul 2016 06:29:25 PM UTC, original submission:

I'm actually not using the most recent version, but from looking at the source code the problem I'm having seems to still exist on the current git master branch (4b136d631af0650247ab1bb21c7eb761d12960b6)

In 'lwip_netconn_do_connect()':

...

case NETCONN_TCP:
/* Prevent connect while doing any other action. */
if (msg->conn->state == NETCONN_CONNECT) {
msg->err = ERR_ALREADY;
} else if (msg->conn->state != NETCONN_NONE) {
msg->err = ERR_ISCONN;
} else {
setup_tcp(msg->conn);
msg->err = tcp_connect(msg->conn->pcb.tcp, API_EXPR_REF(msg->msg.bc.ipaddr),
msg->msg.bc.port, lwip_netconn_do_connected);
if (msg->err == ERR_OK) {
u8_t non_blocking = netconn_is_nonblocking(msg->conn);
msg->conn->state = NETCONN_CONNECT;

...

The problem occurred when the function was called for the second time when the connection was already established. I would have expected an 'ERR_ISCONN' status code, but instead tcp_connect() got called for a second time and printed a 'tcp_connect: can only connect from state CLOSED' error message (the actual state was ESTABLISHED).

The reason for the repeated call of 'tcp_connect()' was that 'msg->conn->state' was NETCONN_NONE, as set in 'lwip_netconn_do_connected()' after the connection was established.

Perhaps a new netconn state 'NETCONN_CONNECTED' would be needed here, but I'm not too familiar with lwip interna to be sure about that.

Christian Prochaska <cproc>

 

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

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

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only logged-in users can vote.

     

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    Follow 3 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Wed 06 Jul 2016 05:18:18 AM UTCgoldsimonStatusNone=>Works For Me
      Assigned toNone=>goldsimon
      Open/ClosedOpen=>Closed

    Back to the top


    Powered by Savane 3.1-cleanup1