Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Z
ZEO
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
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
ZEO
Commits
64916308
Commit
64916308
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
f6bec97e
Changes
3
Hide 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 @
64916308
...
...
@@ -25,6 +25,7 @@ from ZODB.tests.MinPO import MinPO
from
ZODB.utils
import
p64
import
doctest
import
gc
import
sys
import
threading
import
time
import
transaction
...
...
@@ -337,6 +338,8 @@ class CacheErrors(unittest.TestCase):
def
add
(
key
,
obj
):
self
.
cache
[
key
]
=
obj
nones
=
sys
.
getrefcount
(
None
)
key
=
p64
(
2
)
# value isn't persistent
self
.
assertRaises
(
TypeError
,
add
,
key
,
12
)
...
...
@@ -360,6 +363,8 @@ class CacheErrors(unittest.TestCase):
# same object, different keys
self
.
assertRaises
(
ValueError
,
add
,
p64
(
0
),
o
)
self
.
assertEqual
(
sys
.
getrefcount
(
None
),
nones
)
def
checkTwoCaches
(
self
):
jar2
=
StubDataManager
()
cache2
=
PickleCache
(
jar2
)
...
...
src/persistent/cPickleCache.c
View file @
64916308
...
...
@@ -242,6 +242,8 @@ scan_gc_items(ccobject *self, int target, PY_LONG_LONG target_bytes)
Py_DECREF
(
method
);
if
(
temp
==
NULL
)
error_occurred
=
1
;
else
Py_DECREF
(
temp
);
}
here
=
placeholder
.
r_next
;
...
...
@@ -354,7 +356,6 @@ _invalidate(ccobject *self, PyObject *key)
{
static
PyObject
*
_p_invalidate
=
NULL
;
PyObject
*
meth
,
*
v
;
int
result
;
v
=
PyDict_GetItem
(
self
->
data
,
key
);
if
(
v
==
NULL
)
...
...
@@ -392,9 +393,10 @@ _invalidate(ccobject *self, PyObject *key)
v
=
PyObject_CallObject
(
meth
,
NULL
);
Py_DECREF
(
meth
);
result
=
v
==
NULL
?
-
1
:
0
;
if
(
v
==
NULL
)
return
-
1
;
Py_DECREF
(
v
);
return
result
;
return
0
;
}
static
PyObject
*
...
...
@@ -1039,9 +1041,11 @@ cc_add_item(ccobject *self, PyObject *key, PyObject *v)
return
-
1
;
if
(
!
PyString_Check
(
oid
))
{
Py_DECREF
(
oid
);
PyErr_Format
(
PyExc_TypeError
,
"Cached object oid must be a string, not a %s"
,
oid
->
ob_type
->
tp_name
);
return
-
1
;
}
...
...
src/persistent/tests/test_PickleCache.py
View file @
64916308
...
...
@@ -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
>>> import transaction
...
...
@@ -127,6 +127,12 @@ def cache_invalidate_used_to_leak_None_ref():
>>> sys.getrefcount(None) - old
0
>>> _ = conn.root.p.keys()
>>> old = sys.getrefcount(None)
>>> conn._cache.minimize()
>>> sys.getrefcount(None) - old
0
>>> 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