diff options
Diffstat (limited to 'src/SocketReader.cpp')
-rw-r--r-- | src/SocketReader.cpp | 35 |
1 files changed, 17 insertions, 18 deletions
diff --git a/src/SocketReader.cpp b/src/SocketReader.cpp index 28ad9bbf..93677c6c 100644 --- a/src/SocketReader.cpp +++ b/src/SocketReader.cpp @@ -23,31 +23,26 @@ #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> -#include <cstdio> #include <memory> #include <mutex> #include <poll.h> #include <sys/socket.h> -#include <sys/types.h> #include <utility> namespace ingen { SocketReader::SocketReader(ingen::World& world, Interface& iface, - std::shared_ptr<Raul::Socket> sock) + 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) {} @@ -128,7 +123,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(), @@ -171,19 +166,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; } @@ -201,7 +200,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); @@ -211,4 +210,4 @@ SocketReader::run() _socket.reset(); } -} // namespace ingen +} // namespace ingen |