src,quic: add custom smart pointer for BaseObjects by addaleax · Pull Request #141 · nodejs/quic

added 7 commits

September 29, 2019 19:12
This simplifies the implementation of ELDHistogram a bit,
and more generally allows us to have weak JS references
associated with `HandleWrap`s.

PR-URL: nodejs/node#29317
Reviewed-By: James M Snell <jasnell@gmail.com>
In 0af62aa, this was overlooked, with it
possibly leading to hard crashes.

Refs: nodejs/node#29317

PR-URL: nodejs/node#29640
Reviewed-By: Ben Coe <bencoe@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Referring to `BaseObject` instances using standard C++ smart pointers
can interfere with BaseObject’s own cleanup mechanisms
(explicit delete, delete-on-GC and delete-on-cleanup).

Introducing custom smart pointers allows referring to `BaseObject`s
safely while keeping those mechanisms intact.
Previously, the QuicSocket instance would always be destroyed first
during cleanup (because it is a `HandleWrap`), destroying the other
native objects associated with it in the process. This makes sure
that cleanup also works when the session is detached from the
“real” network socket. In particular, this is useful for the future
possibility of fully detaching sessions from sockets.

addaleax

@addaleax

@addaleax

jasnell pushed a commit that referenced this pull request

Oct 1, 2019
Referring to `BaseObject` instances using standard C++ smart pointers
can interfere with BaseObject’s own cleanup mechanisms
(explicit delete, delete-on-GC and delete-on-cleanup).

Introducing custom smart pointers allows referring to `BaseObject`s
safely while keeping those mechanisms intact.

PR-URL: #141
Reviewed-By: James M Snell <jasnell@gmail.com>

jasnell pushed a commit that referenced this pull request

Oct 1, 2019
PR-URL: #141
Reviewed-By: James M Snell <jasnell@gmail.com>

jasnell pushed a commit that referenced this pull request

Oct 1, 2019
PR-URL: #141
Reviewed-By: James M Snell <jasnell@gmail.com>

jasnell pushed a commit that referenced this pull request

Oct 1, 2019
PR-URL: #141
Reviewed-By: James M Snell <jasnell@gmail.com>

jasnell pushed a commit that referenced this pull request

Oct 1, 2019
Previously, the QuicSocket instance would always be destroyed first
during cleanup (because it is a `HandleWrap`), destroying the other
native objects associated with it in the process. This makes sure
that cleanup also works when the session is detached from the
“real” network socket. In particular, this is useful for the future
possibility of fully detaching sessions from sockets.

PR-URL: #141
Reviewed-By: James M Snell <jasnell@gmail.com>

jasnell pushed a commit that referenced this pull request

Oct 2, 2019
Referring to `BaseObject` instances using standard C++ smart pointers
can interfere with BaseObject’s own cleanup mechanisms
(explicit delete, delete-on-GC and delete-on-cleanup).

Introducing custom smart pointers allows referring to `BaseObject`s
safely while keeping those mechanisms intact.

PR-URL: #141
Reviewed-By: James M Snell <jasnell@gmail.com>

jasnell pushed a commit that referenced this pull request

Oct 2, 2019
PR-URL: #141
Reviewed-By: James M Snell <jasnell@gmail.com>

jasnell pushed a commit that referenced this pull request

Oct 3, 2019
Referring to `BaseObject` instances using standard C++ smart pointers
can interfere with BaseObject’s own cleanup mechanisms
(explicit delete, delete-on-GC and delete-on-cleanup).

Introducing custom smart pointers allows referring to `BaseObject`s
safely while keeping those mechanisms intact.

PR-URL: #141
Reviewed-By: James M Snell <jasnell@gmail.com>

jasnell pushed a commit that referenced this pull request

Oct 3, 2019
PR-URL: #141
Reviewed-By: James M Snell <jasnell@gmail.com>

addaleax added a commit to addaleax/node that referenced this pull request

Nov 12, 2019
Referring to `BaseObject` instances using standard C++ smart pointers
can interfere with BaseObject’s own cleanup mechanisms
(explicit delete, delete-on-GC and delete-on-cleanup).

Introducing custom smart pointers allows referring to `BaseObject`s
safely while keeping those mechanisms intact.

Refs: nodejs/quic#141
Refs: nodejs/quic#149
Reviewed-By: James M Snell <jasnell@gmail.com>

addaleax added a commit to addaleax/node that referenced this pull request

Nov 12, 2019

MylesBorins pushed a commit to addaleax/node that referenced this pull request

Apr 1, 2020
Referring to `BaseObject` instances using standard C++ smart pointers
can interfere with BaseObject’s own cleanup mechanisms
(explicit delete, delete-on-GC and delete-on-cleanup).

Introducing custom smart pointers allows referring to `BaseObject`s
safely while keeping those mechanisms intact.

Refs: nodejs/quic#141
Refs: nodejs/quic#149
Reviewed-By: James M Snell <jasnell@gmail.com>

PR-URL: nodejs#30374
Refs: nodejs/quic#165
Reviewed-By: David Carlier <devnexen@gmail.com>

MylesBorins pushed a commit to addaleax/node that referenced this pull request

Apr 1, 2020

MylesBorins pushed a commit to addaleax/node that referenced this pull request

Apr 1, 2020

MylesBorins pushed a commit to addaleax/node that referenced this pull request

Apr 1, 2020

MylesBorins pushed a commit to addaleax/node that referenced this pull request

Apr 1, 2020
This allows keeping `BaseObjectPtr`s to `HandleWrap` instances.
Previously, the pointer kept the `HandleWrap` object alive, leaving
the Environment cleanup code that waits for the handle list to drain
in a busy loop, because only the `HandleWrap` destructor removed
the item from the list.

Refs: nodejs/quic#165
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com>

PR-URL: nodejs#30374
Refs: nodejs/quic#141
Refs: nodejs/quic#149
Refs: nodejs/quic#141
Reviewed-By: David Carlier <devnexen@gmail.com>

MylesBorins pushed a commit to nodejs/node that referenced this pull request

Apr 1, 2020
Referring to `BaseObject` instances using standard C++ smart pointers
can interfere with BaseObject’s own cleanup mechanisms
(explicit delete, delete-on-GC and delete-on-cleanup).

Introducing custom smart pointers allows referring to `BaseObject`s
safely while keeping those mechanisms intact.

Refs: nodejs/quic#141
Refs: nodejs/quic#149
Reviewed-By: James M Snell <jasnell@gmail.com>

Backport-PR-URL: #32301
PR-URL: #30374
Refs: nodejs/quic#165
Reviewed-By: David Carlier <devnexen@gmail.com>

MylesBorins pushed a commit to nodejs/node that referenced this pull request

Apr 1, 2020

MylesBorins pushed a commit to nodejs/node that referenced this pull request

Apr 1, 2020

MylesBorins pushed a commit to nodejs/node that referenced this pull request

Apr 1, 2020

MylesBorins pushed a commit to nodejs/node that referenced this pull request

Apr 1, 2020
This allows keeping `BaseObjectPtr`s to `HandleWrap` instances.
Previously, the pointer kept the `HandleWrap` object alive, leaving
the Environment cleanup code that waits for the handle list to drain
in a busy loop, because only the `HandleWrap` destructor removed
the item from the list.

Refs: nodejs/quic#165
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com>

Backport-PR-URL: #32301
PR-URL: #30374
Refs: nodejs/quic#141
Refs: nodejs/quic#149
Refs: nodejs/quic#141
Reviewed-By: David Carlier <devnexen@gmail.com>