aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias P. Braendli <matthias.braendli@mpb.li>2015-04-10 16:51:40 +0200
committerMatthias P. Braendli <matthias.braendli@mpb.li>2015-06-19 10:44:03 +0200
commit8e7f5fd041f7eb5730d0810d19a5d96183e41a36 (patch)
tree42c4d99154aab0e30e3220fc40cc034f543357a6
parent93cbefeeffcba044ab95ee46307ab50ec717bf2b (diff)
downloaddabmux-8e7f5fd041f7eb5730d0810d19a5d96183e41a36.tar.gz
dabmux-8e7f5fd041f7eb5730d0810d19a5d96183e41a36.tar.bz2
dabmux-8e7f5fd041f7eb5730d0810d19a5d96183e41a36.zip
Correct usage of json parser buffers
-rw-r--r--src/ManagementServer.cpp11
1 files changed, 6 insertions, 5 deletions
diff --git a/src/ManagementServer.cpp b/src/ManagementServer.cpp
index fe1a0be..fc0a43e 100644
--- a/src/ManagementServer.cpp
+++ b/src/ManagementServer.cpp
@@ -298,7 +298,9 @@ void ManagementServer::handle_accept(
if (length > 0) {
boost::unique_lock<boost::mutex> lock(m_configmutex);
m_pt.clear();
- boost::property_tree::json_parser::read_json(jsonbuffer, m_pt);
+
+ std::istream json_stream(&jsonbuffer);
+ boost::property_tree::json_parser::read_json(json_stream, m_pt);
}
else if (length == 0) {
etiLog.level(warn) <<
@@ -319,14 +321,13 @@ void ManagementServer::handle_accept(
std::stringstream ss;
boost::property_tree::json_parser::write_json(ss, m_pt);
- boost::asio::write(*socket, ss,
+ boost::asio::write(*socket, boost::asio::buffer(ss.str()),
boost::asio::transfer_all(),
ignored_error);
}
else {
- std::stringstream ss;
- ss << "Invalid command\n";
- boost::asio::write(*socket, ss,
+ std::string invcmd("Invalid command\n");
+ boost::asio::write(*socket, boost::asio::buffer(invcmd),
boost::asio::transfer_all(),
ignored_error);
}