Skip to content

Rename KeepAlivePingInterval to KeepAlivePingDelay #24308

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 28, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions src/Servers/Kestrel/Core/src/Http2Limits.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public class Http2Limits
private int _maxRequestHeaderFieldSize = (int)Http2PeerSettings.DefaultMaxFrameSize;
private int _initialConnectionWindowSize = 1024 * 128; // Larger than the default 64kb, and larger than any one single stream.
private int _initialStreamWindowSize = 1024 * 96; // Larger than the default 64kb
private TimeSpan _keepAlivePingInterval = TimeSpan.MaxValue;
private TimeSpan _keepAlivePingDelay = TimeSpan.MaxValue;
private TimeSpan _keepAlivePingTimeout = TimeSpan.FromSeconds(20);

/// <summary>
Expand Down Expand Up @@ -147,18 +147,18 @@ public int InitialStreamWindowSize
}

/// <summary>
/// Gets or sets the keep alive ping interval. The server will send a keep alive ping to the client if it
/// doesn't receive any frames for this period of time. This property is used together with
/// Gets or sets the keep alive ping delay. The server will send a keep alive ping to the client if it
/// doesn't receive any frames on a connection for this period of time. This property is used together with
/// <see cref="KeepAlivePingTimeout"/> to close broken connections.
/// <para>
/// Interval must be greater than or equal to 1 second. Set to <see cref="TimeSpan.MaxValue"/> to
/// disable the keep alive ping interval.
/// Delay value must be greater than or equal to 1 second. Set to <see cref="TimeSpan.MaxValue"/> to
/// disable the keep alive ping.
/// Defaults to <see cref="TimeSpan.MaxValue"/>.
/// </para>
/// </summary>
public TimeSpan KeepAlivePingInterval
public TimeSpan KeepAlivePingDelay
{
get => _keepAlivePingInterval;
get => _keepAlivePingDelay;
set
{
// Keep alive uses Kestrel's system clock which has a 1 second resolution. Time is greater or equal to clock resolution.
Expand All @@ -167,13 +167,13 @@ public TimeSpan KeepAlivePingInterval
throw new ArgumentOutOfRangeException(nameof(value), CoreStrings.FormatArgumentTimeSpanGreaterOrEqual(Heartbeat.Interval));
}

_keepAlivePingInterval = value != Timeout.InfiniteTimeSpan ? value : TimeSpan.MaxValue;
_keepAlivePingDelay = value != Timeout.InfiniteTimeSpan ? value : TimeSpan.MaxValue;
}
}

/// <summary>
/// Gets or sets the keep alive ping timeout. Keep alive pings are sent when a period of inactivity exceeds
/// the configured <see cref="KeepAlivePingInterval"/> value. The server will close the connection if it
/// the configured <see cref="KeepAlivePingDelay"/> value. The server will close the connection if it
/// doesn't receive any frames within the timeout.
/// <para>
/// Timeout must be greater than or equal to 1 second. Set to <see cref="TimeSpan.MaxValue"/> to
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,10 +107,10 @@ public Http2Connection(HttpConnectionContext context)
var connectionWindow = (uint)http2Limits.InitialConnectionWindowSize;
_inputFlowControl = new InputFlowControl(connectionWindow, connectionWindow / 2);

