Commit 8afbdd53 authored by Julien Muchembled's avatar Julien Muchembled

client: detect if monkey-patched code changes

parent 54d692c5
...@@ -12,18 +12,25 @@ ...@@ -12,18 +12,25 @@
# #
############################################################################## ##############################################################################
# At the moment, no ZODB release include the following patches.
# Later, this must be replaced by some detection mechanism.
if 1: if 1:
from hashlib import md5
from ZODB.Connection import Connection from ZODB.Connection import Connection
def _check(f, *args):
h = md5(f.func_code.co_code).hexdigest()
assert h in args, h
# Allow serial to be returned as late as tpc_finish # Allow serial to be returned as late as tpc_finish
# #
# This makes possible for storage to allocate serial inside tpc_finish, # This makes possible for storage to allocate serial inside tpc_finish,
# removing the requirement to serialise second commit phase (tpc_vote # removing the requirement to serialise second commit phase (tpc_vote
# to tpc_finish/tpc_abort). # to tpc_finish/tpc_abort).
_check(Connection.tpc_finish,
'f50ed2e5a74f584fa1ecaf1cd70a6b15', # Python 2.6
'ab9b1b8d82c40e5fffa84f7bc4ea3a8b', # Python 2.7
)
def tpc_finish(self, transaction): def tpc_finish(self, transaction):
"""Indicate confirmation that the transaction is done.""" """Indicate confirmation that the transaction is done."""
...@@ -39,6 +46,7 @@ if 1: ...@@ -39,6 +46,7 @@ if 1:
# to be able to read any updated data until we've had a chance # to be able to read any updated data until we've had a chance
# to send an invalidation message to all of the other # to send an invalidation message to all of the other
# connections! # connections!
# <patch>
serial = self._storage.tpc_finish(transaction, callback) serial = self._storage.tpc_finish(transaction, callback)
if serial is not None: if serial is not None:
assert isinstance(serial, str), repr(serial) assert isinstance(serial, str), repr(serial)
...@@ -49,6 +57,7 @@ if 1: ...@@ -49,6 +57,7 @@ if 1:
if obj is not None and obj._p_changed is not None: if obj is not None and obj._p_changed is not None:
obj._p_changed = 0 obj._p_changed = 0
obj._p_serial = serial obj._p_serial = serial
# </patch>
self._tpc_cleanup() self._tpc_cleanup()
Connection.tpc_finish = tpc_finish Connection.tpc_finish = tpc_finish
...@@ -62,6 +71,11 @@ if 1: ...@@ -62,6 +71,11 @@ if 1:
# so this should not be done in afterCompletion(), and anyway, we don't # so this should not be done in afterCompletion(), and anyway, we don't
# know any legitimate use of DB access outside a transaction. # know any legitimate use of DB access outside a transaction.
_check(Connection.afterCompletion,
'70dfc3df8a455d9f663dec619c607eb5', # Python 2.6
'cd3a080b80fd957190ff3bb867149448', # Python 2.7
)
def afterCompletion(self, *ignored): def afterCompletion(self, *ignored):
self._readCurrent.clear() self._readCurrent.clear()
# PATCH: do not call sync() # PATCH: do not call sync()
......
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