File tree Expand file tree Collapse file tree 1 file changed +15
-1
lines changed Expand file tree Collapse file tree 1 file changed +15
-1
lines changed Original file line number Diff line number Diff line change @@ -1116,7 +1116,7 @@ def tls_verified?; @tls_verified end
1116
1116
#
1117
1117
# Related: #logout, #logout!
1118
1118
def disconnect
1119
- state_logout! unless connection_state . to_sym == :logout
1119
+ in_logout_state = try_state_logout?
1120
1120
return if disconnected?
1121
1121
begin
1122
1122
begin
@@ -1136,6 +1136,10 @@ def disconnect
1136
1136
@sock . close
1137
1137
end
1138
1138
raise e if e
1139
+ ensure
1140
+ # Try again after shutting down the receiver thread. With no reciever
1141
+ # left to wait for, any remaining locks should be _very_ brief.
1142
+ state_logout! unless in_logout_state
1139
1143
end
1140
1144
1141
1145
# Returns true if disconnected from the server.
@@ -3804,6 +3808,16 @@ def state_logout!
3804
3808
end
3805
3809
end
3806
3810
3811
+ # don't wait to aqcuire the lock
3812
+ def try_state_logout?
3813
+ return true if connection_state in [ :logout , *]
3814
+ return false unless acquired_lock = mon_try_enter
3815
+ state_logout!
3816
+ true
3817
+ ensure
3818
+ mon_exit if acquired_lock
3819
+ end
3820
+
3807
3821
def sasl_adapter
3808
3822
SASLAdapter . new ( self , &method ( :send_command_with_continuations ) )
3809
3823
end
You can’t perform that action at this time.
0 commit comments