Repository navigation
Commit 6c8a697
authored
fs: keep readFile abortable on non-regular files
`ReadFileJob` treats a file that is not a regular file as size 0 and
reads it to EOF inside one thread pool job, so the `AbortSignal` is
only checked once the job ends. `fs.readFile()` and
`fs.promises.readFile()` on a FIFO whose writer stays open therefore
do not settle until the writer closes, and on `/dev/zero` they keep
growing the buffer until the process runs out of memory.
Hand the fd back to the chunked reader for non-regular files, the path
files larger than one chunk already take. It checks the signal before
each read. Regular files that report size 0, such as procfs files, are
still read in one job.
Signed-off-by: Christian Aurich Zanettini Martins <christian.aurichzm@gmail.com>
PR-URL: #66940
Refs: #65327
Reviewed-By: Anna Henningsen <anna@addaleax.net>1 parent b1cd451 commit 6c8a697
4 files changed
Lines changed: 69 additions & 17 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
452 | 452 | | |
453 | 453 | | |
454 | 454 | | |
455 | | - | |
456 | | - | |
457 | | - | |
458 | | - | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
459 | 460 | | |
460 | 461 | | |
461 | 462 | | |
| |||
480 | 481 | | |
481 | 482 | | |
482 | 483 | | |
483 | | - | |
| 484 | + | |
| 485 | + | |
484 | 486 | | |
485 | 487 | | |
486 | 488 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2305 | 2305 | | |
2306 | 2306 | | |
2307 | 2307 | | |
2308 | | - | |
2309 | | - | |
2310 | | - | |
| 2308 | + | |
| 2309 | + | |
| 2310 | + | |
2311 | 2311 | | |
2312 | 2312 | | |
2313 | 2313 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3587 | 3587 | | |
3588 | 3588 | | |
3589 | 3589 | | |
3590 | | - | |
3591 | | - | |
3592 | | - | |
| 3590 | + | |
| 3591 | + | |
| 3592 | + | |
| 3593 | + | |
3593 | 3594 | | |
3594 | 3595 | | |
3595 | 3596 | | |
3596 | 3597 | | |
3597 | 3598 | | |
3598 | | - | |
3599 | | - | |
3600 | | - | |
3601 | | - | |
| 3599 | + | |
| 3600 | + | |
| 3601 | + | |
| 3602 | + | |
3602 | 3603 | | |
3603 | 3604 | | |
3604 | 3605 | | |
| |||
3663 | 3664 | | |
3664 | 3665 | | |
3665 | 3666 | | |
3666 | | - | |
3667 | | - | |
| 3667 | + | |
| 3668 | + | |
| 3669 | + | |
3668 | 3670 | | |
3669 | 3671 | | |
3670 | 3672 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
0 commit comments