simplify / clarify code somewhat
@@ -82,11 +82,18 @@ void cleanupReservation(ScriptData & data)
void
ScriptCommand::doneHandler(OkState result)
{
- LOG_ASSERT(_data != nullptr);
+ LOG_ASSERT(_data);
std::unique_ptr<ScriptData> dataUP = std::move(_data);
+ LOG_ASSERT(! _data);
ScriptData & data = *dataUP;
+ const char *name_p = data.name.c_str();
+ const char *spec_p = data.spec.c_str();
+ ExchangeManager &xch = data.env._exchanger;
+ RpcServerManager &rsm = data.env._rpcsrvmanager;
+
if (result.failed()) {
- LOG(warning, "failed in state %d: %s", data._state, result.errorMsg.c_str());
+ LOG(warning, "failed [%s->%s] in state %d: %s",
+ name_p, spec_p, data._state, result.errorMsg.c_str());
cleanupReservation(data);
// XXX should handle different state errors differently?
if (data.registerRequest != nullptr) {
@@ -98,22 +105,22 @@ ScriptCommand::doneHandler(OkState result)
return;
}
if (data._state == ScriptData::RDC_INIT) {
- LOG(spam, "phase wantAdd(%s,%s)", data.name.c_str(), data.spec.c_str());
+ LOG(spam, "phase wantAdd(%s,%s)", name_p, spec_p);
data._state = ScriptData::XCH_WANTADD;
- data.env._exchanger.wantAdd(std::move(dataUP));
+ xch.wantAdd(std::move(dataUP));
return;
} else if (data._state == ScriptData::XCH_WANTADD) {
- LOG(spam, "phase addManaged(%s,%s)", data.name.c_str(), data.spec.c_str());
+ LOG(spam, "phase addManaged(%s,%s)", name_p, spec_p);
data._state = ScriptData::CHK_RPCSRV;
- data.env._rpcsrvmanager.addManaged(std::move(dataUP));
+ rsm.addManaged(std::move(dataUP));
return;
} else if (data._state == ScriptData::CHK_RPCSRV) {
- LOG(spam, "phase doAdd(%s,%s)", data.name.c_str(), data.spec.c_str());
+ LOG(spam, "phase doAdd(%s,%s)", name_p, spec_p);
data._state = ScriptData::XCH_DOADD;
- data.env._exchanger.doAdd(std::move(dataUP));
+ xch.doAdd(std::move(dataUP));
return;
} else if (data._state == ScriptData::XCH_DOADD) {
- LOG(debug, "done doAdd(%s,%s)", data.name.c_str(), data.spec.c_str());
+ LOG(debug, "done doAdd(%s,%s)", name_p, spec_p);
data._state = ScriptData::RDC_INVAL;
// all OK
data.registerRequest->Return();
