[RFC PATCH spice-streaming-agent 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 | 18 ++++++++++++++++--
 1 file changed, 16 insertions(+), 2 deletions(-)

diff --git a/src/spice-streaming-agent.cpp b/src/spice-streaming-agent.cpp
index b88225f..73baa48 100644
--- a/src/spice-streaming-agent.cpp
+++ b/src/spice-streaming-agent.cpp
@@ -130,8 +130,22 @@ 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");
+    const size_t MSG_SIZE = 256;
+
+    // TODO the message should have an upper size limit defined somewhere?
+    if (len >= MSG_SIZE) {
+        throw std::runtime_error("NotifyError message size " + std::to_string(len) +
+                                 " is too long (longer than " + std::to_string(MSG_SIZE) + ")");
+    }
+
+    uint8_t msg[MSG_SIZE];
+    msg[len] = '\0'; // make sure to terminate the string - TODO is there a better way?
+
+    read_message(msg, len);
+    StreamMsgNotifyError *error_msg = (StreamMsgNotifyError*) msg;
+
+    syslog(LOG_ERR, "Received NotifyError message from the client: %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]