Skip to content

Commit 2aaf2ed

Browse files
Martin Belangerigaw
authored andcommitted
Python: Fix crash during garbage collection
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]>
1 parent f64e1a0 commit 2aaf2ed

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

libnvme/nvme.i

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -612,7 +612,9 @@ struct nvme_ns {
612612

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

0 commit comments

Comments
 (0)