Skip to content
Snippets Groups Projects
Commit 168fe137 authored by Guillaume Roguez's avatar Guillaume Roguez Committed by gerrit2
Browse files

tls: remove unneeded atomic load


TlsSession state holder 'state_' is loaded twice
when we check for its modification in the TlsSession
state machine code.
std::atomic_compare_exchange_strong returns false when
'state_' is not equals to 'old_state' and in this case
'old_state' is changed for the current value of 'state_'.
So reload it right after the returns is not efficient
and may also have an unexpected corner case.

This patch re-uses the value of 'old_state' for next
processing.

Change-Id: Ia29abc0f5834caabf12f1ae528ff11b132bd603c
Reviewed-by: default avatarStepan Salenikovich <stepan.salenikovich@savoirfairelinux.com>
parent c4d7748e
Branches
Tags
No related merge requests found
......@@ -778,7 +778,7 @@ TlsSession::process()
// update state_ with taking care for external state change
if (not std::atomic_compare_exchange_strong(&state_, &old_state, new_state))
new_state = state_;
new_state = old_state;
if (old_state != new_state and callbacks_.onStateChange)
callbacks_.onStateChange(new_state);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment