Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
17ddbce
init
Jul 21, 2020
2afc76f
Http2 ping
Aug 3, 2020
c590b7c
Merge remote-tracking branch 'upstream/master' into jajahoda/httpping
Aug 3, 2020
eb37332
clean up
Aug 3, 2020
712479f
enable tests
Aug 3, 2020
95bc2f3
Fix mac build
Aug 3, 2020
de89629
Merge branch 'master' of github.com:dotnet/runtime into jajahoda/http…
Aug 3, 2020
b3e4b3d
Split HttpHandlerDefaults
Aug 4, 2020
e06f092
Merge branch 'master' of github.com:dotnet/runtime into jajahoda/http…
Aug 4, 2020
6e2f371
Merge remote-tracking branch 'origin/jajahoda/httpping' into jajahoda…
Aug 4, 2020
b7ed6ce
Fix mac build
Aug 4, 2020
20f44cf
Fix browser and test csproj
Aug 4, 2020
b684730
Apply PR comments
Aug 5, 2020
014c8d6
Merge remote-tracking branch 'upstream/master' into jajahoda/httpping
Aug 5, 2020
60a757d
Remove Http2KeepAlice class
Aug 5, 2020
886a2da
fix trace message
Aug 5, 2020
863f636
ProcessPingAck no longer return bool
Aug 5, 2020
a987919
Apply suggestions from code review
aik-jahoda Aug 6, 2020
b221f43
Add argument out of ramnge message
Aug 6, 2020
be468cd
Merge branch 'jajahoda/httpping' of github.com:aik-jahoda/runtime int…
Aug 6, 2020
db89b58
Apply PR comments
Aug 6, 2020
02785d6
SocketsHttpHandler setters
Aug 6, 2020
d354a29
Merge remote-tracking branch 'upstream/master' into jajahoda/httpping
Aug 7, 2020
b83cfc3
Update src/libraries/Common/tests/System/Net/Http/Http2LoopbackConnec…
aik-jahoda Aug 7, 2020
63e3d3f
Update src/libraries/System.Net.Http/src/Resources/Strings.resx
aik-jahoda Aug 7, 2020
258f1c4
Apply suggestions from code review
aik-jahoda Aug 7, 2020
2695f2e
PR comments
Aug 7, 2020
0ea45e8
Merge branch 'master' into jajahoda/httpping
ManickaP Aug 11, 2020
7078d8e
Addressed the last batch of PR feedback.
ManickaP Aug 11, 2020
9c1b6e7
Merge branch 'master' into jajahoda/httpping
ManickaP Aug 12, 2020
86c8413
Fixed KeepAlive test dependency on frame chronology.
ManickaP Aug 12, 2020
c10beb9
Fixed FW compilation.
ManickaP Aug 12, 2020
b9c6b33
Split and moved tests to theirs proper places.
ManickaP Aug 12, 2020
40e0e5c
More test fixing for super slow CI.
ManickaP Aug 12, 2020
3a753b7
Exception texts.
ManickaP Aug 13, 2020
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
Prev Previous commit
Next Next commit
PR comments
  • Loading branch information
Jan Jahoda committed Aug 7, 2020
commit 2695f2e77271edfc6ee60c20e533fdc25cc30118
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ internal static partial class HttpHandlerDefaults
public const int DefaultMaxAutomaticRedirections = 50;
public const int DefaultMaxConnectionsPerServer = int.MaxValue;
public const int DefaultMaxResponseDrainSize = 1024 * 1024;
public static readonly TimeSpan DefaultResponseDrainTimeout = TimeSpan.FromTicks(TimeSpan.TicksPerSecond * 2);
public static readonly TimeSpan DefaultResponseDrainTimeout = TimeSpan.FromSeconds(2);
public const int DefaultMaxResponseHeadersLength = 64; // Units in K (1024) bytes.
public const DecompressionMethods DefaultAutomaticDecompression = DecompressionMethods.None;
public const bool DefaultAutomaticRedirection = true;
Expand All @@ -25,8 +25,8 @@ internal static partial class HttpHandlerDefaults
public const bool DefaultUseDefaultCredentials = false;
public const bool DefaultCheckCertificateRevocationList = false;
public static readonly TimeSpan DefaultPooledConnectionLifetime = Timeout.InfiniteTimeSpan;
public static readonly TimeSpan DefaultPooledConnectionIdleTimeout = TimeSpan.FromTicks(TimeSpan.TicksPerMinute * 2);
public static readonly TimeSpan DefaultExpect100ContinueTimeout = TimeSpan.FromTicks(TimeSpan.TicksPerSecond * 1);
public static readonly TimeSpan DefaultPooledConnectionIdleTimeout = TimeSpan.FromMinutes(2);
public static readonly TimeSpan DefaultExpect100ContinueTimeout = TimeSpan.FromSeconds(1);
public static readonly TimeSpan DefaultConnectTimeout = Timeout.InfiniteTimeSpan;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace System.Net.Http
/// </summary>
internal static partial class HttpHandlerDefaults
{
public static readonly TimeSpan DefaultKeepAlivePingTimeout = TimeSpan.FromTicks(TimeSpan.TicksPerSecond * 20);
public static readonly TimeSpan DefaultKeepAlivePingTimeout = TimeSpan.FromSeconds(20);
public static readonly TimeSpan DefaultKeepAlivePingDelay = Timeout.InfiniteTimeSpan;
public const HttpKeepAlivePingPolicy DefaultKeepAlivePingPolicy = HttpKeepAlivePingPolicy.Always;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,12 +134,18 @@ public Http2Connection(HttpConnectionPool pool, Connection connection)
_pendingWindowUpdate = 0;
_idleSinceTickCount = Environment.TickCount64;

_keepAlivePingDelay = (long)_pool.Settings._keepAlivePingDelay.TotalMilliseconds;
_keepAlivePingTimeout = (long)_pool.Settings._keepAlivePingTimeout.TotalMilliseconds;

_keepAlivePingDelay = TimeSpanToMs(_pool.Settings._keepAlivePingDelay);
_keepAlivePingTimeout = TimeSpanToMs(_pool.Settings._keepAlivePingTimeout);
_nextPingRequestTimestamp = Environment.TickCount64 + _keepAlivePingDelay;
_keepAlivePingPolicy = _pool.Settings._keepAlivePingPolicy;

if (NetEventSource.Log.IsEnabled()) TraceConnection(_stream);

static long TimeSpanToMs(TimeSpan value) {
double milliseconds = value.TotalMilliseconds;
return (long)(milliseconds > int.MaxValue? int.MaxValue : milliseconds);
}
}

