Skip to content

Linux workaround for multiple connect attempts per socket does not work #16238

Description

@ericeil

On Linux, we attempt to re-use a socket for multiple connection attempts by "connecting" the socket to an invalid address between each "real" connect attempt. See PrimeForNextConnectAttempt. This does not work as intended. In the current implementation, the raw call to connect() cases any pending call to epoll_wait() to wake up and mark the socket as connected; any subsequent connect attempt on a non-blocking socket (or an Async connect attempt) then appears to succeed immediately, whether it did in fact or not.

This is causing some tests (e.g., System.Net.Sockets.Tests.DualMode.ConnectV4V6IPAddressListToV6Host_Success) to appear to succeed, even though the connection is never successfully established. Once dotnet/corefx#5472 is merged, this test will hang, as the non-blocking connect will now be blocking, and this bug will no longer mask the underlying issue.

I tried fixing this in the blocking case, by adding a call to PrimeForNextConnectAttempt after a blocking connect fails, and discovered that this also does not work. The subsequent connect attempt simply blocks until it times out.

If I disable this feature entirely, forcing Socket methods that connect to address lists to use multiple sockets instead, then the test passes.

Activity

  1. self-assigned this
    on Jan 28, 2016
  2. stephentoub commented on Jan 28, 2016

    @stephentoub
    Member
  3. changed the title [-]Linux workaround for multiple connect attempts per socket does not work on non-blocking sockets[/-] [+]Linux workaround for multiple connect attempts per socket does not work[/+] on Jan 29, 2016
  4. ericeil commented on Jan 29, 2016

    @ericeil
    ContributorAuthor

    Updated the initial description with additional info; this workaround simply does not work.

  5. transferred this issue fromdotnet/corefxon Jan 31, 2020
  6. added this to the 1.0.0-rtm milestone on Jan 31, 2020
  7. ghost locked as resolved and limited conversation to collaborators on Jan 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions