Skip to content

Commit 99ea452

Browse files
committed
Add client properties to connection.closed events
This commit adds client properties to connection.closed events. The original need was to have only the optional user-provided connection name added to correlate connections between created and closed events, but all the client properties are finally added for the sake of consistency between the 2 events. This commit uses the process dictionary to convey the client properties, as they're not yet available in the connection state when the call to send the closed event is made (in the after block, just after the network connection has been established). Fixes #1596 [#157500358]
1 parent c395246 commit 99ea452

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

src/rabbit_reader.erl

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -387,10 +387,17 @@ start_connection(Parent, HelperSup, Deb, Sock) ->
387387
%% socket w/o delay before termination.
388388
rabbit_net:fast_close(RealSocket),
389389
rabbit_networking:unregister_connection(self()),
390-
rabbit_core_metrics:connection_closed(self()),
390+
rabbit_core_metrics:connection_closed(self()),
391+
ClientProperties = case get(client_properties) of
392+
undefined ->
393+
[];
394+
Properties ->
395+
Properties
396+
end,
391397
rabbit_event:notify(connection_closed, [{name, Name},
392398
{pid, self()},
393-
{node, node()}])
399+
{node, node()},
400+
{client_properties, ClientProperties}])
394401
end,
395402
done.
396403

@@ -1130,6 +1137,9 @@ handle_method0(#'connection.start_ok'{mechanism = Mechanism,
11301137
Connection2 = augment_connection_log_name(Connection1),
11311138
State = State0#v1{connection_state = securing,
11321139
connection = Connection2},
1140+
% adding client properties to process dictionary to send them later
1141+
% in the connection_closed event
1142+
put(client_properties, ClientProperties),
11331143
auth_phase(Response, State);
11341144

11351145
handle_method0(#'connection.secure_ok'{response = Response},

0 commit comments

Comments
 (0)