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)
val.channel = channel;
val.name = name;
val.state = accept ? ChannelRequestState::ACCEPT : ChannelRequestState::DECLINE;
std::stringstream ss;
msgpack::pack(ss, val);
msgpack::sbuffer buffer(512);
msgpack::pack(buffer, val);
std::error_code ec;
auto toSend = ss.str();
int wr = parent_.write(CONTROL_CHANNEL,
reinterpret_cast<const uint8_t*>(&toSend[0]),
toSend.size(),
reinterpret_cast<const uint8_t*>(buffer.data()),
buffer.size(),
ec);
if (wr < 0) {
if (ec)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment