From 9ff8491996381cb2297671b94b7282a7ffb2136f Mon Sep 17 00:00:00 2001 From: Anders Svensson Date: Thu, 9 Feb 2017 17:18:21 +0100 Subject: Don't send from receiving transport processes Both diameter_tcp and diameter_sctp are susceptible to deadlock since a peer that blocks send also prevents additional messages from being received. Send from a process that's paired with the transport process to avoid this. Use the existing monitor process in the TCP case, add one in the SCTP case. This has been the reason for many sporadic testcase failures, mostly in diameter_traffic_SUITE. --- lib/diameter/test/diameter_watchdog_SUITE.erl | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'lib/diameter/test') diff --git a/lib/diameter/test/diameter_watchdog_SUITE.erl b/lib/diameter/test/diameter_watchdog_SUITE.erl index 6d22ddcc18..5ae951f7c2 100644 --- a/lib/diameter/test/diameter_watchdog_SUITE.erl +++ b/lib/diameter/test/diameter_watchdog_SUITE.erl @@ -1,7 +1,7 @@ %% %% %CopyrightBegin% %% -%% Copyright Ericsson AB 2010-2015. All Rights Reserved. +%% Copyright Ericsson AB 2010-2017. All Rights Reserved. %% %% Licensed under the Apache License, Version 2.0 (the "License"); %% you may not use this file except in compliance with the License. @@ -569,12 +569,12 @@ send(_, Sock, <<_:32, 1:1, _:7, 280:24, _:32, EId:32, HId:32, _/binary>>) -> {'Origin-Host', "XXX"}, {'Origin-Realm', ?REALM}]}, #diameter_packet{bin = Bin} = diameter_codec:encode(?BASE, Pkt), - self() ! {tcp, Sock, Bin}, + tpid(Sock) ! {tcp, Sock, Bin}, ok; %% First outgoing DWA. send(init, Sock, Bin) -> - [{{?MODULE, _, T}, _}] = diameter_reg:wait({?MODULE, self(), '_'}), + [{{?MODULE, _, T}, _}] = diameter_reg:wait({?MODULE, tpid(Sock), '_'}), putr(config, T), send(Sock, Bin); @@ -607,6 +607,14 @@ send(N, Sock, <<_:32, 0:1, _:7, 280:24, _/binary>> = Bin) -> putr(config, N-1), gen_tcp:send(Sock, Bin). +%% tpid/1 + +tpid(Sock) -> + {connected, Pid} = erlang:port_info(Sock, connected), + Pid. + +%%failback/5 + failback(Tmo, Msg, Sock, Bin, Origin) -> timer:sleep(Tmo), ok = gen_tcp:send(Sock, msg(Msg, Bin, Origin)). -- cgit v1.2.3