Skip to content

HttpClient: Timing issue in sync ConnectHelper.Connect #40876

Closed

Description

@geoffkizer

This code has a timing issue:

                using (cancellationToken.UnsafeRegister(static s => ((Socket)s!).Dispose(), socket))
                {
                    socket.Connect(new DnsEndPoint(host, port));
                }

If the socket.Connect call succeeds, but then the CancellationToken fires before the registration is disposed, then the Socket will be disposed but we will still continue as if the Connect succeeded.

I'm reasonably sure that's what caused this failure: https://helix.dot.net/api/2019-06-17/jobs/e63fcc11-e9ad-476c-9798-47f2f6d3b152/workitems/System.Net.Http.Functional.Tests/console

Activity

  1. added this to the 5.0.0 milestone on Aug 15, 2020
  2. added
    untriaged
    on Aug 15, 2020
  3. added and removed
    untriaged
    on Aug 15, 2020
  4. ManickaP commented on Aug 15, 2020

    @ManickaP
    Member

    This has been already fixed in #39514
    But returned back, probably via bad resolution of conflicts in merge, in #39524.

    I can fix that.

  5. ghost locked as resolved and limited conversation to collaborators on Dec 7, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions