Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Z
ZODB
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kirill Smelkov
ZODB
Commits
bb9ff612
Commit
bb9ff612
authored
Sep 02, 2010
by
Jim Fulton
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed some None ref leaks in cPickleCache.c
parent
38ef55f0
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
19 additions
and
4 deletions
+19
-4
src/ZODB/tests/testCache.py
src/ZODB/tests/testCache.py
+5
-0
src/persistent/cPickleCache.c
src/persistent/cPickleCache.c
+7
-3
src/persistent/tests/test_PickleCache.py
src/persistent/tests/test_PickleCache.py
+7
-1
No files found.
src/ZODB/tests/testCache.py
View file @
bb9ff612
...
@@ -25,6 +25,7 @@ from ZODB.tests.MinPO import MinPO
...
@@ -25,6 +25,7 @@ from ZODB.tests.MinPO import MinPO
from
ZODB.utils
import
p64
from
ZODB.utils
import
p64
import
doctest
import
doctest
import
gc
import
gc
import
sys
import
threading
import
threading
import
time
import
time
import
transaction
import
transaction
...
@@ -337,6 +338,8 @@ class CacheErrors(unittest.TestCase):
...
@@ -337,6 +338,8 @@ class CacheErrors(unittest.TestCase):
def
add
(
key
,
obj
):
def
add
(
key
,
obj
):
self
.
cache
[
key
]
=
obj
self
.
cache
[
key
]
=
obj
nones
=
sys
.
getrefcount
(
None
)
key
=
p64
(
2
)
key
=
p64
(
2
)
# value isn't persistent
# value isn't persistent
self
.
assertRaises
(
TypeError
,
add
,
key
,
12
)
self
.
assertRaises
(
TypeError
,
add
,
key
,
12
)
...
@@ -360,6 +363,8 @@ class CacheErrors(unittest.TestCase):
...
@@ -360,6 +363,8 @@ class CacheErrors(unittest.TestCase):
# same object, different keys
# same object, different keys
self
.
assertRaises
(
ValueError
,
add
,
p64
(
0
),
o
)
self
.
assertRaises
(
ValueError
,
add
,
p64
(
0
),
o
)
self
.
assertEqual
(
sys
.
getrefcount
(
None
),
nones
)
def
checkTwoCaches
(
self
):
def
checkTwoCaches
(
self
):
jar2
=
StubDataManager
()
jar2
=
StubDataManager
()
cache2
=
PickleCache
(
jar2
)
cache2
=
PickleCache
(
jar2
)
...
...
src/persistent/cPickleCache.c
View file @
bb9ff612
...
@@ -242,6 +242,8 @@ scan_gc_items(ccobject *self, int target, PY_LONG_LONG target_bytes)
...
@@ -242,6 +242,8 @@ scan_gc_items(ccobject *self, int target, PY_LONG_LONG target_bytes)
Py_DECREF
(
method
);
Py_DECREF
(
method
);
if
(
temp
==
NULL
)
if
(
temp
==
NULL
)
error_occurred
=
1
;
error_occurred
=
1
;
else
Py_DECREF
(
temp
);
}
}
here
=
placeholder
.
r_next
;
here
=
placeholder
.
r_next
;
...
@@ -354,7 +356,6 @@ _invalidate(ccobject *self, PyObject *key)
...
@@ -354,7 +356,6 @@ _invalidate(ccobject *self, PyObject *key)
{
{
static
PyObject
*
_p_invalidate
=
NULL
;
static
PyObject
*
_p_invalidate
=
NULL
;
PyObject
*
meth
,
*
v
;
PyObject
*
meth
,
*
v
;
int
result
;
v
=
PyDict_GetItem
(
self
->
data
,
key
);
v
=
PyDict_GetItem
(
self
->
data
,
key
);
if
(
v
==
NULL
)
if
(
v
==
NULL
)
...
@@ -392,9 +393,10 @@ _invalidate(ccobject *self, PyObject *key)
...
@@ -392,9 +393,10 @@ _invalidate(ccobject *self, PyObject *key)
v
=
PyObject_CallObject
(
meth
,
NULL
);
v
=
PyObject_CallObject
(
meth
,
NULL
);
Py_DECREF
(
meth
);
Py_DECREF
(
meth
);
result
=
v
==
NULL
?
-
1
:
0
;
if
(
v
==
NULL
)
return
-
1
;
Py_DECREF
(
v
);
Py_DECREF
(
v
);
return
result
;
return
0
;
}
}
static
PyObject
*
static
PyObject
*
...
@@ -1039,9 +1041,11 @@ cc_add_item(ccobject *self, PyObject *key, PyObject *v)
...
@@ -1039,9 +1041,11 @@ cc_add_item(ccobject *self, PyObject *key, PyObject *v)
return
-
1
;
return
-
1
;
if
(
!
PyString_Check
(
oid
))
if
(
!
PyString_Check
(
oid
))
{
{
Py_DECREF
(
oid
);
PyErr_Format
(
PyExc_TypeError
,
PyErr_Format
(
PyExc_TypeError
,
"Cached object oid must be a string, not a %s"
,
"Cached object oid must be a string, not a %s"
,
oid
->
ob_type
->
tp_name
);
oid
->
ob_type
->
tp_name
);
return
-
1
;
return
-
1
;
}
}
...
...
src/persistent/tests/test_PickleCache.py
View file @
bb9ff612
...
@@ -109,7 +109,7 @@ Peristent meta classes work too:
...
@@ -109,7 +109,7 @@ Peristent meta classes work too:
"""
"""
def
cache_invalidate_used_to_leak_None_ref
():
def
cache_invalidate_
and_minimize_
used_to_leak_None_ref
():
"""Persistent weak references
"""Persistent weak references
>>> import transaction
>>> import transaction
...
@@ -127,6 +127,12 @@ def cache_invalidate_used_to_leak_None_ref():
...
@@ -127,6 +127,12 @@ def cache_invalidate_used_to_leak_None_ref():
>>> sys.getrefcount(None) - old
>>> sys.getrefcount(None) - old
0
0
>>> _ = conn.root.p.keys()
>>> old = sys.getrefcount(None)
>>> conn._cache.minimize()
>>> sys.getrefcount(None) - old
0
>>> db.close()
>>> db.close()
"""
"""
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment