• Ingo Struewing's avatar
    Bug#37267 - connect() EINPROGRESS failures mishandled in client library · 7dacca0f
    Ingo Struewing authored
    We cann connect() in a non-blocking mode to be able to specify a
    non-standard timeout.
    
    The problem was that we did not fetch the status from the
    non-blocking connect(). We assumed that poll() would not return
    a POLLIN flag if the connect failed. But on some platforms this
    is not true.
    
    After a successful poll() we do now retrieve the status value
    from connect() with getsockopt(...SO_ERROR...). Now we do know
    if (and how) the connect failed.
    
    The test case for my investigation was rpl.rlp_ssl1 on an
    Ubuntu 9.04 x86_64 machine. Both, IPV4 and IPV6 were active.
    'localhost' resolved first for IPV6 and then for IPV4. The
    connection over IPV6 was blocked. rpl.rlp_ssl1 timed out
    as it did not notice the failed connect(). The first read()
    failed, which was interpreted as a master crash and the
    connection was tried to reestablish with the same result
    until the retry limit was reached.
    
    With the fix, the connect() problem is immediately recognized,
    and the connect() is retried on the second resolution for
    'localhost', which is successful.
    
    
    libmysqld/libmysqld.c:
      Bug#37267 - connect() EINPROGRESS failures mishandled in client library
      Changed a DBUG print string to distinguish the two mysql_real_connect()
      implementations in DBUG traces.
    mysql-test/include/wait_for_slave_param.inc:
      Bug#37267 - connect() EINPROGRESS failures mishandled in client library
      Made timeout value available in error message.
    mysql-test/suite/rpl/r/rpl_get_master_version_and_clock.result:
      Bug#37267 - connect() EINPROGRESS failures mishandled in client library
      Fixed test result. Connect error is now detected as CR_CONN_HOST_ERROR
      (2003) instead of CR_SERVER_LOST (2013).
    sql-common/client.c:
      Bug#37267 - connect() EINPROGRESS failures mishandled in client library
      Added retrieval of the error code from the non-blocking connect().
      Added DBUG.
      Added comment.
    7dacca0f
client.c 98.1 KB