a fork of iceshrimp.net but a tweaked frontend to my personal liking. waow
fediverse social-media social iceshrimp fedi
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

[backend/core] Don't use TaskCreationOptions.LongRunning for async code

See https://github.com/davidfowl/AspNetCoreDiagnosticScenarios/blob/master/AsyncGuidance.md#avoid-using-taskrun-for-long-running-work-that-blocks-the-thread for more details

+12 -14
+6 -8
Iceshrimp.Backend/Controllers/Web/AdminController.cs
··· 386 386 var task = cronSvc.Tasks.FirstOrDefault(p => p.Task.GetType().FullName == id) 387 387 ?? throw GracefulException.NotFound("Task not found"); 388 388 389 - Task.Factory.StartNew(async () => 390 - { 391 - await cronSvc.RunCronTaskAsync(task.Task, task.Trigger); 392 - task.Trigger.UpdateNextTrigger(); 393 - }, 394 - CancellationToken.None, 395 - TaskCreationOptions.DenyChildAttach | TaskCreationOptions.LongRunning, 396 - TaskScheduler.Default); 389 + Task.Run(async () => 390 + { 391 + await cronSvc.RunCronTaskAsync(task.Task, task.Trigger); 392 + task.Trigger.UpdateNextTrigger(); 393 + }, 394 + CancellationToken.None); 397 395 } 398 396 399 397 [HttpGet("policy")]
+4 -4
Iceshrimp.Backend/Core/Services/CronService.cs
··· 111 111 CancellationToken = cancellationToken; 112 112 NextTrigger = DateTime.UtcNow; 113 113 114 - RunningTask = Task.Factory.StartNew(async () => 114 + RunningTask = Task.Run(async () => 115 115 { 116 116 while (!CancellationToken.IsCancellationRequested) 117 117 { ··· 119 119 await Task.Delay(nextTrigger, CancellationToken); 120 120 OnTrigger?.Invoke(this); 121 121 } 122 - }, CancellationToken, TaskCreationOptions.DenyChildAttach | TaskCreationOptions.LongRunning, TaskScheduler.Default); 122 + }, CancellationToken); 123 123 } 124 124 125 125 public TimeSpan UpdateNextTrigger() ··· 163 163 CancellationToken = cancellationToken; 164 164 NextTrigger = DateTime.UtcNow + TriggerInterval; 165 165 166 - RunningTask = Task.Factory.StartNew(async () => 166 + RunningTask = Task.Run(async () => 167 167 { 168 168 while (!CancellationToken.IsCancellationRequested) 169 169 { ··· 178 178 179 179 OnTrigger?.Invoke(this); 180 180 } 181 - }, CancellationToken, TaskCreationOptions.DenyChildAttach | TaskCreationOptions.LongRunning, TaskScheduler.Default); 181 + }, CancellationToken); 182 182 } 183 183 184 184 public TimeSpan UpdateNextTrigger()
+2 -2
Iceshrimp.Backend/Core/Services/QueueService.cs
··· 60 60 logger.LogInformation("Queue shutdown complete."); 61 61 }); 62 62 63 - _ = Task.Factory.StartNew(ExecuteHealthchecksWorkerAsync, token, TaskCreationOptions.DenyChildAttach | TaskCreationOptions.LongRunning, TaskScheduler.Default); 64 - await Task.Factory.StartNew(ExecuteBackgroundWorkersAsync, tokenSource.Token, TaskCreationOptions.DenyChildAttach | TaskCreationOptions.LongRunning, TaskScheduler.Default); 63 + _ = Task.Run(ExecuteHealthchecksWorkerAsync, token); 64 + await Task.Run(ExecuteBackgroundWorkersAsync, tokenSource.Token); 65 65 66 66 return; 67 67