A personal assistant that lives on your desktop, remembers what matters, and can use your Mac for you.
TypeScript
fix(desktop): bound the post-cancel wait in the Windows stop listener
Rowell Urbaez Reyes9db6c3873cf6
diff --git a/packages/daemon/native/windows-stop.cc b/packages/daemon/native/windows-stop.ccindex 0690518..8a265a2 100644--- a/packages/daemon/native/windows-stop.cc+++ b/packages/daemon/native/windows-stop.cc@@ -261,6 +261,7 @@ bool Complete(State& s, DWORD timeout, DWORD& transferred) {if (code != ERROR_NOT_FOUND) { s.Fail(code); s.Stop(); NotifyDeadline(s); }}ULONGLONG started = GetTickCount64();+ bool reported = false;for (;;) {if (GetOverlappedResult(s.pipe.value, &op.overlapped, &transferred, FALSE)) return false;DWORD code = GetLastError();@@ -268,14 +269,19 @@ bool Complete(State& s, DWORD timeout, DWORD& transferred) {if (!ExpectedDisconnect(code)) { s.Fail(code); s.Stop(); }return false;}- if (GetTickCount64() - started >= kDeadlineMs) {+ const ULONGLONG elapsed = GetTickCount64() - started;+ if (!reported && elapsed >= kDeadlineMs) {s.Fail(ERROR_TIMEOUT); s.Stop(); NotifyDeadline(s);+ reported = true;}// Poll only the retained operation's completion, not the already-set stop- // event. A pathological signaled-but-incomplete event cannot busy-spin.+ // event. If the kernel never retires the cancelled operation, spinning here+ // would hold the pipe handle and this thread forever, so the loop gives up+ // one deadline after the timeout is reported.+ if (elapsed >= kDeadlineMs * 2) return false;DWORD completion = WaitForSingleObject(op.event.value, 50);if (completion == WAIT_FAILED) { s.Fail(GetLastError()); Sleep(50); }- else if (completion == WAIT_OBJECT_0) Sleep(1);+ else if (completion == WAIT_OBJECT_0) Sleep(10);}}bool ClientIsOwner(State& s) {