more onInit() error handling

This commit is contained in:
Michael Davidsaver
2021-06-27 10:17:13 -07:00
parent db32f05ce1
commit 9d128b2f8a
2 changed files with 15 additions and 4 deletions
+3
View File
@@ -514,8 +514,11 @@ void Connection::handle_GPR(pva_app_msg_t cmd)
if(gpr->onInit)
gpr->onInit(data);
} catch(std::exception& e) {
log_err_printf(setup, "Server %s op%02x \"%s\" onInit() error: %s\n",
peerName.c_str(), cmd, gpr->chan->name.c_str(), e.what());
gpr->result = Result(std::current_exception());
gpr->state = GPROp::Done;
gpr->notify();
}
if(gpr->state==GPROp::Idle && gpr->autoExec)
+12 -4
View File
@@ -467,12 +467,20 @@ void Connection::handle_MONITOR()
peerName.c_str(),
mon->chan->name.c_str());
if(mon->onInit)
mon->onInit(*mon, info->prototype);
mon->state = SubscriptionImpl::Idle;
if(mon->autostart)
try {
if(mon->onInit)
mon->onInit(*mon, info->prototype);
}catch(std::exception& e){
mon->state = SubscriptionImpl::Done;
update.exc = std::current_exception();
log_debug_printf(io, "Server %s channel %s monitor Create error: %s\n",
peerName.c_str(),
mon->chan->name.c_str(), e.what());
}
if(mon->autostart && mon->state == SubscriptionImpl::Idle)
mon->resume();
} else if(data) { // Idle or Running