Capture port by value to prevent dangling reference.

This commit is contained in:
Christopher Kohlhoff 2019-02-28 10:33:48 +11:00
parent 2ee7a65253
commit 30e38527a4

View File

@ -204,7 +204,10 @@ int main(int argc, char* argv[])
{
unsigned short port = std::atoi(argv[i]);
co_spawn(io_context,
[&]{ return listener(tcp::acceptor(io_context, {tcp::v4(), port})); },
[&io_context, port]
{
return listener(tcp::acceptor(io_context, {tcp::v4(), port}));
},
detached);
}