Skip to content

Commit

Permalink
cmd/acme: fix ui deadlock
Browse files Browse the repository at this point in the history
I don't quite understand why this loop sometimes runs forever.
There may be another problem. But this should at least stop the
deadlock, which wouldn't have happened in the C version either.

Fixes #81.
  • Loading branch information
rsc committed Nov 17, 2021
1 parent d63f25e commit 6faf3d8
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
2 changes: 2 additions & 0 deletions cmd/acme/acme.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,8 @@ func main() {
editpkg.Run = func(w *wind.Window, s string, rdir []rune) {
exec.Run(w, s, rdir, true, nil, nil, true)
}
ui.BigLock = bigLock
ui.BigUnlock = bigUnlock
exec.Fsysmount = fsysmount
exec.Fsysdelid = fsysdelid
exec.Xfidlog = xfidlog
Expand Down
13 changes: 12 additions & 1 deletion cmd/acme/internal/ui/text.go
Original file line number Diff line number Diff line change
Expand Up @@ -467,13 +467,24 @@ func Textselect(t *wind.Text) {
Clearmouse()
}
adraw.Display.Flush()

// Mousectl.Read does both the Flush
// and the receive. We did the flush.
// Do just the receive, dropping biglock
// to let other goroutines proceed.
// Note that *Mouse is Mousectl.Mouse.
BigUnlock()
for Mouse.Buttons == b {
Mousectl.Read()
*Mouse = <-Mousectl.C
}
BigLock()
clicktext = nil
}
}

var BigLock = func(){}
var BigUnlock = func(){}

/*
* Release the button in less than DELAY ms and it's considered a null selection
* if the mouse hardly moved, regardless of whether it crossed a char boundary.
Expand Down

0 comments on commit 6faf3d8

Please sign in to comment.