summaryrefslogtreecommitdiffstats
path: root/ingen
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2020-02-26 21:13:44 +0100
committerDavid Robillard <d@drobilla.net>2020-02-26 21:13:44 +0100
commite8df60dc3647c9deac999a7d3ccf73354ab939c4 (patch)
treefdf2e4bc4c8c0179b5466174000264fcbe52ee31 /ingen
parent96840d3fc46ec6531a3c5b53eee1c0713723f9a7 (diff)
downloadingen-e8df60dc3647c9deac999a7d3ccf73354ab939c4.tar.gz
ingen-e8df60dc3647c9deac999a7d3ccf73354ab939c4.tar.bz2
ingen-e8df60dc3647c9deac999a7d3ccf73354ab939c4.zip
Set up serd to read directly from socket without a FILE intermediary
This was problematic because using fdopen() conflicts with poll(). If the FILE ends up reading more than is actually processed by serd, then poll will not fire because the socket file descriptor has been fully read, even though there is pending input in the FILE object (which is buffered). Avoid this by using a custom read function and calling recv() directly. In retrospect, this was stupid, but it seemed convenient to be able to use the handy built-in support for reading from a FILE in serd. Now, the client and server are using send() and recv() directly on the socket, as things should be. I am not sure if MSG_WAITALL is the best idea here, or if it's really important at all, but it seems like a good idea.
Diffstat (limited to 'ingen')
-rw-r--r--ingen/SocketReader.hpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/ingen/SocketReader.hpp b/ingen/SocketReader.hpp
index 3c3c5f3c..22a0f4aa 100644
--- a/ingen/SocketReader.hpp
+++ b/ingen/SocketReader.hpp
@@ -45,6 +45,12 @@ protected:
virtual void on_hangup() {}
private:
+ /// Serd source function for reading from socket
+ static size_t c_recv(void* buf, size_t size, size_t nmemb, void* stream);
+
+ /// Serd error function for getting socket error status
+ static int c_err(void* stream);
+
void run();
static SerdStatus set_base_uri(SocketReader* iface,
@@ -69,6 +75,7 @@ private:
SordInserter* _inserter;
SordNode* _msg_node;
SPtr<Raul::Socket> _socket;
+ int _socket_error;
bool _exit_flag;
std::thread _thread;
};