Commit 7cc35422 authored by Kirill Smelkov's avatar Kirill Smelkov

bigfile/py: Move PyVMA's support for cyclic GC close to pyvma_dealloc

The logic in pyvma_traverse and pyvma_clear needs to be synchronized
with PyVMA deallocation. In the next patche we'll be amending this
logic, and it will help a reader to keep all those functions together.

For the reference: PyVMA support for cyclic GC was introduced in
450ad804 (bigarray: ArrayRef support for BigArray). See also d97641d2
(bigfile/py: Properly untrack PyVMA from GC before dealloc).

/proposed-for-review-on nexedi/wendelin.core!12
parent a702d410
/* Wendelin.bigfile | Python interface to memory/files
* Copyright (C) 2014-2019 Nexedi SA and Contributors.
* Copyright (C) 2014-2020 Nexedi SA and Contributors.
* Kirill Smelkov <kirr@nexedi.com>
*
* This program is free software: you can Use, Study, Modify and Redistribute
......@@ -165,26 +165,6 @@ pyvma_len(PyObject *pyvma0)
}
/* pyvma vs cyclic GC */
static int
pyvma_traverse(PyObject *pyvma0, visitproc visit, void *arg)
{
PyVMA *pyvma = container_of(pyvma0, PyVMA, pyobj);
Py_VISIT(pyvma->pyuser);
return 0;
}
static int
pyvma_clear(PyObject *pyvma0)
{
PyVMA *pyvma = container_of(pyvma0, PyVMA, pyobj);
Py_CLEAR(pyvma->pyuser);
return 0;
}
PyFunc(pyvma_filerange, "filerange() -> (pgoffset, pglen) -- file range this vma covers")
(PyObject *pyvma0, PyObject *args)
{
......@@ -211,6 +191,26 @@ PyFunc(pyvma_pagesize, "pagesize() -> pagesize -- page size of RAM underlying th
}
/* pyvma vs cyclic GC */
static int
pyvma_traverse(PyObject *pyvma0, visitproc visit, void *arg)
{
PyVMA *pyvma = container_of(pyvma0, PyVMA, pyobj);
Py_VISIT(pyvma->pyuser);
return 0;
}
static int
pyvma_clear(PyObject *pyvma0)
{
PyVMA *pyvma = container_of(pyvma0, PyVMA, pyobj);
Py_CLEAR(pyvma->pyuser);
return 0;
}
static void
pyvma_dealloc(PyObject *pyvma0)
{
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment