File tree 3 files changed +24
-0
lines changed
3 files changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -85,6 +85,10 @@ int Authenticator::onAuthenticationRequest(
85
85
response.status ().code () = 0 ;
86
86
response.lifetimeMs () = 10 * 60 * 1000 ;
87
87
88
+ context->testAndSwapState (
89
+ mqbnet::AuthenticationContext::State::e_AUTHENTICATING,
90
+ mqbnet::AuthenticationContext::State::e_AUTHENTICATED);
91
+
88
92
int rc = sendAuthenticationMessage (errorDescription,
89
93
authenticationResponse,
90
94
context);
Original file line number Diff line number Diff line change @@ -30,10 +30,12 @@ namespace mqbnet {
30
30
AuthenticationContext::AuthenticationContext (
31
31
InitialConnectionContext* initialConnectionContext,
32
32
bool isReversed,
33
+ State state,
33
34
ConnectionType::Enum connectionType,
34
35
bslma::Allocator* basicAllocator)
35
36
: d_initialConnectionContext_p(initialConnectionContext)
36
37
, d_authenticationMessage(basicAllocator)
38
+ , d_state(state)
37
39
, d_isReversed(isReversed)
38
40
, d_connectionType(connectionType)
39
41
{
@@ -54,6 +56,12 @@ AuthenticationContext& AuthenticationContext::setAuthenticationMessage(
54
56
return *this ;
55
57
}
56
58
59
+ int AuthenticationContext::testAndSwapState (State compareValue,
60
+ State swapValue)
61
+ {
62
+ return d_state.testAndSwap (compareValue, swapValue);
63
+ }
64
+
57
65
AuthenticationContext& AuthenticationContext::setIsReversed (bool value)
58
66
{
59
67
d_isReversed = value;
Original file line number Diff line number Diff line change @@ -40,10 +40,19 @@ namespace mqbnet {
40
40
41
41
// / VST for the context associated with an connection being authenticated.
42
42
class AuthenticationContext {
43
+ public:
44
+ // TYPES
45
+ enum State {
46
+ e_IDLE = 0 ,
47
+ e_AUTHENTICATING,
48
+ e_AUTHENTICATED,
49
+ };
50
+
43
51
private:
44
52
// DATA
45
53
InitialConnectionContext* d_initialConnectionContext_p;
46
54
bmqp_ctrlmsg::AuthenticationMessage d_authenticationMessage;
55
+ bsls::AtomicInt d_state;
47
56
bool d_isReversed;
48
57
ConnectionType::Enum d_connectionType;
49
58
@@ -63,6 +72,7 @@ class AuthenticationContext {
63
72
AuthenticationContext (
64
73
InitialConnectionContext* initialConnectionContext,
65
74
bool isReversed,
75
+ State state = State::e_IDLE,
66
76
ConnectionType::Enum connectionType = ConnectionType::e_UNKNOWN,
67
77
bslma::Allocator* basicAllocator = 0 );
68
78
@@ -74,6 +84,8 @@ class AuthenticationContext {
74
84
AuthenticationContext& setIsReversed (bool value);
75
85
AuthenticationContext& setConnectionType (ConnectionType::Enum value);
76
86
87
+ int testAndSwapState (State compareValue, State swapValue);
88
+
77
89
// ACCESSORS
78
90
InitialConnectionContext* initialConnectionContext () const ;
79
91
const bmqp_ctrlmsg::AuthenticationMessage& authenticationMessage () const ;
You can’t perform that action at this time.
0 commit comments