[PATCH spice-streaming-agent v2 2/2] Implement handling of error messages from the server

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Signed-off-by: Lukáš Hrázký <lhrazky@xxxxxxxxxx>
---
 src/spice-streaming-agent.cpp | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)

diff --git a/src/spice-streaming-agent.cpp b/src/spice-streaming-agent.cpp
index 20ac1f4..ab403f9 100644
--- a/src/spice-streaming-agent.cpp
+++ b/src/spice-streaming-agent.cpp
@@ -139,8 +139,20 @@ static void handle_stream_capabilities(uint32_t len)
 
 static void handle_stream_error(uint32_t len)
 {
-    // TODO read message and use it
-    throw std::runtime_error("got an error message from server");
+    uint8_t msg[1024];
+
+    if (len >= sizeof(msg)) {
+        throw std::runtime_error("NotifyError message size " + std::to_string(len) +
+                                 " is too long (longer than " + std::to_string(sizeof(msg)) + ")");
+    }
+
+    msg[len] = '\0';
+
+    read_all(msg, len);
+    StreamMsgNotifyError *error_msg = (StreamMsgNotifyError*) msg;
+
+    syslog(LOG_ERR, "Received NotifyError message from the server: %d - %s\n",
+        error_msg->error_code, error_msg->msg);
 }
 
 static void read_command_from_device(void)
-- 
2.16.1

_______________________________________________
Spice-devel mailing list
Spice-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/spice-devel




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]     [Monitors]