Skip to content

Commit b320450

Browse files
Addressed PR feedback!
1 parent 09840e5 commit b320450

File tree

7 files changed

+24
-26
lines changed

7 files changed

+24
-26
lines changed

src/Servers/Connections.Abstractions/src/BaseConnectionContext.cs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,6 @@ public abstract class BaseConnectionContext : IAsyncDisposable
4646
/// </summary>
4747
public virtual EndPoint? RemoteEndPoint { get; set; }
4848

49-
/// <summary>
50-
/// Gets or sets the socket for this connection.
51-
/// </summary>
52-
public virtual Socket? Socket { get; set; }
53-
5449
/// <summary>
5550
/// Aborts the underlying connection.
5651
/// </summary>

src/Servers/Connections.Abstractions/src/DefaultConnectionContext.cs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,7 @@ public class DefaultConnectionContext : ConnectionContext,
2323
IConnectionTransportFeature,
2424
IConnectionUserFeature,
2525
IConnectionLifetimeFeature,
26-
IConnectionEndPointFeature,
27-
IConnectionSocketFeature
26+
IConnectionEndPointFeature
2827
{
2928
private CancellationTokenSource _connectionClosedTokenSource = new CancellationTokenSource();
3029

@@ -53,7 +52,6 @@ public DefaultConnectionContext(string id)
5352
Features.Set<IConnectionTransportFeature>(this);
5453
Features.Set<IConnectionLifetimeFeature>(this);
5554
Features.Set<IConnectionEndPointFeature>(this);
56-
Features.Set<IConnectionSocketFeature>(this);
5755

5856
ConnectionClosed = _connectionClosedTokenSource.Token;
5957
}
@@ -99,9 +97,6 @@ public DefaultConnectionContext(string id, IDuplexPipe transport, IDuplexPipe ap
9997
/// <inheritdoc />
10098
public override EndPoint? RemoteEndPoint { get; set; }
10199

102-
/// <inheritdoc />
103-
public override Socket? Socket { get; set; }
104-
105100
/// <inheritdoc />
106101
public override void Abort(ConnectionAbortedException abortReason)
107102
{

src/Servers/Connections.Abstractions/src/PublicAPI.Unshipped.txt

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,3 @@ Microsoft.AspNetCore.Connections.Experimental.MultiplexedConnectionContext.Multi
2525
Microsoft.AspNetCore.Connections.Experimental.MultiplexedConnectionDelegate
2626
abstract Microsoft.AspNetCore.Connections.Experimental.MultiplexedConnectionContext.AcceptAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Threading.Tasks.ValueTask<Microsoft.AspNetCore.Connections.ConnectionContext?>
2727
abstract Microsoft.AspNetCore.Connections.Experimental.MultiplexedConnectionContext.ConnectAsync(Microsoft.AspNetCore.Http.Features.IFeatureCollection? features = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Threading.Tasks.ValueTask<Microsoft.AspNetCore.Connections.ConnectionContext!>
28-
override Microsoft.AspNetCore.Connections.DefaultConnectionContext.Socket.get -> System.Net.Sockets.Socket?
29-
override Microsoft.AspNetCore.Connections.DefaultConnectionContext.Socket.set -> void
30-
virtual Microsoft.AspNetCore.Connections.BaseConnectionContext.Socket.get -> System.Net.Sockets.Socket?
31-
virtual Microsoft.AspNetCore.Connections.BaseConnectionContext.Socket.set -> void

src/Servers/Kestrel/Transport.Sockets/src/Internal/SocketConnection.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ internal SocketConnection(Socket socket,
4848
MemoryPool = memoryPool;
4949
_trace = trace;
5050
_waitForData = waitForData;
51-
Socket = _socket;
5251

5352
LocalEndPoint = _socket.LocalEndPoint;
5453
RemoteEndPoint = _socket.RemoteEndPoint;

src/Servers/Kestrel/shared/TransportConnection.FeatureCollection.cs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,7 @@ internal partial class TransportConnection : IConnectionIdFeature,
1616
IConnectionTransportFeature,
1717
IConnectionItemsFeature,
1818
IMemoryPoolFeature,
19-
IConnectionLifetimeFeature,
20-
IConnectionSocketFeature
19+
IConnectionLifetimeFeature
2120
{
2221
// NOTE: When feature interfaces are added to or removed from this TransportConnection class implementation,
2322
// then the list of `features` in the generated code project MUST also be updated.
@@ -43,11 +42,6 @@ CancellationToken IConnectionLifetimeFeature.ConnectionClosed
4342
set => ConnectionClosed = value;
4443
}
4544

46-
Socket? IConnectionSocketFeature.Socket
47-
{
48-
get => Socket;
49-
}
50-
5145
void IConnectionLifetimeFeature.Abort() => Abort(new ConnectionAbortedException("The connection was aborted by the application via IConnectionLifetimeFeature.Abort()."));
5246
}
5347
}

src/Servers/Kestrel/shared/TransportConnection.Generated.cs

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ internal partial class TransportConnection : IFeatureCollection
1919
private object? _currentIConnectionItemsFeature;
2020
private object? _currentIMemoryPoolFeature;
2121
private object? _currentIConnectionLifetimeFeature;
22+
private object? _currentIConnectionSocketFeature;
2223

2324
private int _featureRevision;
2425

@@ -31,7 +32,7 @@ private void FastReset()
3132
_currentIConnectionItemsFeature = this;
3233
_currentIMemoryPoolFeature = this;
3334
_currentIConnectionLifetimeFeature = this;
34-
35+
_currentIConnectionSocketFeature = this;
3536
}
3637

3738
// Internal for testing
@@ -123,6 +124,10 @@ private void ExtraFeatureSet(Type key, object? value)
123124
{
124125
feature = _currentIConnectionLifetimeFeature;
125126
}
127+
else if (key == typeof(IConnectionSocketFeature))
128+
{
129+
feature = _currentIConnectionSocketFeature;
130+
}
126131
else if (MaybeExtra != null)
127132
{
128133
feature = ExtraFeatureGet(key);
@@ -155,6 +160,10 @@ private void ExtraFeatureSet(Type key, object? value)
155160
{
156161
_currentIConnectionLifetimeFeature = value;
157162
}
163+
else if (key == typeof(IConnectionSocketFeature))
164+
{
165+
_currentIConnectionSocketFeature = value;
166+
}
158167
else
159168
{
160169
ExtraFeatureSet(key, value);
@@ -185,6 +194,10 @@ private void ExtraFeatureSet(Type key, object? value)
185194
{
186195
feature = (TFeature?)_currentIConnectionLifetimeFeature;
187196
}
197+
else if (typeof(TFeature) == typeof(IConnectionSocketFeature))
198+
{
199+
feature = (TFeature?)_currentIConnectionSocketFeature;
200+
}
188201
else if (MaybeExtra != null)
189202
{
190203
feature = (TFeature?)(ExtraFeatureGet(typeof(TFeature)));
@@ -216,6 +229,10 @@ private void ExtraFeatureSet(Type key, object? value)
216229
{
217230
_currentIConnectionLifetimeFeature = feature;
218231
}
232+
else if (typeof(TFeature) == typeof(IConnectionSocketFeature))
233+
{
234+
_currentIConnectionSocketFeature = feature;
235+
}
219236
else
220237
{
221238
ExtraFeatureSet(typeof(TFeature), feature);
@@ -244,6 +261,10 @@ private IEnumerable<KeyValuePair<Type, object>> FastEnumerable()
244261
{
245262
yield return new KeyValuePair<Type, object>(typeof(IConnectionLifetimeFeature), _currentIConnectionLifetimeFeature);
246263
}
264+
if (_currentIConnectionSocketFeature != null)
265+
{
266+
yield return new KeyValuePair<Type, object>(typeof(IConnectionSocketFeature), _currentIConnectionSocketFeature);
267+
}
247268

248269
if (MaybeExtra != null)
249270
{

src/Servers/Kestrel/shared/TransportConnection.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,6 @@ public override string ConnectionId
6565
}
6666
}
6767

68-
public override Socket? Socket { get; set; }
69-
7068
public override CancellationToken ConnectionClosed { get; set; }
7169

7270
// DO NOT remove this override to ConnectionContext.Abort. Doing so would cause

0 commit comments

Comments
 (0)