When socket.ConnectAsync() throws an error synchronously, SocketAsyncEventArgs is not disposed

Description

Related to CSHARP-691, in the case when socket.ConnectAsync(e) throws an error synchronously the driver is not disposing the event args.

In that case, the resources are not going to be freed until the finalizer is called.

Note that as the driver properly configures the socket, ConnectAsync() will complete asynchronously in most cases (IO pending), even if there is no process listening on the remote port or the address can't be reached. I could reproduce sync completion of ConnectAsync() only when connecting to a port that is listening on a local interface w/ Linux under .NET Core 2.0+.

Environment

None

Pull Requests

None

Status

Assignee

Unassigned

Reporter

Jorge Bay Gondra

Labels

None

Reproduced in

None

PM Priority

None

Fix versions

None

External issue ID

None

Doc Impact

None

Reviewer

None

Pull Request

None

Epic Link

None

Sprint

Size

None

Affects versions

Priority

Major
Configure