diff options
Diffstat (limited to 'src/SocketReader.cpp')
-rw-r--r-- | src/SocketReader.cpp | 51 |
1 files changed, 26 insertions, 25 deletions
diff --git a/src/SocketReader.cpp b/src/SocketReader.cpp index e643b9a2..5499fb66 100644 --- a/src/SocketReader.cpp +++ b/src/SocketReader.cpp @@ -14,16 +14,18 @@ along with Ingen. If not, see <http://www.gnu.org/licenses/>. */ -#include "ingen/SocketReader.hpp" - -#include "ingen/AtomForge.hpp" -#include "ingen/AtomReader.hpp" -#include "ingen/Log.hpp" -#include "ingen/URIMap.hpp" -#include "ingen/World.hpp" -#include "lv2/urid/urid.h" -#include "raul/Socket.hpp" -#include "sord/sordmm.hpp" +#include <ingen/SocketReader.hpp> + +#include <ingen/AtomForge.hpp> +#include <ingen/AtomReader.hpp> +#include <ingen/Log.hpp> +#include <ingen/URIMap.hpp> +#include <ingen/World.hpp> +#include <lv2/urid/urid.h> +#include <raul/Socket.hpp> +#include <serd/serd.h> +#include <sord/sord.h> +#include <sord/sordmm.hpp> #include <cerrno> #include <cstdint> @@ -41,12 +43,7 @@ SocketReader::SocketReader(ingen::World& world, std::shared_ptr<raul::Socket> sock) : _world(world) , _iface(iface) - , _env() - , _inserter(nullptr) - , _msg_node(nullptr) , _socket(std::move(sock)) - , _socket_error(0) - , _exit_flag(false) , _thread(&SocketReader::run, this) {} @@ -127,7 +124,7 @@ SocketReader::run() AtomForge forge(map); { // Lock RDF world - std::lock_guard<std::mutex> lock(_world.rdf_mutex()); + const std::lock_guard<std::mutex> lock{_world.rdf_mutex()}; // Use <ingen:/> as base URI, so relative URIs are like bundle paths base_uri = sord_new_uri(world->c_obj(), @@ -170,19 +167,23 @@ SocketReader::run() const int ret = poll(&pfd, 1, -1); if (ret == -1 || (pfd.revents & (POLLERR|POLLHUP|POLLNVAL))) { on_hangup(); - break; // Hangup - } else if (!ret) { - continue; // No data, shouldn't happen + break; // Hangup + } + + if (!ret) { + continue; // No data, shouldn't happen } // Lock RDF world - std::lock_guard<std::mutex> lock(_world.rdf_mutex()); + const std::lock_guard<std::mutex> lock{_world.rdf_mutex()}; // Read until the next '.' - SerdStatus st = serd_reader_read_chunk(reader); + const SerdStatus st = serd_reader_read_chunk(reader); if (st == SERD_FAILURE || !_msg_node) { - continue; // Read nothing, e.g. just whitespace - } else if (st) { + continue; // Read nothing, e.g. just whitespace + } + + if (st) { _world.log().error("Read error: %1%\n", serd_strerror(st)); continue; } @@ -200,7 +201,7 @@ SocketReader::run() } // Lock RDF world - std::lock_guard<std::mutex> lock(_world.rdf_mutex()); + const std::lock_guard<std::mutex> lock{_world.rdf_mutex()}; // Destroy everything sord_inserter_free(_inserter); @@ -210,4 +211,4 @@ SocketReader::run() _socket.reset(); } -} // namespace ingen +} // namespace ingen |