private object SyncObject => _httpStreams;
Expand Down Expand Up @@ -1908,9 +1914,9 @@ private void VerifyKeepAlive()
{
if (_keepAlivePingPolicy == HttpKeepAlivePingPolicy.WithActiveRequests)
{
lock(SyncObject)
lock (SyncObject)
{
if(_httpStreams.Count == 0) return;
if (_httpStreams.Count == 0) return;
}
}

Expand All @@ -1919,7 +1925,7 @@ private void VerifyKeepAlive()
{
case KeepAliveState.None:
// Check whether keep alive delay has passed since last frame received
if (now > _nextPingRequestTimestamp && _keepAlivePingDelay != Timeout.InfiniteTimeSpan.TotalMilliseconds)
if (now > _nextPingRequestTimestamp)
{
// Set the status directly to ping sent and set the timestamp
_keepAliveState = KeepAliveState.PingSent;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,14 +119,16 @@ public HttpConnectionPoolManager(HttpConnectionSettings settings)
// For now heart beat is used only for ping functionality.
if (_settings._keepAlivePingDelay != Timeout.InfiniteTimeSpan)
{
long heartBeatInterval = (long)Math.Max(1000, Math.Min(_settings._keepAlivePingDelay.TotalMilliseconds, _settings._keepAlivePingTimeout.TotalMilliseconds) / 4);

_heartBeatTimer = new Timer(static state =>
{
var wr = (WeakReference<HttpConnectionPoolManager>)state!;
if (wr.TryGetTarget(out HttpConnectionPoolManager? thisRef))
{
thisRef.HeartBeat();
}
}, thisRef, TimeSpan.FromSeconds(1), TimeSpan.FromSeconds(1));
}, thisRef, heartBeatInterval, heartBeatInterval);
}
}
finally
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ public TimeSpan KeepAlivePingDelay
}

CheckDisposedOrStarted();
_settings._keepAlivePingDelay = value.TotalMilliseconds > int.MaxValue? TimeSpan.FromMilliseconds(int.MaxValue) : value;
_settings._keepAlivePingDelay = value;
}
}

Expand All @@ -326,7 +326,7 @@ public TimeSpan KeepAlivePingTimeout
}

CheckDisposedOrStarted();
_settings._keepAlivePingTimeout = value.TotalMilliseconds > int.MaxValue? TimeSpan.FromMilliseconds(int.MaxValue) : value;
_settings._keepAlivePingTimeout = value;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -304,21 +304,6 @@ public void SettersExceptions()
Assert.Throws<ArgumentOutOfRangeException>(() => handler.KeepAlivePingTimeout = TimeSpan.FromMilliseconds(500));
}

[Theory]
[InlineData(1000, 1000)]
[InlineData(int.MaxValue - 1, int.MaxValue - 1)]
[InlineData(int.MaxValue, int.MaxValue)]
// Setter starts clamp the value
[InlineData((double)int.MaxValue + 1, (double)int.MaxValue)]
public void Setters(double milliseconds, double expectedMilliseconds)
{
using var handler = new SocketsHttpHandler();

handler.KeepAlivePingTimeout = TimeSpan.FromMilliseconds(milliseconds);
Assert.Equal(TimeSpan.FromMilliseconds(expectedMilliseconds), handler.KeepAlivePingTimeout);
}


public static IEnumerable<object[]> KeepAliveTestDataSource()
{
yield return new object[] { Timeout.InfiniteTimeSpan, TimeSpan.FromSeconds(0), HttpKeepAlivePingPolicy.Always, false, false, false };
Expand Down