Skip to content

Commit

Permalink
Python: Fix crash during garbage collection
Browse files Browse the repository at this point in the history
Same fix as commit d2a5491

Prevent Garbage Collector (GC) from deleting host and root objects
before all controller objects under that root/host have been GCed.
This time, it's the init() method that needed the fix. Previously
we had only fixed the connect() method.

Signed-off-by: Martin Belanger <[email protected]>
  • Loading branch information
Martin Belanger authored and igaw committed May 4, 2023
1 parent f64e1a0 commit 2aaf2ed
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion libnvme/nvme.i
Original file line number Diff line number Diff line change
Expand Up @@ -612,7 +612,9 @@ struct nvme_ns {

%pythonappend nvme_ctrl::connect(struct nvme_host *h,
struct nvme_fabrics_config *cfg) {
self.__parent = h # Keep a reference to parent to ensure garbage collection happens in the right order}
self.__host = h # Keep a reference to parent to ensure ctrl obj gets GCed before host}
%pythonappend nvme_ctrl::init(struct nvme_host *h, int instance) {
self.__host = h # Keep a reference to parent to ensure ctrl obj gets GCed before host}
%extend nvme_ctrl {
nvme_ctrl(struct nvme_root *r,
const char *subsysnqn,
Expand Down

0 comments on commit 2aaf2ed

Please sign in to comment.