Skip to content
This repository was archived by the owner on Jul 22, 2023. It is now read-only.

Commit d9b21a5

Browse files
committed
Revert "Change refcount logic in ImportHook.Shutdown"
This reverts commit 82034dc.
1 parent 8c133e3 commit d9b21a5

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

src/runtime/importhook.cs

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -108,25 +108,24 @@ internal static void Shutdown()
108108
}
109109

110110
RestoreImport();
111+
111112
bool shouldFreeDef = Runtime.Refcount(py_clr_module) == 1;
112-
#if !NETSTANDARD
113-
if(Runtime.ShutdownMode != ShutdownMode.Reload)
114-
#endif
113+
Runtime.XDecref(py_clr_module);
114+
py_clr_module = IntPtr.Zero;
115+
if (shouldFreeDef)
115116
{
116-
Runtime.XDecref(py_clr_module);
117-
py_clr_module = IntPtr.Zero;
118-
if (shouldFreeDef)
119-
{
120-
ReleaseModuleDef();
121-
}
122-
Runtime.XDecref(root.pyHandle);
117+
ReleaseModuleDef();
123118
}
119+
120+
Runtime.XDecref(root.pyHandle);
124121
root = null;
125122
CLRModule.Reset();
126123
}
127124

128125
internal static void SaveRuntimeData(RuntimeDataStorage storage)
129126
{
127+
Runtime.XIncref(py_clr_module);
128+
Runtime.XIncref(root.pyHandle);
130129
storage.AddValue("py_clr_module", py_clr_module);
131130
storage.AddValue("root", root.pyHandle);
132131
}

0 commit comments

Comments
 (0)