@@ -500,15 +500,10 @@ handle_cast({frame_body, FrameBody},
500500 # state {cfg = # cfg {writer_pid = WriterPid ,
501501 channel_num = Ch }} = State0 ) ->
502502 try handle_frame (FrameBody , State0 ) of
503- {reply , Replies , State } when is_list (Replies ) ->
504- lists :foreach (fun (Reply ) ->
505- rabbit_amqp_writer :send_command (WriterPid , Ch , Reply )
506- end , Replies ),
507- noreply (State );
508- {reply , Reply , State } ->
509- rabbit_amqp_writer :send_command (WriterPid , Ch , Reply ),
510- noreply (State );
511- {noreply , State } ->
503+ {ok , ReplyFrames , State } ->
504+ lists :foreach (fun (Frame ) ->
505+ rabbit_amqp_writer :send_command (WriterPid , Ch , Frame )
506+ end , ReplyFrames ),
512507 noreply (State );
513508 {stop , _ , _ } = Stop ->
514509 Stop
@@ -913,7 +908,7 @@ handle_frame({Performative = #'v1_0.transfer'{handle = ?UINT(Handle)}, Paylaod},
913908 _ ->
914909 incoming_mgmt_link_transfer (Performative , Paylaod , State1 )
915910 end ,
916- reply0 (Reply ++ Flows , State );
911+ reply_frames (Reply ++ Flows , State );
917912
918913% % Although the AMQP message format [3.2] requires a body, it is valid to send a transfer frame without payload.
919914% % For example, when a large multi transfer message is streamed using the ProtonJ2 client, the client could send
@@ -962,7 +957,7 @@ handle_frame(#'v1_0.flow'{handle = Handle} = Flow,
962957 end
963958 end
964959 end ,
965- { noreply , S } ;
960+ reply_frames ([] , S ) ;
966961
967962handle_frame (# 'v1_0.disposition' {role = ? AMQP_ROLE_RECEIVER ,
968963 first = ? UINT (First ),
@@ -981,7 +976,7 @@ handle_frame(#'v1_0.disposition'{role = ?AMQP_ROLE_RECEIVER,
981976 UnsettledMapSize = map_size (UnsettledMap0 ),
982977 case UnsettledMapSize of
983978 0 ->
984- { noreply , State0 } ;
979+ reply_frames ([] , State0 ) ;
985980 _ ->
986981 DispositionRangeSize = diff (Last , First ) + 1 ,
987982 {Settled , UnsettledMap } =
@@ -1041,7 +1036,7 @@ handle_frame(#'v1_0.disposition'{role = ?AMQP_ROLE_RECEIVER,
10411036 role = ? AMQP_ROLE_SENDER }]
10421037 end ,
10431038 State = handle_queue_actions (Actions , State1 ),
1044- reply0 (Reply , State )
1039+ reply_frames (Reply , State )
10451040 end ;
10461041
10471042handle_frame (# 'v1_0.attach' {handle = ? UINT (Handle )} = Attach ,
@@ -1095,9 +1090,9 @@ handle_frame(Detach = #'v1_0.detach'{handle = ?UINT(HandleInt)},
10951090 outgoing_pending = Pending ,
10961091 queue_states = QStates },
10971092 State = maybe_detach_mgmt_link (HandleInt , State1 ),
1098- maybe_detach_reply (Detach , State , State0 ),
1093+ Reply = detach_reply (Detach , State , State0 ),
10991094 publisher_or_consumer_deleted (State , State0 ),
1100- { noreply , State } ;
1095+ reply_frames ( Reply , State ) ;
11011096
11021097handle_frame (# 'v1_0.end' {},
11031098 State0 = # state {cfg = # cfg {writer_pid = WriterPid ,
@@ -1118,6 +1113,9 @@ handle_frame(Frame, _State) ->
11181113 " Unexpected frame ~tp " ,
11191114 [amqp10_framing :pprint (Frame )]).
11201115
1116+ reply_frames (Frames , State ) ->
1117+ {ok , session_flow_fields (Frames , State ), State }.
1118+
11211119handle_attach (# 'v1_0.attach' {
11221120 role = ? AMQP_ROLE_SENDER ,
11231121 snd_settle_mode = ? V_1_0_SENDER_SETTLE_MODE_SETTLED ,
@@ -1173,7 +1171,7 @@ handle_attach(#'v1_0.attach'{
11731171 Flow = # 'v1_0.flow' {handle = Handle ,
11741172 delivery_count = DeliveryCount ,
11751173 link_credit = ? UINT (? MAX_MANAGEMENT_LINK_CREDIT )},
1176- reply0 ([Reply , Flow ], State );
1174+ reply_frames ([Reply , Flow ], State );
11771175
11781176handle_attach (# 'v1_0.attach' {
11791177 role = ? AMQP_ROLE_RECEIVER ,
@@ -1228,7 +1226,7 @@ handle_attach(#'v1_0.attach'{
12281226 % % Echo back that we will respect the client's requested max-message-size.
12291227 max_message_size = MaybeMaxMessageSize ,
12301228 properties = Properties },
1231- reply0 ( Reply , State );
1229+ reply_frames ([ Reply ] , State );
12321230
12331231handle_attach (# 'v1_0.attach' {role = ? AMQP_ROLE_SENDER ,
12341232 name = LinkName ,
@@ -1275,7 +1273,7 @@ handle_attach(#'v1_0.attach'{role = ?AMQP_ROLE_SENDER,
12751273 State = State0 # state {incoming_links = IncomingLinks ,
12761274 permission_cache = PermCache },
12771275 rabbit_global_counters :publisher_created (? PROTOCOL ),
1278- reply0 ([Reply , Flow ], State );
1276+ reply_frames ([Reply , Flow ], State );
12791277 {error , Reason } ->
12801278 protocol_error (? V_1_0_AMQP_ERROR_INVALID_FIELD ,
12811279 " Attach rejected: ~tp " ,
@@ -1416,7 +1414,7 @@ handle_attach(#'v1_0.attach'{role = ?AMQP_ROLE_RECEIVER,
14161414 end
14171415 end ) of
14181416 {ok , Reply , State } ->
1419- reply0 (Reply , State );
1417+ reply_frames (Reply , State );
14201418 {error , Reason } ->
14211419 protocol_error (
14221420 ? V_1_0_AMQP_ERROR_INTERNAL_ERROR ,
@@ -1842,11 +1840,6 @@ record_outgoing_unsettled(#pending_delivery{queue_ack_required = false}, State)
18421840 % % Also, queue client already acked to queue on behalf of us.
18431841 State .
18441842
1845- reply0 ([], State ) ->
1846- {noreply , State };
1847- reply0 (Reply , State ) ->
1848- {reply , session_flow_fields (Reply , State ), State }.
1849-
18501843% % Implements section "receiving a transfer" in 2.5.6
18511844session_flow_control_received_transfer (
18521845 # state {next_incoming_id = NextIncomingId ,
@@ -3278,26 +3271,22 @@ publisher_or_consumer_deleted(
32783271
32793272% % If we previously already sent a detach with an error condition, and the Detach we
32803273% % receive here is therefore the client's reply, do not reply again with a 3rd detach.
3281- maybe_detach_reply (
3282- Detach ,
3283- # state {incoming_links = NewIncomingLinks ,
3284- outgoing_links = NewOutgoingLinks ,
3285- incoming_management_links = NewIncomingMgmtLinks ,
3286- outgoing_management_links = NewOutgoingMgmtLinks ,
3287- cfg = # cfg {writer_pid = WriterPid ,
3288- channel_num = Ch }},
3289- # state {incoming_links = OldIncomingLinks ,
3290- outgoing_links = OldOutgoingLinks ,
3291- incoming_management_links = OldIncomingMgmtLinks ,
3292- outgoing_management_links = OldOutgoingMgmtLinks })
3274+ detach_reply (Detach ,
3275+ # state {incoming_links = NewIncomingLinks ,
3276+ outgoing_links = NewOutgoingLinks ,
3277+ incoming_management_links = NewIncomingMgmtLinks ,
3278+ outgoing_management_links = NewOutgoingMgmtLinks },
3279+ # state {incoming_links = OldIncomingLinks ,
3280+ outgoing_links = OldOutgoingLinks ,
3281+ incoming_management_links = OldIncomingMgmtLinks ,
3282+ outgoing_management_links = OldOutgoingMgmtLinks })
32933283 when map_size (NewIncomingLinks ) < map_size (OldIncomingLinks ) orelse
32943284 map_size (NewOutgoingLinks ) < map_size (OldOutgoingLinks ) orelse
32953285 map_size (NewIncomingMgmtLinks ) < map_size (OldIncomingMgmtLinks ) orelse
32963286 map_size (NewOutgoingMgmtLinks ) < map_size (OldOutgoingMgmtLinks ) ->
3297- Reply = Detach # 'v1_0.detach' {error = undefined },
3298- rabbit_amqp_writer :send_command (WriterPid , Ch , Reply );
3299- maybe_detach_reply (_ , _ , _ ) ->
3300- ok .
3287+ [Detach # 'v1_0.detach' {error = undefined }];
3288+ detach_reply (_ , _ , _ ) ->
3289+ [].
33013290
33023291-spec maybe_detach_mgmt_link (link_handle (), state ()) -> state ().
33033292maybe_detach_mgmt_link (
0 commit comments