-
-
Notifications
You must be signed in to change notification settings - Fork 2
fix: WMI disposal, Ookla timeout, docs accuracy (CQ-001, CQ-003) #370
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -196,13 +196,18 @@ public async Task<SpeedTestResult> RunOoklaAsync( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // Start the process on a thread-pool thread so Process.Start() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // never blocks the UI thread. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // never blocks the UI thread. Link a 5-minute timeout to prevent | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // indefinite hangs if the Ookla CLI freezes (CQ-003). | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| using var timeoutCts = CancellationTokenSource.CreateLinkedTokenSource(ct); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| timeoutCts.CancelAfter(TimeSpan.FromMinutes(5)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| var linked = timeoutCts.Token; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| using var proc = new Process(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| proc.StartInfo = psi; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| await Task.Run(() => proc.Start(), ct).ConfigureAwait(false); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| var stdout = await proc.StandardOutput.ReadToEndAsync(ct); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| var stderr = await proc.StandardError.ReadToEndAsync(ct); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| await proc.WaitForExitAsync(ct); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| await Task.Run(() => proc.Start(), linked).ConfigureAwait(false); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| var stdout = await proc.StandardOutput.ReadToEndAsync(linked); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| var stderr = await proc.StandardError.ReadToEndAsync(linked); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| await proc.WaitForExitAsync(linked); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+201
to
+210
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: #!/bin/bash
set -euo pipefail
# Verify whether RunOoklaAsync has a cancellation path that kills the spawned process.
fd -i 'SpeedTestService.cs' | while read -r f; do
echo "== $f =="
rg -n -C4 'RunOoklaAsync|CreateLinkedTokenSource|WaitForExitAsync|OperationCanceledException|Kill\(' "$f"
doneRepository: laurentiu021/SystemManager Length of output: 1315 🏁 Script executed: #!/bin/bash
# Get the complete RunOoklaAsync method to verify exception handling
rg -n -A 60 'public async Task<SpeedTestResult> RunOoklaAsync' 'SysManager/SysManager/Services/SpeedTestService.cs' | head -100Repository: laurentiu021/SystemManager Length of output: 2759 Kill the Ookla process on timeout/cancellation to prevent orphan Lines 207–210 await with the timeout token, but have no exception handler. If the 5-minute timeout triggers, Proposed fix using var proc = new Process();
proc.StartInfo = psi;
-await Task.Run(() => proc.Start(), linked).ConfigureAwait(false);
-var stdout = await proc.StandardOutput.ReadToEndAsync(linked);
-var stderr = await proc.StandardError.ReadToEndAsync(linked);
-await proc.WaitForExitAsync(linked);
+try
+{
+ await Task.Run(() => proc.Start(), linked).ConfigureAwait(false);
+ var stdout = await proc.StandardOutput.ReadToEndAsync(linked);
+ var stderr = await proc.StandardError.ReadToEndAsync(linked);
+ await proc.WaitForExitAsync(linked);
+}
+catch (OperationCanceledException) when (timeoutCts.IsCancellationRequested && !ct.IsCancellationRequested)
+{
+ try { if (!proc.HasExited) proc.Kill(entireProcessTree: true); } catch { }
+ throw new TimeoutException("Ookla CLI timed out after 5 minutes.");
+}
+catch (OperationCanceledException)
+{
+ try { if (!proc.HasExited) proc.Kill(entireProcessTree: true); } catch { }
+ throw;
+}📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (proc.ExitCode != 0) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Align the support table with the written support policy.
Lines 15-18 now show two supported minors, but Line 10 still says fixes apply to the latest minor only. Please make them consistent to avoid ambiguity in security support commitments.
Suggested doc fix
🤖 Prompt for AI Agents