diff options
author | David Robillard <d@drobilla.net> | 2019-01-09 19:43:44 +0100 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2019-01-09 19:43:44 +0100 |
commit | dc0548bc7b9b833e1c64440d943dc235882f62cf (patch) | |
tree | e605b0ca7bb23b44d8eec45cf334a90394c2847c | |
parent | 26e33ec7a3dd9f960c3bd44e065106b099dfa8b6 (diff) | |
download | ingen-dc0548bc7b9b833e1c64440d943dc235882f62cf.tar.gz ingen-dc0548bc7b9b833e1c64440d943dc235882f62cf.tar.bz2 ingen-dc0548bc7b9b833e1c64440d943dc235882f62cf.zip |
Fix SocketWriter bundle delimiters
In particular, this fixes ingenish. The old solution here was broken by
changing to a single message() function since bundle_end() was no longer
virtual.
-rw-r--r-- | ingen/SocketWriter.hpp | 5 | ||||
-rw-r--r-- | src/SocketWriter.cpp | 25 |
2 files changed, 17 insertions, 13 deletions
diff --git a/ingen/SocketWriter.hpp b/ingen/SocketWriter.hpp index 4d7247da..c4ed7b51 100644 --- a/ingen/SocketWriter.hpp +++ b/ingen/SocketWriter.hpp @@ -43,10 +43,9 @@ public: const URI& uri, SPtr<Raul::Socket> sock); - size_t text_sink(const void* buf, size_t len) override; + void message(const Message& message) override; - /** Override of bundle_end to terminate bundles in the stream. */ - void bundle_end(); + size_t text_sink(const void* buf, size_t len) override; protected: SPtr<Raul::Socket> _socket; diff --git a/src/SocketWriter.cpp b/src/SocketWriter.cpp index dcba5799..56ed8d55 100644 --- a/src/SocketWriter.cpp +++ b/src/SocketWriter.cpp @@ -18,6 +18,8 @@ #include <sys/types.h> #include <sys/socket.h> +#include <boost/variant/get.hpp> + #include "ingen/SocketWriter.hpp" #include "raul/Socket.hpp" @@ -35,6 +37,19 @@ SocketWriter::SocketWriter(URIMap& map, , _socket(std::move(sock)) {} +void +SocketWriter::message(const Message& message) +{ + TurtleWriter::message(message); + if (boost::get<BundleEnd>(&message)) { + fprintf(stderr, "BUNDLE END!\n"); + + // Send a null byte to indicate end of bundle + const char end[] = { 0 }; + send(_socket->fd(), end, 1, MSG_NOSIGNAL); + } +} + size_t SocketWriter::text_sink(const void* buf, size_t len) { @@ -45,14 +60,4 @@ SocketWriter::text_sink(const void* buf, size_t len) return ret; } -void -SocketWriter::bundle_end() -{ - TurtleWriter::bundle_end(); - - // Send a null byte to indicate end of bundle - const char end[] = { 0 }; - send(_socket->fd(), end, 1, MSG_NOSIGNAL); -} - } // namespace ingen |