client: fix Op early destruction
Errors resulting in early Op destruction would erroneously be escalated to "Not in running evbase worker" exceptions. Something has already gone wrong, but this would mask the root cause.
This commit is contained in:
1 parent
007ba4e000
commit
97407cd11e
5 files changed
+21
-4
No files matched your search
@@ -21,7 +21,7 @@ Discovery::Discovery(const std::shared_ptr<ContextImpl> &context, const std::str
|
||||
{}
|
||||
|
||||
Discovery::~Discovery() {
|
||||
if(loop.assertInRunningLoop())
|
||||
if(onWorker && loop.assertInRunningLoop())
|
||||
_cancel(true);
|
||||
}
|
||||
|
||||
@@ -81,6 +81,8 @@ std::shared_ptr<Operation> DiscoverBuilder::exec()
|
||||
// setup timer to send discovery
|
||||
|
||||
context->tcp_loop.dispatch([op, context, ping]() {
|
||||
// on worker
|
||||
op->onWorker = true;
|
||||
|
||||
if(context->state!=ContextImpl::Running)
|
||||
throw std::logic_error("Context close()d");
|
||||
|
||||
+2
-1
@@ -138,7 +138,7 @@ struct GPROp : public OperationBase
|
||||
:OperationBase (op, loop, name)
|
||||
{}
|
||||
~GPROp() {
|
||||
if(loop.assertInRunningLoop())
|
||||
if(onWorker && loop.assertInRunningLoop())
|
||||
_cancel(true);
|
||||
}
|
||||
|
||||
@@ -605,6 +605,7 @@ std::shared_ptr<Operation> gpr_setup(const std::shared_ptr<ContextImpl>& context
|
||||
|
||||
context->tcp_loop.dispatch([internal, context, name, server]() {
|
||||
// on worker
|
||||
internal->onWorker = true;
|
||||
|
||||
try {
|
||||
internal->chan = Channel::build(context, name, server);
|
||||
|
||||
@@ -50,6 +50,8 @@ struct OperationBase : public Operation
|
||||
uint32_t ioid = 0;
|
||||
Value result;
|
||||
bool done = false;
|
||||
// state of handoff from user thread to worker
|
||||
bool onWorker = false;
|
||||
std::shared_ptr<ResultWaiter> waiter;
|
||||
|
||||
OperationBase(operation_t op, const evbase& loop, const std::string& name);
|
||||
|
||||
+2
-1
@@ -84,7 +84,7 @@ struct SubscriptionImpl final : public OperationBase, public Subscription
|
||||
event_new(loop.base, -1, EV_TIMEOUT, &tickAckS, this))
|
||||
{}
|
||||
virtual ~SubscriptionImpl() {
|
||||
if(loop.assertInRunningLoop())
|
||||
if(onWorker && loop.assertInRunningLoop())
|
||||
_cancel(true);
|
||||
}
|
||||
|
||||
@@ -830,6 +830,7 @@ std::shared_ptr<Subscription> MonitorBuilder::exec()
|
||||
auto server(std::move(_server));
|
||||
context->tcp_loop.dispatch([op, context, server]() {
|
||||
// on worker
|
||||
op->onWorker = true;
|
||||
|
||||
try {
|
||||
op->chan = Channel::build(context, op->channelName, server);
|
||||
|
||||
+12
-1
@@ -25,6 +25,16 @@
|
||||
namespace {
|
||||
using namespace pvxs;
|
||||
|
||||
void testEmptyName() {
|
||||
client::Config conf;
|
||||
conf.autoAddrList = false;
|
||||
auto ctx(conf.build());
|
||||
testThrowsMatch<std::logic_error>("Empty channel name",
|
||||
[&](){
|
||||
ctx.get("").exec();
|
||||
});
|
||||
}
|
||||
|
||||
struct Tester {
|
||||
Value initial;
|
||||
server::SharedPV mbox;
|
||||
@@ -592,10 +602,11 @@ void testServerClose()
|
||||
|
||||
MAIN(testget)
|
||||
{
|
||||
testPlan(67);
|
||||
testPlan(68);
|
||||
testSetup();
|
||||
logger_config_env();
|
||||
const bool canIPv6 = pvxs::impl::evsocket::canIPv6;
|
||||
testEmptyName();
|
||||
Tester().testConnector();
|
||||
Tester().testWaiter();
|
||||
Tester(AF_INET).loopback();
|
||||
|
||||
Reference in new issue
Block a user