router::make_endpt_writer_callback seems to be keeping a dangling pointer to this.
|
return [this]<typename R>(const auto& req, R&& resp, const auto& conn) { |
When I create a routing_context and then std::move and pass it to malloy::server::start, the router that lives in the moved-to routing_context is a different instance than when I created the routes in. The endpoint_http_regex objects created in the old router are moved, but the endpoint_http_regex::writer object:
|
ep->writer = make_endpt_writer_callback(); |
is still refering to an old router, and crashes when a request comes in.
For reference, here is how I am adding routes and starting the server:
malloy::server::routing_context ctx{m_cfg};
setup_routes(ctx.router());
m_session = std::make_unique<malloy::server::routing_context::session>(malloy::server::start(std::move(ctx)));
m_thread = std::jthread{[&session=*m_session]
{
session.run();
}};
Is this how it is supposed to be used?
router::make_endpt_writer_callbackseems to be keeping a dangling pointer tothis.malloy/lib/malloy/server/routing/router.hpp
Line 111 in 121a814
When I create a
routing_contextand thenstd::moveand pass it tomalloy::server::start, therouterthat lives in the moved-torouting_contextis a different instance than when I created the routes in. Theendpoint_http_regexobjects created in the old router are moved, but theendpoint_http_regex::writerobject:malloy/lib/malloy/server/routing/router.hpp
Line 661 in 121a814
is still refering to an old
router, and crashes when a request comes in.For reference, here is how I am adding routes and starting the server:
malloy::server::routing_context ctx{m_cfg}; setup_routes(ctx.router()); m_session = std::make_unique<malloy::server::routing_context::session>(malloy::server::start(std::move(ctx))); m_thread = std::jthread{[&session=*m_session] { session.run(); }};Is this how it is supposed to be used?