diff options
author | AGaliuzov <AGaliuzov@luxoft.com> | 2015-08-31 01:51:11 +0300 |
---|---|---|
committer | AGaliuzov <AGaliuzov@luxoft.com> | 2015-08-31 01:51:11 +0300 |
commit | 02cc75ed4d505cae8548127e9477338ca24db6ea (patch) | |
tree | 666ecab7f7d818829e4750836de5f15324d8c609 /src/components/protocol_handler/src | |
parent | 603a93e2e660749788a5f71b7dfaf4ae4c59c936 (diff) | |
parent | a79769d21972f59277b7025573ebaa00e61b9778 (diff) | |
download | sdl_core-02cc75ed4d505cae8548127e9477338ca24db6ea.tar.gz |
Merge pull request #203 from LuxoftSDL/develop
Sync up branches after release merging
Diffstat (limited to 'src/components/protocol_handler/src')
-rw-r--r-- | src/components/protocol_handler/src/protocol_handler_impl.cc | 34 |
1 files changed, 20 insertions, 14 deletions
diff --git a/src/components/protocol_handler/src/protocol_handler_impl.cc b/src/components/protocol_handler/src/protocol_handler_impl.cc index 9ae8128f66..5e69b1cdfd 100644 --- a/src/components/protocol_handler/src/protocol_handler_impl.cc +++ b/src/components/protocol_handler/src/protocol_handler_impl.cc @@ -37,6 +37,7 @@ #include "connection_handler/connection_handler_impl.h" #include "config_profile/profile.h" #include "utils/byte_order.h" +#include "protocol/common.h" #ifdef ENABLE_SECURITY #include "security_manager/ssl_context.h" @@ -340,7 +341,6 @@ void ProtocolHandlerImpl::SendMessageToMobileApp(const RawMessagePtr message, return; } - if (!session_observer_) { LOG4CXX_ERROR( logger_, @@ -358,29 +358,35 @@ void ProtocolHandlerImpl::SendMessageToMobileApp(const RawMessagePtr message, metric_observer_->StartMessageProcess(message_id, start_time); } #endif // TIME_TESTER - - const uint32_t header_size = (PROTOCOL_VERSION_1 == message->protocol_version()) - ? PROTOCOL_HEADER_V1_SIZE : PROTOCOL_HEADER_V2_SIZE; - uint32_t max_frame_size = MAXIMUM_FRAME_DATA_V2_SIZE - header_size; + const size_t max_frame_size = + profile::Profile::instance()->maximum_payload_size(); + size_t frame_size = MAXIMUM_FRAME_DATA_V2_SIZE; + switch (message->protocol_version()) { + case PROTOCOL_VERSION_3: + case PROTOCOL_VERSION_4: + frame_size = max_frame_size > MAXIMUM_FRAME_DATA_V2_SIZE ? + max_frame_size : MAXIMUM_FRAME_DATA_V2_SIZE; + break; + default: + break; + } #ifdef ENABLE_SECURITY const security_manager::SSLContext *ssl_context = session_observer_-> GetSSLContext(message->connection_key(), message->service_type()); if (ssl_context && ssl_context->IsInitCompleted()) { - const size_t max_block_size = ssl_context->get_max_block_size(max_frame_size); + const size_t max_block_size = ssl_context->get_max_block_size(frame_size); DCHECK(max_block_size > 0); if (max_block_size > 0) { - max_frame_size = max_block_size; - LOG4CXX_DEBUG(logger_, "Security set new optimal packet size " << max_frame_size); + frame_size = max_block_size; + LOG4CXX_DEBUG(logger_, "Security set new optimal packet size " << frame_size); } else { LOG4CXX_ERROR(logger_, "Security could not return max block size, use the origin one"); } } - LOG4CXX_DEBUG(logger_, "Optimal packet size is " << max_frame_size); + LOG4CXX_DEBUG(logger_, "Optimal packet size is " << frame_size); #endif // ENABLE_SECURITY - DCHECK(MAXIMUM_FRAME_DATA_V2_SIZE > max_frame_size); - - if (message->data_size() <= max_frame_size) { + if (message->data_size() <= frame_size) { RESULT_CODE result = SendSingleFrameMessage(connection_handle, sessionID, message->protocol_version(), message->service_type(), @@ -394,14 +400,14 @@ void ProtocolHandlerImpl::SendMessageToMobileApp(const RawMessagePtr message, } else { LOG4CXX_DEBUG( logger_, - "Message will be sent in multiple frames; max frame size is " << max_frame_size); + "Message will be sent in multiple frames; max frame size is " << frame_size); RESULT_CODE result = SendMultiFrameMessage(connection_handle, sessionID, message->protocol_version(), message->service_type(), message->data_size(), message->data(), - max_frame_size, final_message); + frame_size, final_message); if (result != RESULT_OK) { LOG4CXX_ERROR(logger_, "ProtocolHandler failed to send multiframe messages."); |