Commit 9e55192
Fix
Summary:
This fixes two possible deadlocks that cause `elp server` to hang during exit. I was on the right track in #74 but there are actually two deadlocks:
* The first happens because the logger backend has a clone of the `Sender` of the `Connection` (because the `LspLogger` clones it one). This can cause a deadlock when a message is _not_ logged following the drop of `Server` on `io_threads.join()` because the `Connection`'s thread for receiving messages from the `Connection`'s `Receiver` awaits messages indefinitely. The solution for this deadlock is to remove the `LspLogger` from the backend on `Drop` of the server (or any time earlier). That decrements the reference count on the `Sender` and causes the `Receiver`'s iterator to return `None` resulting in the termination of its thread.
* The second I don't really understand fully. The `Drop for Server` hangs because the cache task pool's drop joins its threads (by design) and there is an outstanding task that seems to be frozen, I think related to Salsa's cancellation mechanism. Explicitly requesting cancellation during drop eliminates this problem. Plus it matches what rust-analyzer does.
Fixes #36
Pull Request resolved: #75
Reviewed By: michalmuskala
Differential Revision: D69115301
Pulled By: alanz
fbshipit-source-id: 3b0a5b39f49d668199a2370f1b23bc78f0ae6d17Drop for Server deadlock behavior (#75)1 parent 5608951 commit 9e55192
2 files changed
+17
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
256 | 256 | | |
257 | 257 | | |
258 | 258 | | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
259 | 269 | | |
260 | 270 | | |
261 | 271 | | |
| |||
603 | 613 | | |
604 | 614 | | |
605 | 615 | | |
606 | | - | |
607 | 616 | | |
608 | 617 | | |
609 | 618 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
72 | 72 | | |
73 | 73 | | |
74 | 74 | | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
75 | 82 | | |
76 | 83 | | |
77 | 84 | | |
| |||
0 commit comments