Skip to content

Commit

Permalink
Fix global_distrib sockets
Browse files Browse the repository at this point in the history
  • Loading branch information
NelsonVides committed Jan 10, 2025
1 parent 7f35c7f commit 7c6aaf5
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
7 changes: 4 additions & 3 deletions src/global_distrib/mod_global_distrib_connection.erl
Original file line number Diff line number Diff line change
Expand Up @@ -89,14 +89,15 @@ handle_cast({data, Stamp, Data}, #state{socket = Socket, host = ToHost} = State)
end,
{noreply, State}.

handle_info({tcp, _Socket, RawData}, #state{socket = Socket} = State) ->
handle_info({Tag, _Socket, RawData}, #state{socket = Socket} = State)
when Tag == tcp; Tag == ssl ->
ok = mod_global_distrib_transport:setopts(Socket, [{active, once}]),
%% Feeding data to drive the TLS state machine (in case of TLS connection)
{ok, _} = mod_global_distrib_transport:recv_data(Socket, RawData),
{noreply, State};
handle_info({tcp_closed, _}, State) ->
handle_info({Tag, _Socket}, State) when Tag == tcp_closed; Tag == ssl_closed ->
{stop, normal, State};
handle_info({tcp_error, _Socket, Reason}, State) ->
handle_info({Tag, _Socket, Reason}, State) when Tag == tcp_error; Tag == ssl_error ->
?LOG_ERROR(#{what => gd_outgoing_socket_error,
reason => Reason, peer => State#state.peer, conn_id => State#state.conn_id}),
mongoose_instrument:execute(?GLOBAL_DISTRIB_OUTGOING_ERRORED, #{}, #{count => 1, host => State#state.host}),
Expand Down
1 change: 0 additions & 1 deletion src/global_distrib/mod_global_distrib_transport.erl
Original file line number Diff line number Diff line change
Expand Up @@ -80,4 +80,3 @@ peername(#?MODULE{transport = just_tls, socket = Socket}) ->
{inet:ip_address(), inet:port_number()} | unknown.
normalize_peername({ok, {IP, Port}}) when is_tuple(IP), is_integer(Port) -> {IP, Port};
normalize_peername(_Other) -> unknown.

0 comments on commit 7c6aaf5

Please sign in to comment.