[Spice-devel] [PATCH spice-streaming-agent v2 2/2] Implement handling of error messages from the server
Lukáš Hrázký
lhrazky at redhat.com
Thu Feb 22 17:41:53 UTC 2018
Signed-off-by: Lukáš Hrázký <lhrazky at redhat.com>
---
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
More information about the Spice-devel
mailing list