173
173
callback_mode () ->
174
174
[state_functions , state_enter ].
175
175
176
- terminate (Reason , State , StatemData ) ->
176
+ terminate (Reason , State ,
177
+ # statem_data {transport = Transport ,
178
+ connection = # stream_connection {socket = Socket },
179
+ connection_state = ConnectionState } = StatemData ) ->
180
+ close (Transport , Socket , ConnectionState ),
177
181
rabbit_networking :unregister_non_amqp_connection (self ()),
178
182
notify_connection_closed (StatemData ),
179
- rabbit_log :debug (" ~p terminating in state '~s ' with reason '~p '" ,
180
- [? MODULE , State , Reason ]).
183
+ rabbit_log :debug (" ~s terminating in state '~s ' with reason '~W '" ,
184
+ [? MODULE , State , Reason , 10 ]).
181
185
182
186
start_link (KeepaliveSup , Transport , Ref , Opts ) ->
183
187
{ok ,
@@ -713,7 +717,6 @@ open(info, {OK, S, Data},
713
717
# stream_connection {connection_step = Step } = Connection1 ,
714
718
case Step of
715
719
closing ->
716
- close (Transport , S , State ),
717
720
stop ;
718
721
close_sent ->
719
722
rabbit_log_connection :debug (" Transitioned to close_sent" ),
@@ -808,7 +811,6 @@ open(info, heartbeat_send,
808
811
rabbit_log_connection :info (" Heartbeat send error ~p , closing connection" ,
809
812
[Unexpected ]),
810
813
_C1 = demonitor_all_streams (Connection ),
811
- close (Transport , S , State ),
812
814
stop
813
815
end ;
814
816
open (info , heartbeat_timeout ,
@@ -817,7 +819,6 @@ open(info, heartbeat_timeout,
817
819
connection_state = State }) ->
818
820
rabbit_log_connection :debug (" Heartbeat timeout, closing connection" ),
819
821
_C1 = demonitor_all_streams (Connection ),
820
- close (Transport , S , State ),
821
822
stop ;
822
823
open (info , {infos , From },
823
824
# statem_data {connection =
@@ -857,7 +858,6 @@ open({call, From}, {shutdown, Explanation},
857
858
rabbit_log_connection :info (" Forcing stream connection ~p closing: ~p " ,
858
859
[self (), Explanation ]),
859
860
demonitor_all_streams (Connection ),
860
- close (Transport , S , State ),
861
861
{stop_and_reply , normal , {reply , From , ok }};
862
862
open (cast ,
863
863
{queue_event , _ , {osiris_written , _ , undefined , CorrelationList }},
@@ -1060,7 +1060,6 @@ close_sent(state_timeout, close,
1060
1060
connection_state = State }) ->
1061
1061
rabbit_log_connection :warning (" Closing connection because of timeout in state '~s ' likely due to lack of client action." ,
1062
1062
[? FUNCTION_NAME ]),
1063
- close (Transport , Socket , State ),
1064
1063
stop ;
1065
1064
close_sent (info , {tcp , S , Data },
1066
1065
# statem_data {transport = Transport ,
@@ -1075,7 +1074,6 @@ close_sent(info, {tcp, S, Data},
1075
1074
[? FUNCTION_NAME , Step ]),
1076
1075
case Step of
1077
1076
closing_done ->
1078
- close (Transport , S , State1 ),
1079
1077
stop ;
1080
1078
_ ->
1081
1079
Transport :setopts (S , [{active , once }]),
@@ -1091,7 +1089,6 @@ close_sent(info, {tcp_error, S, Reason},
1091
1089
# statem_data {transport = Transport , connection_state = State }) ->
1092
1090
rabbit_log_connection :error (" Stream protocol connection socket error: ~p [~w ] [~w ]" ,
1093
1091
[Reason , S , self ()]),
1094
- close (Transport , S , State ),
1095
1092
stop ;
1096
1093
close_sent (info , {resource_alarm , IsThereAlarm },
1097
1094
StatemData = # statem_data {connection = Connection }) ->
0 commit comments