[Spice-devel] [client 1/2] streaming: Send a special stream report to signal streaming errors

Francois Gouget fgouget at codeweavers.com
Thu Aug 11 11:04:09 UTC 2016


Servers that recognize this special report then stop streaming (sending 
regular screen updates instead) while older ones essentially ignore it.

Signed-off-by: Francois Gouget <fgouget at codeweavers.com>
---

This patchset is based on Victor Toso's idea [1] of using the stream 
reports to tell the server that, despite expectations, the client cannot 
handle a given stream.

You'll notice that this patch does not directly check for 
create_xxx_decoder() errors. Instead it relies on the previous patchset 
[2] deleting broken streams so that the following messages will run into 
an unknown stream.

Of course this could already happen in case of a malicious server 
sending garbage to the client. So this patchset is quite independent 
from the previous one.

I don't know what the consequences of receiving an unknown message would 
be for the server so I chose to hook into the 
display_handle_stream_activate_report() as that's where we get notified 
that the server supports the stream reports.

Maybe we should send such an error anywhere we receive a message with an 
unknown stream_id. There's really no reason for that to happen in those 
other places though, except if the server does not recognize the initial 
error stream report and continues streaming. In that case sending more 
error messages won't do any good. So sending an error in just this one 
place may make more sense.

We could also add an extra cap to identify servers that recognize this 
special type or stream report. But is it really worth it?

[1] https://lists.freedesktop.org/archives/spice-devel/2016-August/031101.html
[2] https://lists.freedesktop.org/archives/spice-devel/2016-August/031282.html


 src/channel-display.c | 24 +++++++++++++++++++++---
 1 file changed, 21 insertions(+), 3 deletions(-)

diff --git a/src/channel-display.c b/src/channel-display.c
index 709b3d2..3898f0a 100644
--- a/src/channel-display.c
+++ b/src/channel-display.c
@@ -1530,10 +1530,28 @@ static void display_handle_stream_activate_report(SpiceChannel *channel, SpiceMs
 
     g_return_if_fail(c != NULL);
     g_return_if_fail(c->streams != NULL);
-    g_return_if_fail(c->nstreams > op->stream_id);
 
-    st = c->streams[op->stream_id];
-    g_return_if_fail(st != NULL);
+    st = op->stream_id < c->nstreams ? c->streams[op->stream_id] : NULL;
+    if (st == NULL) {
+        SpiceMsgcDisplayStreamReport report;
+        SpiceMsgOut *msg;
+
+        /* Send a special stream report to indicate there is no such stream */
+        spice_printerr("notify the server that stream %u does not exist", op->stream_id);
+        report.stream_id = op->stream_id;
+        report.unique_id = op->unique_id;
+        report.start_frame_mm_time = 0;
+        report.end_frame_mm_time = 0;
+        report.num_frames = 0;
+        report.num_drops = UINT_MAX;
+        report.last_frame_delay = 0;
+        report.audio_delay = 0;
+
+        msg = spice_msg_out_new(SPICE_CHANNEL(channel), SPICE_MSGC_DISPLAY_STREAM_REPORT);
+        msg->marshallers->msgc_display_stream_report(msg->marshaller, &report);
+        spice_msg_out_send(msg);
+        return;
+    }
 
     st->report_is_active = TRUE;
     st->report_id = op->unique_id;
-- 
2.8.1


More information about the Spice-devel mailing list