[PATCH v2 20/24] Throw an exception in case we can't write a complete packet.

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

 



From: Christophe de Dinechin <dinechin@xxxxxxxxxx>

Signed-off-by: Christophe de Dinechin <dinechin@xxxxxxxxxx>
---
 src/spice-streaming-agent.cpp | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/src/spice-streaming-agent.cpp b/src/spice-streaming-agent.cpp
index 4e3a21c..61a73ce 100644
--- a/src/spice-streaming-agent.cpp
+++ b/src/spice-streaming-agent.cpp
@@ -62,6 +62,13 @@ class Stream
     typedef std::set<SpiceVideoCodecType> codecs_t;
 
 public:
+    class WriteError : public std::runtime_error
+    {
+    public:
+        WriteError(const char *msg): runtime_error(msg) {}
+    };
+
+public:
     Stream(const char *name)
         : codecs()
     {
@@ -92,8 +99,10 @@ public:
         size_t expected = message.size(payload...);
         size_t written = message.write(*this, payload...);
         bool result = written == expected;
-        if (!result)
-            syslog(LOG_WARNING, "sent only %zu bytes out of %zu", written, expected);
+        if (!result) {
+            syslog(LOG_ERR, "sent only %zu bytes out of %zu", written, expected);
+            throw WriteError("Unable to write complete packet");
+        }
         return result;
     }
 
-- 
2.13.5 (Apple Git-94)

_______________________________________________
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]