1
1
% % The contents of this file are subject to the Mozilla Public License
2
- % % Version 2.0 (the "License"); you may not use this file except in
3
- % % compliance with the License. You may obtain a copy of the License
4
2
% % at https://www.mozilla.org/en-US/MPL/2.0/
5
3
% %
6
4
% % Software distributed under the License is distributed on an "AS IS"
173
171
callback_mode () ->
174
172
[state_functions , state_enter ].
175
173
176
- terminate (Reason , State , StatemData ) ->
174
+ terminate (Reason , State ,
175
+ # statem_data {transport = Transport ,
176
+ connection = # stream_connection {socket = Socket },
177
+ connection_state = ConnectionState } = StatemData ) ->
178
+ close (Transport , Socket , ConnectionState ),
177
179
rabbit_networking :unregister_non_amqp_connection (self ()),
178
180
notify_connection_closed (StatemData ),
179
- rabbit_log :debug (" ~p terminating in state '~s ' with reason '~p '" ,
180
- [? MODULE , State , Reason ]).
181
+ rabbit_log :debug (" ~s terminating in state '~s ' with reason '~W '" ,
182
+ [? MODULE , State , Reason , 10 ]).
181
183
182
184
start_link (KeepaliveSup , Transport , Ref , Opts ) ->
183
185
{ok ,
@@ -715,7 +717,6 @@ open(info, {OK, S, Data},
715
717
# stream_connection {connection_step = Step } = Connection1 ,
716
718
case Step of
717
719
closing ->
718
- close (Transport , S , State ),
719
720
stop ;
720
721
close_sent ->
721
722
rabbit_log_connection :debug (" Transitioned to close_sent" ),
@@ -800,8 +801,7 @@ open(info, {'DOWN', MonitorRef, process, _OsirisPid, _Reason},
800
801
connection_state = State1 }};
801
802
open (info , heartbeat_send ,
802
803
# statem_data {transport = Transport ,
803
- connection = # stream_connection {socket = S } = Connection ,
804
- connection_state = State }) ->
804
+ connection = # stream_connection {socket = S } = Connection }) ->
805
805
Frame = rabbit_stream_core :frame (heartbeat ),
806
806
case catch send (Transport , S , Frame ) of
807
807
ok ->
@@ -810,16 +810,12 @@ open(info, heartbeat_send,
810
810
rabbit_log_connection :info (" Heartbeat send error ~p , closing connection" ,
811
811
[Unexpected ]),
812
812
_C1 = demonitor_all_streams (Connection ),
813
- close (Transport , S , State ),
814
813
stop
815
814
end ;
816
815
open (info , heartbeat_timeout ,
817
- # statem_data {transport = Transport ,
818
- connection = # stream_connection {socket = S } = Connection ,
819
- connection_state = State }) ->
816
+ # statem_data {connection = # stream_connection {} = Connection }) ->
820
817
rabbit_log_connection :debug (" Heartbeat timeout, closing connection" ),
821
818
_C1 = demonitor_all_streams (Connection ),
822
- close (Transport , S , State ),
823
819
stop ;
824
820
open (info , {infos , From },
825
821
# statem_data {connection =
@@ -852,14 +848,11 @@ open({call, From}, {publishers_info, Items},
852
848
{keep_state_and_data ,
853
849
{reply , From , publishers_infos (Items , Connection )}};
854
850
open ({call , From }, {shutdown , Explanation },
855
- # statem_data {transport = Transport ,
856
- connection = # stream_connection {socket = S } = Connection ,
857
- connection_state = State }) ->
851
+ # statem_data {connection = Connection }) ->
858
852
% likely closing call from the management plugin
859
853
rabbit_log_connection :info (" Forcing stream connection ~p closing: ~p " ,
860
854
[self (), Explanation ]),
861
855
demonitor_all_streams (Connection ),
862
- close (Transport , S , State ),
863
856
{stop_and_reply , normal , {reply , From , ok }};
864
857
open (cast ,
865
858
{queue_event , _ , {osiris_written , _ , undefined , CorrelationList }},
@@ -1059,14 +1052,9 @@ close_sent(enter, _OldState,
1059
1052
# configuration {connection_negotiation_step_timeout =
1060
1053
StateTimeout }}) ->
1061
1054
{keep_state_and_data , {state_timeout , StateTimeout , close }};
1062
- close_sent (state_timeout , close ,
1063
- # statem_data {transport = Transport ,
1064
- connection = # stream_connection {socket = Socket },
1065
- connection_state = State }) ->
1066
- rabbit_log_connection :warning (" Closing connection because of timeout in state "
1067
- " '~s ' likely due to lack of client action." ,
1055
+ close_sent (state_timeout , close , # statem_data {}) ->
1056
+ rabbit_log_connection :warning (" Closing connection because of timeout in state '~s ' likely due to lack of client action." ,
1068
1057
[? FUNCTION_NAME ]),
1069
- close (Transport , Socket , State ),
1070
1058
stop ;
1071
1059
close_sent (info , {tcp , S , Data },
1072
1060
# statem_data {transport = Transport ,
@@ -1081,7 +1069,6 @@ close_sent(info, {tcp, S, Data},
1081
1069
[? FUNCTION_NAME , Step ]),
1082
1070
case Step of
1083
1071
closing_done ->
1084
- close (Transport , S , State1 ),
1085
1072
stop ;
1086
1073
_ ->
1087
1074
Transport :setopts (S , [{active , once }]),
@@ -1093,12 +1080,9 @@ close_sent(info, {tcp_closed, S}, _StatemData) ->
1093
1080
rabbit_log_connection :debug (" Stream protocol connection socket ~w closed [~w ]" ,
1094
1081
[S , self ()]),
1095
1082
stop ;
1096
- close_sent (info , {tcp_error , S , Reason },
1097
- # statem_data {transport = Transport , connection_state = State }) ->
1098
- rabbit_log_connection :error (" Stream protocol connection socket error: ~p [~w ] "
1099
- " [~w ]" ,
1083
+ close_sent (info , {tcp_error , S , Reason }, # statem_data {}) ->
1084
+ rabbit_log_connection :error (" Stream protocol connection socket error: ~p [~w ] [~w ]" ,
1100
1085
[Reason , S , self ()]),
1101
- close (Transport , S , State ),
1102
1086
stop ;
1103
1087
close_sent (info , {resource_alarm , IsThereAlarm },
1104
1088
StatemData = # statem_data {connection = Connection }) ->
0 commit comments