Fix race that would allow GetDateHeaderValues to return null

This commit is contained in:
Stephen Halter 2016-05-23 20:38:51 -07:00
parent d164f350b4
commit cb284b9d58
1 changed files with 4 additions and 14 deletions

View File

@ -58,9 +58,11 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Http
/// <returns>The value in string and byte[] format.</returns>
public DateHeaderValues GetDateHeaderValues()
{
if (!_hadRequestsSinceLastTimerTick)
_hadRequestsSinceLastTimerTick = !_isDisposed;
if (!_timerIsRunning)
{
PrepareDateValues();
StartTimer();
}
return _dateValues;
@ -151,18 +153,6 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Http
}
}
/// <summary>
/// Starts the timer if it's turned off, or sets the datevalues to the current time if disposed.
/// </summary>
private void PrepareDateValues()
{
_hadRequestsSinceLastTimerTick = !_isDisposed;
if (!_timerIsRunning)
{
StartTimer();
}
}
/// <summary>
/// Sets date values from a provided ticks value
/// </summary>