diff --git a/src/security/tls_session.cpp b/src/security/tls_session.cpp
index 75976f0bf9dae24d3e3b3714c4261ab527a17638..09641e8e9bbe020f3c82dc8479a34e9010511580 100644
--- a/src/security/tls_session.cpp
+++ b/src/security/tls_session.cpp
@@ -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);