Skip to content
Snippets Groups Projects
Commit 324d49ce authored by Adrien Béraud's avatar Adrien Béraud
Browse files

mxsocks: avoid copy when packing

Change-Id: I62341574acfb6a089c508cdc0a1737caad640241
parent d3cf5b99
No related branches found
No related tags found
No related merge requests found
...@@ -235,13 +235,12 @@ MultiplexedSocket::Impl::onRequest(const std::string& name, uint16_t channel) ...@@ -235,13 +235,12 @@ MultiplexedSocket::Impl::onRequest(const std::string& name, uint16_t channel)
val.channel = channel; val.channel = channel;
val.name = name; val.name = name;
val.state = accept ? ChannelRequestState::ACCEPT : ChannelRequestState::DECLINE; val.state = accept ? ChannelRequestState::ACCEPT : ChannelRequestState::DECLINE;
std::stringstream ss; msgpack::sbuffer buffer(512);
msgpack::pack(ss, val); msgpack::pack(buffer, val);
std::error_code ec; std::error_code ec;
auto toSend = ss.str();
int wr = parent_.write(CONTROL_CHANNEL, int wr = parent_.write(CONTROL_CHANNEL,
reinterpret_cast<const uint8_t*>(&toSend[0]), reinterpret_cast<const uint8_t*>(buffer.data()),
toSend.size(), buffer.size(),
ec); ec);
if (wr < 0) { if (wr < 0) {
if (ec) if (ec)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment