LocalServer: better synchronization
(cherry picked from commit 7589f69)