Skip to content

Commit cb284b9

Browse files
committed
Fix race that would allow GetDateHeaderValues to return null
1 parent d164f35 commit cb284b9

File tree

1 file changed

+4
-14
lines changed

1 file changed

+4
-14
lines changed

src/Microsoft.AspNetCore.Server.Kestrel/Http/DateHeaderValueManager.cs

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,11 @@ internal DateHeaderValueManager(
5858
/// <returns>The value in string and byte[] format.</returns>
5959
public DateHeaderValues GetDateHeaderValues()
6060
{
61-
if (!_hadRequestsSinceLastTimerTick)
61+
_hadRequestsSinceLastTimerTick = !_isDisposed;
62+
63+
if (!_timerIsRunning)
6264
{
63-
PrepareDateValues();
65+
StartTimer();
6466
}
6567

6668
return _dateValues;
@@ -151,18 +153,6 @@ private void TimerLoop(object state)
151153
}
152154
}
153155

154-
/// <summary>
155-
/// Starts the timer if it's turned off, or sets the datevalues to the current time if disposed.
156-
/// </summary>
157-
private void PrepareDateValues()
158-
{
159-
_hadRequestsSinceLastTimerTick = !_isDisposed;
160-
if (!_timerIsRunning)
161-
{
162-
StartTimer();
163-
}
164-
}
165-
166156
/// <summary>
167157
/// Sets date values from a provided ticks value
168158
/// </summary>

0 commit comments

Comments
 (0)