fix(core): take over agent, reuse callbacks
- Kill running agents before replace - Retry copy with backoff while locked - Reuse syscall callbacks at package scope - Add callback regression test
This commit is contained in:
@@ -76,6 +76,8 @@ var (
|
||||
hookMods modifierState
|
||||
lastHWND uintptr
|
||||
lastTitle string
|
||||
// ponytail: NewCallback is never freed; reuse across Start/Stop.
|
||||
hookCB = syscall.NewCallback(keyboardHookProc)
|
||||
)
|
||||
|
||||
func startPlatform(_ *Writer, events chan Event, stop <-chan struct{}, done chan struct{}) error {
|
||||
@@ -120,8 +122,7 @@ func runHookThread(ready chan struct{}) error {
|
||||
hookThreadID = windowsGetCurrentThreadId()
|
||||
close(ready)
|
||||
|
||||
hookProc := syscall.NewCallback(keyboardHookProc)
|
||||
handle, _, err := procSetWindowsHookExW.Call(whKeyboardLL, hookProc, 0, 0)
|
||||
handle, _, err := procSetWindowsHookExW.Call(whKeyboardLL, hookCB, 0, 0)
|
||||
if handle == 0 {
|
||||
return err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user