From 65c40615d35b4deb565ec7fb4d7b3fd4cb2b202e Mon Sep 17 00:00:00 2001 From: Martin Haefner Date: Wed, 13 Jun 2018 09:42:16 +0200 Subject: [PATCH] Fix strict ordering of sequence number in requests sent out --- src/client/binary_client.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/client/binary_client.cpp b/src/client/binary_client.cpp index 274f632b..9ee05b69 100644 --- a/src/client/binary_client.cpp +++ b/src/client/binary_client.cpp @@ -836,6 +836,8 @@ class BinaryClient const SymmetricAlgorithmHeader algorithmHeader = CreateAlgorithmHeader(); hdr.AddSize(RawSize(algorithmHeader)); + std::unique_lock send_lock(send_mutex); + const SequenceHeader sequence = CreateSequenceHeader(); hdr.AddSize(RawSize(sequence)); @@ -868,7 +870,7 @@ class BinaryClient std::unique_lock lock(Mutex); Callbacks.insert(std::make_pair(request.Header.RequestHandle, responseCallback)); lock.unlock(); - + LOG_DEBUG(Logger, "binary_client | send: id: {} handle: {}, UtcTime: {}", ToString(request.TypeId, true), request.Header.RequestHandle, request.Header.UtcTime); Send(request); @@ -903,11 +905,12 @@ class BinaryClient const SymmetricAlgorithmHeader algorithmHeader = CreateAlgorithmHeader(); hdr.AddSize(RawSize(algorithmHeader)); + std::unique_lock send_lock(send_mutex); + const SequenceHeader sequence = CreateSequenceHeader(); hdr.AddSize(RawSize(sequence)); hdr.AddSize(RawSize(request)); - std::unique_lock send_lock(send_mutex); Stream << hdr << algorithmHeader << sequence << request << flush; } @@ -1124,6 +1127,8 @@ void BinaryClient::Send(OpenSecureChannelRequest reque hdr.AddSize(RawSize(algorithmHeader)); hdr.AddSize(RawSize(request)); + std::unique_lock send_lock(send_mutex); + const SequenceHeader sequence = CreateSequenceHeader(); hdr.AddSize(RawSize(sequence)); Stream << hdr << algorithmHeader << sequence << request << flush;