Commit 1bac87e804 ("terminal: fix race when closing a terminal") fixed
a race in Terminal.Draw by using a mutex. The current locking of the
entire Draw function could create a deadlock, however, since this
function itself might call Terminal.Close which is protected by the same
mutex. A finer-grained locking solves both the race and deadlock
problem.
Signed-off-by: Koni Marti <koni.marti@gmail.com>
Acked-by: Robin Jarry <robin@jarry.cc>