[Spice-devel] [PATCH spice-streaming-agent v2 1/9] Use read_all() to read headers of received messages
Lukáš Hrázký
lhrazky at redhat.com
Wed May 16 16:25:59 UTC 2018
Unifies the reading from the virtio port, read_all() supports signals
and partial reads.
Signed-off-by: Lukáš Hrázký <lhrazky at redhat.com>
---
src/spice-streaming-agent.cpp | 9 +++------
1 file changed, 3 insertions(+), 6 deletions(-)
diff --git a/src/spice-streaming-agent.cpp b/src/spice-streaming-agent.cpp
index 8b3f833..5dd41a9 100644
--- a/src/spice-streaming-agent.cpp
+++ b/src/spice-streaming-agent.cpp
@@ -166,14 +166,11 @@ static void handle_stream_error(size_t len)
static void read_command_from_device(void)
{
StreamDevHeader hdr;
- int n;
std::lock_guard<std::mutex> stream_guard(stream_mtx);
- n = read(streamfd, &hdr, sizeof(hdr));
- if (n != sizeof(hdr)) {
- throw std::runtime_error("read command from device FAILED -- read " + std::to_string(n) +
- " expected " + std::to_string(sizeof(hdr)));
- }
+
+ read_all(&hdr, sizeof(hdr));
+
if (hdr.protocol_version != STREAM_DEVICE_PROTOCOL) {
throw std::runtime_error("BAD VERSION " + std::to_string(hdr.protocol_version) +
" (expected is " + std::to_string(STREAM_DEVICE_PROTOCOL) + ")");
--
2.16.2
More information about the Spice-devel
mailing list