diff options
author | Yonit Halperin <yhalperi@redhat.com> | 2009-10-16 00:21:43 +0200 |
---|---|---|
committer | Yaniv Kamay <ykamay@redhat.com> | 2009-10-18 17:42:37 +0200 |
commit | ef213c66c19d265140e9a55519b174d34ff1f16b (patch) | |
tree | 0a8e58217f5757881d4d4798d1316dbb3809f37a /client/red_channel.cpp | |
parent | 308e4545cbf8d26d5d47ad6ab9f2c6e6e6648003 (diff) | |
download | spice-ef213c66c19d265140e9a55519b174d34ff1f16b.tar.gz spice-ef213c66c19d265140e9a55519b174d34ff1f16b.tar.xz spice-ef213c66c19d265140e9a55519b174d34ff1f16b.zip |
tunnel
Diffstat (limited to 'client/red_channel.cpp')
-rw-r--r-- | client/red_channel.cpp | 38 |
1 files changed, 20 insertions, 18 deletions
diff --git a/client/red_channel.cpp b/client/red_channel.cpp index 4c6f1f8f..a82d9f77 100644 --- a/client/red_channel.cpp +++ b/client/red_channel.cpp @@ -133,7 +133,7 @@ void RedChannelBase::link(uint32_t connection_id, const std::string& password) */ if (RSA_public_encrypt(password.length() + 1, (unsigned char *)password.c_str(), (uint8_t *)bufEncrypted.get(), - rsa, RSA_PKCS1_OAEP_PADDING) > 0 ) { + rsa, RSA_PKCS1_OAEP_PADDING) > 0) { send((uint8_t*)bufEncrypted.get(), nRSASize); } else { THROW("could not encrypt password"); @@ -425,8 +425,10 @@ void RedChannel::run() _outgoing_message = NULL; } _incomming_header_pos = 0; - delete _incomming_message; - _incomming_message = NULL; + if (_incomming_message) { + _incomming_message->unref(); + _incomming_message = NULL; + } case DISCONNECT_ACTION: close(); on_disconnect(); @@ -525,19 +527,19 @@ void RedChannel::recive_messages() _incomming_header_pos = n; return; } - std::auto_ptr<CompundInMessage> message(new CompundInMessage(_incomming_header.serial, - _incomming_header.type, - _incomming_header.size, - _incomming_header.sub_list)); - n = RedPeer::recive(message->data(), message->compund_size()); - if (n != message->compund_size()) { + AutoRef<CompundInMessage> message(new CompundInMessage(_incomming_header.serial, + _incomming_header.type, + _incomming_header.size, + _incomming_header.sub_list)); + n = RedPeer::recive((*message)->data(), (*message)->compund_size()); + if (n != (*message)->compund_size()) { _incomming_message = message.release(); _incomming_message_pos = n; return; } on_message_recived(); - _message_handler->handle_message(*message.get()); - on_message_complition(message->serial()); + _message_handler->handle_message(*(*message)); + on_message_complition((*message)->serial()); } } @@ -577,11 +579,11 @@ void RedChannel::on_event() if (_incomming_message_pos != _incomming_message->compund_size()) { return; } - std::auto_ptr<CompundInMessage> message(_incomming_message); + AutoRef<CompundInMessage> message(_incomming_message); _incomming_message = NULL; on_message_recived(); - _message_handler->handle_message(*message.get()); - on_message_complition(message->serial()); + _message_handler->handle_message(*(*message)); + on_message_complition((*message)->serial()); } recive_messages(); } @@ -616,18 +618,18 @@ void RedChannel::handle_migrate(RedPeer::InMessage* message) if (migrate->flags & RED_MIGRATE_NEED_FLUSH) { send_migrate_flush_mark(); } - std::auto_ptr<RedPeer::CompundInMessage> data_message; + AutoRef<CompundInMessage> data_message; if (migrate->flags & RED_MIGRATE_NEED_DATA_TRANSFER) { data_message.reset(recive()); } _client.migrate_channel(*this); if (migrate->flags & RED_MIGRATE_NEED_DATA_TRANSFER) { - if (data_message->type() != RED_MIGRATE_DATA) { + if ((*data_message)->type() != RED_MIGRATE_DATA) { THROW("expect RED_MIGRATE_DATA"); } std::auto_ptr<RedPeer::OutMessage> message(new RedPeer::OutMessage(REDC_MIGRATE_DATA, - data_message->size())); - memcpy(message->data(), data_message->data(), data_message->size()); + (*data_message)->size())); + memcpy(message->data(), (*data_message)->data(), (*data_message)->size()); send(*message); } _loop.add_socket(*this); |