Commit c6868e1d authored by Guido Trotter's avatar Guido Trotter
Browse files

Fix sstore handling in Processor

- no need to keep the sstore as an object member, remove it
- don't reinitialize sstore only if self.cfg is None
    This is not an issue, as the Processor is recycled for every opcode,
    but in general we know that (a) we might need a different type of
    sstore for different opcodes and (b) initializating them is cheap
- recreate sstore when chaining opcodes
    Without this fix chaining an opcode which requires a writable sstore
    to one which doesn't would fail. This doesn't happen today, but it's
    better to fix it anyway

These changes are possible because nowadays all opcodes already require
a working cluster/configuration.

Reviewed-by: iustinp
parent d2525573
......@@ -97,7 +97,6 @@ class Processor(object):
interesting events are happening
"""
self.cfg = None
self.sstore = None
self._feedback_fn = feedback
def ExecOpCode(self, op):
......@@ -115,17 +114,18 @@ class Processor(object):
if lu_class is None:
raise errors.OpCodeUnknown("Unknown opcode")
if lu_class.REQ_WSSTORE:
sstore = ssconf.WritableSimpleStore()
else:
sstore = ssconf.SimpleStore()
if self.cfg is None:
self.cfg = config.ConfigWriter()
if lu_class.REQ_WSSTORE:
self.sstore = ssconf.WritableSimpleStore()
else:
self.sstore = ssconf.SimpleStore()
if self.cfg is not None:
write_count = self.cfg.write_count
else:
write_count = 0
lu = lu_class(self, op, self.cfg, self.sstore)
lu = lu_class(self, op, self.cfg, sstore)
lu.CheckPrereq()
hm = HooksMaster(rpc.call_hooks_runner, self, lu)
h_results = hm.RunPhase(constants.HOOKS_PHASE_PRE)
......@@ -163,11 +163,15 @@ class Processor(object):
if lu_class is None:
raise errors.OpCodeUnknown("Unknown opcode")
if lu_class.REQ_WSSTORE:
sstore = ssconf.WritableSimpleStore()
else:
sstore = ssconf.SimpleStore()
if self.cfg is None:
self.cfg = config.ConfigWriter()
self.sstore = ssconf.SimpleStore()
#do_hooks = lu_class.HPATH is not None
lu = lu_class(self, op, self.cfg, self.sstore)
lu = lu_class(self, op, self.cfg, sstore)
lu.CheckPrereq()
#if do_hooks:
# hm = HooksMaster(rpc.call_hooks_runner, self, lu)
......
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