Skip to content

Commit

Permalink
Update graceful-shutdown.md
Browse files Browse the repository at this point in the history
Avoid memory leak on combined CancellationTokenSource
  • Loading branch information
JakobOoms authored Dec 4, 2024
1 parent c31406f commit b206bd0
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions samples/kubernetes/graceful-shutdown/graceful-shutdown.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ app.Use((httpContext, next) =>
{
var hostLifetime = httpContext.RequestServices.GetRequiredService<IHostApplicationLifetime>();
var originalCt = httpContext.RequestAborted;
var combinedCt = CancellationTokenSource.CreateLinkedTokenSource(originalCt, hostLifetime.ApplicationStopping).Token;
httpContext.RequestAborted = combinedCt;
using var combinedCts = CancellationTokenSource.CreateLinkedTokenSource(originalCt, hostLifetime.ApplicationStopping);
httpContext.RequestAborted = combinedCts.Token;
return next(httpContext);
});
```
Expand Down

0 comments on commit b206bd0

Please sign in to comment.