Repository navigation
Commit b52dce3
committed
fix: the process ends after
Reported from an editor: the server answers `shutdown` and the process stays. Measured with a client that keeps the pipe
open (what an editor does) and never sends `exit`: the process was still alive after a minute. Three things were
keeping it, and each is fixed where it was:
* **`handle_shutdown` waited thirty seconds for the `exit` notification**, and a client that stops after `shutdown` — or
is slow about `exit` — made every one of them visible. The wait is now `EXIT_WAIT` (500 ms) and *any* outcome ends the
process: `exit`, an unexpected message, the pipe closing, or the timeout. The answer was already written before the
wait, which is what the wait exists for.
* **The reader was a `spawn_blocking` task.** It blocks on stdin, and dropping a runtime waits for its blocking tasks, so
the process reached `Server shutting down.` and then sat there until the client closed the pipe. It is a plain
detached thread now: a blocking read does not belong in a pool whose join is part of exiting.
* **The binary builds its own runtime and ends with `shutdown_timeout(250 ms)`**, so work that is already inside
`spawn_blocking` — a program being cooked — cannot hold the exit either.
New test: `handshake.rs::a_shutdown_ends_the_process_while_the_client_keeps_the_pipe` — a real handshake, a real
project, `shutdown` with no `exit`, and the assertion that the process ends. The existing
`..._and_exits_on_exit` still covers the client that follows the protocol to the letter.
Measured: the process ends **0.58 s** after `shutdown` (it was still alive after 60 s before), and the same test
completes in 0.64 s.shutdown, even with the client holding stdin open1 parent 3427e71 commit b52dce3
3 files changed
Lines changed: 86 additions & 23 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
9 | | - | |
10 | | - | |
| 9 | + | |
11 | 10 | | |
12 | | - | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
13 | 23 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
6 | | - | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
7 | 9 | | |
8 | 10 | | |
9 | 11 | | |
10 | 12 | | |
11 | 13 | | |
12 | | - | |
| 14 | + | |
13 | 15 | | |
14 | 16 | | |
15 | 17 | | |
| |||
18 | 20 | | |
19 | 21 | | |
20 | 22 | | |
21 | | - | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
22 | 27 | | |
23 | | - | |
24 | | - | |
25 | | - | |
26 | | - | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
27 | 35 | | |
28 | | - | |
29 | | - | |
| 36 | + | |
| 37 | + | |
30 | 38 | | |
31 | 39 | | |
32 | 40 | | |
| |||
49 | 57 | | |
50 | 58 | | |
51 | 59 | | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
52 | 69 | | |
53 | 70 | | |
54 | 71 | | |
| |||
58 | 75 | | |
59 | 76 | | |
60 | 77 | | |
61 | | - | |
62 | | - | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
63 | 83 | | |
64 | | - | |
65 | | - | |
66 | | - | |
| 84 | + | |
67 | 85 | | |
68 | 86 | | |
69 | | - | |
70 | | - | |
71 | | - | |
| 87 | + | |
72 | 88 | | |
73 | 89 | | |
74 | | - | |
75 | | - | |
76 | | - | |
| 90 | + | |
77 | 91 | | |
78 | 92 | | |
79 | 93 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
412 | 412 | | |
413 | 413 | | |
414 | 414 | | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
415 | 454 | | |
416 | 455 | | |
417 | 456 | | |
| |||
0 commit comments