[Spice-devel] [PATCH spice 08/10] client/red_channel: support SpiceDataHeaderNoSub

Yonit Halperin yhalperi at redhat.com
Wed Dec 28 09:15:17 PST 2011


---
 client/red_channel.cpp |   12 ++++++++----
 1 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/client/red_channel.cpp b/client/red_channel.cpp
index e8c058c..1f3312f 100644
--- a/client/red_channel.cpp
+++ b/client/red_channel.cpp
@@ -215,6 +215,8 @@ void RedChannelBase::link(uint32_t connection_id, const std::string& password,
                                 SPICEC_ERROR_CODE_CONNECT_FAILED : SPICEC_ERROR_CODE_CONNECT_FAILED;
         THROW_ERR(error_code, "connect failed %u", link_res);
     }
+
+    set_is_header_with_sub_list(!test_common_capability(SPICE_COMMON_CAP_HEADER_NO_SUB));
 }
 
 void RedChannelBase::connect(const ConnectionOptions& options, uint32_t connection_id,
@@ -353,6 +355,8 @@ RedChannel::RedChannel(RedClient& client, uint8_t type, uint8_t id,
 {
     _loop.add_trigger(_send_trigger);
     _loop.add_trigger(_abort_trigger);
+    _incomming_header.sub_list = 0;
+    set_common_capability(SPICE_COMMON_CAP_HEADER_NO_SUB);
 }
 
 RedChannel::~RedChannel()
@@ -691,8 +695,8 @@ void RedChannel::on_message_complition(uint64_t serial)
 void RedChannel::receive_messages()
 {
     for (;;) {
-        uint32_t n = RedPeer::receive((uint8_t*)&_incomming_header, sizeof(SpiceDataHeader));
-        if (n != sizeof(SpiceDataHeader)) {
+        uint32_t n = RedPeer::receive((uint8_t*)&_incomming_header, _header_size);
+        if (n != _header_size) {
             _incomming_header_pos = n;
             return;
         }
@@ -728,8 +732,8 @@ void RedChannel::on_event()
     if (_incomming_header_pos) {
         _incomming_header_pos += RedPeer::receive(((uint8_t*)&_incomming_header) +
                                                  _incomming_header_pos,
-                                                 sizeof(SpiceDataHeader) - _incomming_header_pos);
-        if (_incomming_header_pos != sizeof(SpiceDataHeader)) {
+                                                 _header_size - _incomming_header_pos);
+        if (_incomming_header_pos != _header_size) {
             return;
         }
         _incomming_header_pos = 0;
-- 
1.7.6.4



More information about the Spice-devel mailing list