1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-11-21 15:04:11 -05:00
denoland-deno/runtime/ops
Andreu Botella b7c2902c97
Don't drop messages from workers that have already been closed (#11913)
When `worker.terminate()` is called, the spec requires that the
corresponding port message queue is emptied, so no messages can be
received after the call, even if they were sent from the worker before
it was terminated.

The spec doesn't require this of `self.close()`, and since Deno uses
different channels to send messages and to notify that the worker was
closed, messages might still arrive after the worker is known to be
closed, which are currently being dropped. This change fixes that.

The fix involves two parts: one on the JS side and one on the Rust side.
The JS side was using the `#terminated` flag to keep track of whether
the worker is known to be closed, without distinguishing whether further
messages should be dropped or not. This PR changes that flag to an
enum `#state`, which can be one of `"RUNNING"`, `"CLOSED"` or
`"TERMINATED"`.

The Rust side was removing the `WorkerThread` struct from the workers
table when a close control was received, regardless of whether there
were any messages left to read, which made any subsequent calls to
`op_host_recv_message` to return `Ok(None)`, as if there were no more
mesasges. This change instead waits for both a close control and for
the message channel's sender to be closed before the worker thread is
removed from the table.
2021-09-06 11:05:02 +02:00
..
web_worker fix(runtime): event loop panics in classic workers (#11756) 2021-08-18 15:19:22 +02:00
fs.rs feat(unstable): Add file locking APIs (#11746) 2021-08-24 15:21:31 +02:00
fs_events.rs chore: update dependencies (#11856) 2021-09-02 23:38:44 +02:00
http.rs refactor(ops): return BadResource errors in ResourceTable calls (#11710) 2021-08-15 13:29:19 +02:00
io.rs refactor(ops): return BadResource errors in ResourceTable calls (#11710) 2021-08-15 13:29:19 +02:00
mod.rs feat(runtime): support classic workers for internal testing (#11338) 2021-08-16 14:29:54 +02:00
os.rs feat(runtime): implement navigator.hardwareConcurrency (#11448) 2021-07-29 21:45:11 +02:00
permissions.rs feat: ffi to replace plugins (#11152) 2021-08-06 23:28:10 +02:00
process.rs refactor(ops): return BadResource errors in ResourceTable calls (#11710) 2021-08-15 13:29:19 +02:00
runtime.rs cleanup(ops): remove unused ZeroCopyBuf arg-types (#10530) 2021-05-08 14:37:42 +02:00
signal.rs refactor(ops): return BadResource errors in ResourceTable calls (#11710) 2021-08-15 13:29:19 +02:00
tty.rs refactor(ops): return BadResource errors in ResourceTable calls (#11710) 2021-08-15 13:29:19 +02:00
utils.rs chore: update copyright headers (#10243) 2021-04-20 14:27:36 +09:00
web_worker.rs feat(runtime): support classic workers for internal testing (#11338) 2021-08-16 14:29:54 +02:00
worker_host.rs Don't drop messages from workers that have already been closed (#11913) 2021-09-06 11:05:02 +02:00