if (http2Limits.KeepAlivePingInterval != TimeSpan.MaxValue)
if (http2Limits.KeepAlivePingDelay != TimeSpan.MaxValue)
{
_keepAlive = new Http2KeepAlive(
http2Limits.KeepAlivePingInterval,
http2Limits.KeepAlivePingDelay,
http2Limits.KeepAlivePingTimeout,
context.ServiceContext.SystemClock);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Tests
public class Http2KeepAliveTests : Http2TestBase
{
[Fact]
public async Task KeepAlivePingInterval_InfiniteTimeSpan_KeepAliveNotEnabled()
public async Task KeepAlivePingDelay_InfiniteTimeSpan_KeepAliveNotEnabled()
{
_serviceContext.ServerOptions.Limits.Http2.KeepAlivePingInterval = Timeout.InfiniteTimeSpan;
_serviceContext.ServerOptions.Limits.Http2.KeepAlivePingDelay = Timeout.InfiniteTimeSpan;

await InitializeConnectionAsync(_noopApplication).DefaultTimeout();

Expand All @@ -26,7 +26,7 @@ public async Task KeepAlivePingInterval_InfiniteTimeSpan_KeepAliveNotEnabled()
[Fact]
public async Task KeepAlivePingTimeout_InfiniteTimeSpan_NoGoAway()
{
_serviceContext.ServerOptions.Limits.Http2.KeepAlivePingInterval = TimeSpan.FromSeconds(1);
_serviceContext.ServerOptions.Limits.Http2.KeepAlivePingDelay = TimeSpan.FromSeconds(1);
_serviceContext.ServerOptions.Limits.Http2.KeepAlivePingTimeout = Timeout.InfiniteTimeSpan;

await InitializeConnectionAsync(_noopApplication).DefaultTimeout();
Expand Down Expand Up @@ -57,7 +57,7 @@ await ExpectAsync(Http2FrameType.PING,
[Fact]
public async Task IntervalExceeded_WithoutActivity_PingSent()
{
_serviceContext.ServerOptions.Limits.Http2.KeepAlivePingInterval = TimeSpan.FromSeconds(1);
_serviceContext.ServerOptions.Limits.Http2.KeepAlivePingDelay = TimeSpan.FromSeconds(1);

await InitializeConnectionAsync(_noopApplication).DefaultTimeout();

Expand All @@ -80,7 +80,7 @@ await ExpectAsync(Http2FrameType.PING,
[Fact]
public async Task IntervalExceeded_WithActivity_NoPingSent()
{
_serviceContext.ServerOptions.Limits.Http2.KeepAlivePingInterval = TimeSpan.FromSeconds(1);
_serviceContext.ServerOptions.Limits.Http2.KeepAlivePingDelay = TimeSpan.FromSeconds(1);

await InitializeConnectionAsync(_noopApplication).DefaultTimeout();

Expand All @@ -104,7 +104,7 @@ await ExpectAsync(Http2FrameType.PING,
[Fact]
public async Task IntervalNotExceeded_NoPingSent()
{
_serviceContext.ServerOptions.Limits.Http2.KeepAlivePingInterval = TimeSpan.FromSeconds(5);
_serviceContext.ServerOptions.Limits.Http2.KeepAlivePingDelay = TimeSpan.FromSeconds(5);

await InitializeConnectionAsync(_noopApplication).DefaultTimeout();

Expand All @@ -122,7 +122,7 @@ public async Task IntervalNotExceeded_NoPingSent()
[Fact]
public async Task IntervalExceeded_MultipleTimes_PingsNotSentWhileAwaitingOnAck()
{
_serviceContext.ServerOptions.Limits.Http2.KeepAlivePingInterval = TimeSpan.FromSeconds(1);
_serviceContext.ServerOptions.Limits.Http2.KeepAlivePingDelay = TimeSpan.FromSeconds(1);

await InitializeConnectionAsync(_noopApplication).DefaultTimeout();

Expand All @@ -146,7 +146,7 @@ await ExpectAsync(Http2FrameType.PING,
[Fact]
public async Task IntervalExceeded_MultipleTimes_PingSentAfterAck()
{
_serviceContext.ServerOptions.Limits.Http2.KeepAlivePingInterval = TimeSpan.FromSeconds(1);
_serviceContext.ServerOptions.Limits.Http2.KeepAlivePingDelay = TimeSpan.FromSeconds(1);

await InitializeConnectionAsync(_noopApplication).DefaultTimeout();

Expand Down Expand Up @@ -185,7 +185,7 @@ await ExpectAsync(Http2FrameType.PING,
[Fact]
public async Task TimeoutExceeded_NoAck_GoAway()
{
_serviceContext.ServerOptions.Limits.Http2.KeepAlivePingInterval = TimeSpan.FromSeconds(1);
_serviceContext.ServerOptions.Limits.Http2.KeepAlivePingDelay = TimeSpan.FromSeconds(1);
_serviceContext.ServerOptions.Limits.Http2.KeepAlivePingTimeout = TimeSpan.FromSeconds(3);

await InitializeConnectionAsync(_noopApplication).DefaultTimeout();
Expand Down Expand Up @@ -217,7 +217,7 @@ await ExpectAsync(Http2FrameType.PING,
[Fact]
public async Task TimeoutExceeded_NonPingActivity_NoGoAway()
{
_serviceContext.ServerOptions.Limits.Http2.KeepAlivePingInterval = TimeSpan.FromSeconds(1);
_serviceContext.ServerOptions.Limits.Http2.KeepAlivePingDelay = TimeSpan.FromSeconds(1);
_serviceContext.ServerOptions.Limits.Http2.KeepAlivePingTimeout = TimeSpan.FromSeconds(3);

await InitializeConnectionAsync(_noopApplication).DefaultTimeout();
Expand Down Expand Up @@ -250,7 +250,7 @@ await ExpectAsync(Http2FrameType.HEADERS,
[Fact]
public async Task IntervalExceeded_StreamStarted_NoPingSent()
{
_serviceContext.ServerOptions.Limits.Http2.KeepAlivePingInterval = TimeSpan.FromSeconds(1);
_serviceContext.ServerOptions.Limits.Http2.KeepAlivePingDelay = TimeSpan.FromSeconds(1);

await InitializeConnectionAsync(_noopApplication).DefaultTimeout();

Expand All @@ -275,7 +275,7 @@ await ExpectAsync(Http2FrameType.HEADERS,
[Fact]
public async Task IntervalExceeded_ConnectionFlowControlUsedUpThenPings_NoPingSent()
{
_serviceContext.ServerOptions.Limits.Http2.KeepAlivePingInterval = TimeSpan.FromSeconds(1);
_serviceContext.ServerOptions.Limits.Http2.KeepAlivePingDelay = TimeSpan.FromSeconds(1);

// Reduce connection window size so that one stream can fill it
_serviceContext.ServerOptions.Limits.Http2.InitialConnectionWindowSize = 65535;
Expand Down Expand Up @@ -330,7 +330,7 @@ await ExpectAsync(Http2FrameType.HEADERS,
[Fact]
public async Task TimeoutExceeded_ConnectionFlowControlUsedUpThenPings_NoGoAway()
{
_serviceContext.ServerOptions.Limits.Http2.KeepAlivePingInterval = TimeSpan.FromSeconds(1);
_serviceContext.ServerOptions.Limits.Http2.KeepAlivePingDelay = TimeSpan.FromSeconds(1);

// Reduce connection window size so that one stream can fill it
_serviceContext.ServerOptions.Limits.Http2.InitialConnectionWindowSize = 65535;
Expand Down