Skip to content

Commit bd61fde

Browse files
committed
AMQP 0.9: Prioritise updating internal state
This is an attempt to solve flakes WIP
1 parent ee578e8 commit bd61fde

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

deps/rabbit/src/rabbit_reader.erl

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -361,10 +361,6 @@ start_connection(Parent, HelperSups, RanchRef, Deb, Sock) ->
361361
ConnNameEx = dynamic_connection_name(Name),
362362
log_connection_exception(ConnNameEx, ConnectedAt, Ex)
363363
after
364-
%% We don't call gen_tcp:close/1 here since it waits for
365-
%% pending output to be sent, which results in unnecessary
366-
%% delays.
367-
rabbit_net:fast_close(RealSocket),
368364
rabbit_networking:unregister_connection(self()),
369365
rabbit_core_metrics:connection_closed(self()),
370366
ClientProperties = case get(client_properties) of
@@ -383,7 +379,12 @@ start_connection(Parent, HelperSups, RanchRef, Deb, Sock) ->
383379
ConnectionUserProvidedName ->
384380
[{user_provided_name, ConnectionUserProvidedName} | EventProperties]
385381
end,
386-
rabbit_event:notify(connection_closed, EventProperties1)
382+
rabbit_event:notify(connection_closed, EventProperties1),
383+
384+
%% We don't call gen_tcp:close/1 here since it waits for
385+
%% pending output to be sent, which results in unnecessary
386+
%% delays.
387+
rabbit_net:fast_close(RealSocket)
387388
end,
388389
done.
389390

@@ -1252,7 +1253,6 @@ handle_method0(#'connection.open'{virtual_host = VHost},
12521253
ok = rabbit_access_control:check_vhost_access(User, VHost, {socket, Sock}, #{}),
12531254
ok = is_vhost_alive(VHost, User),
12541255
NewConnection = Connection#connection{vhost = VHost},
1255-
ok = send_on_channel0(Sock, #'connection.open_ok'{}, Protocol),
12561256

12571257
Alarms = rabbit_alarm:register(self(), {?MODULE, conserve_resources, []}),
12581258
BlockedBy = sets:from_list([{resource, Alarm} || Alarm <- Alarms]),
@@ -1276,6 +1276,9 @@ handle_method0(#'connection.open'{virtual_host = VHost},
12761276
rabbit_log_connection:info(
12771277
"connection ~ts: user '~ts' authenticated and granted access to vhost '~ts'",
12781278
[dynamic_connection_name(ConnName), Username, VHost]),
1279+
1280+
ok = send_on_channel0(Sock, #'connection.open_ok'{}, Protocol),
1281+
12791282
State1;
12801283
handle_method0(#'connection.close'{}, State) when ?IS_RUNNING(State) ->
12811284
lists:foreach(fun rabbit_channel:shutdown/1, all_channels()),

0 commit comments

Comments
 (0)