Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
_PyCrossInterpreterData_UnregisterClass -> clear_xid_class
  • Loading branch information
ericsnowcurrently committed Mar 4, 2024
commit 38fe300665bf05d69309ffc1297e884b2a6d72d3
8 changes: 8 additions & 0 deletions Modules/_interpreters_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,11 @@ ensure_xid_class(PyTypeObject *cls, crossinterpdatafunc getdata)
//assert(cls->tp_flags & Py_TPFLAGS_HEAPTYPE);
return _PyCrossInterpreterData_RegisterClass(cls, getdata);
}

#ifdef REGISTERS_HEAP_TYPES
static int
clear_xid_class(PyTypeObject *cls)
{
return _PyCrossInterpreterData_UnregisterClass(cls);
}
#endif
14 changes: 8 additions & 6 deletions Modules/_xxinterpchannelsmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@
#include <sched.h> // sched_yield()
#endif

#define REGISTERS_HEAP_TYPES
#include "_interpreters_common.h"
#undef REGISTERS_HEAP_TYPES


/*
Expand Down Expand Up @@ -281,17 +283,17 @@ clear_xid_types(module_state *state)
{
/* external types */
if (state->send_channel_type != NULL) {
(void)_PyCrossInterpreterData_UnregisterClass(state->send_channel_type);
(void)clear_xid_class(state->send_channel_type);
Py_CLEAR(state->send_channel_type);
}
if (state->recv_channel_type != NULL) {
(void)_PyCrossInterpreterData_UnregisterClass(state->recv_channel_type);
(void)clear_xid_class(state->recv_channel_type);
Py_CLEAR(state->recv_channel_type);
}

/* heap types */
if (state->ChannelIDType != NULL) {
(void)_PyCrossInterpreterData_UnregisterClass(state->ChannelIDType);
(void)clear_xid_class(state->ChannelIDType);
Py_CLEAR(state->ChannelIDType);
}
}
Expand Down Expand Up @@ -2677,11 +2679,11 @@ set_channelend_types(PyObject *mod, PyTypeObject *send, PyTypeObject *recv)

// Clear the old values if the .py module was reloaded.
if (state->send_channel_type != NULL) {
(void)_PyCrossInterpreterData_UnregisterClass(state->send_channel_type);
(void)clear_xid_class(state->send_channel_type);
Py_CLEAR(state->send_channel_type);
}
if (state->recv_channel_type != NULL) {
(void)_PyCrossInterpreterData_UnregisterClass(state->recv_channel_type);
(void)clear_xid_class(state->recv_channel_type);
Py_CLEAR(state->recv_channel_type);
}

Expand All @@ -2694,7 +2696,7 @@ set_channelend_types(PyObject *mod, PyTypeObject *send, PyTypeObject *recv)
return -1;
}
if (ensure_xid_class(recv, _channelend_shared) < 0) {
(void)_PyCrossInterpreterData_UnregisterClass(state->send_channel_type);
(void)clear_xid_class(state->send_channel_type);
Py_CLEAR(state->send_channel_type);
Py_CLEAR(state->recv_channel_type);
return -1;
Expand Down
7 changes: 4 additions & 3 deletions Modules/_xxinterpqueuesmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
#include "Python.h"
#include "pycore_crossinterp.h" // struct _xid

#define REGISTERS_HEAP_TYPES
#include "_interpreters_common.h"
#undef REGISTERS_HEAP_TYPES


#define MODULE_NAME _xxinterpqueues
Expand Down Expand Up @@ -186,7 +188,7 @@ clear_module_state(module_state *state)
{
/* external types */
if (state->queue_type != NULL) {
(void)_PyCrossInterpreterData_UnregisterClass(state->queue_type);
(void)clear_xid_class(state->queue_type);
}
Py_CLEAR(state->queue_type);

Expand Down Expand Up @@ -1146,8 +1148,7 @@ set_external_queue_type(module_state *state, PyTypeObject *queue_type)
{
// Clear the old value if the .py module was reloaded.
if (state->queue_type != NULL) {
(void)_PyCrossInterpreterData_UnregisterClass(
state->queue_type);
(void)clear_xid_class(state->queue_type);
Py_CLEAR(state->queue_type);
}

Expand Down