From b409496fdb0eaa293a63f5c98c8f642aa8ce7aaa Mon Sep 17 00:00:00 2001
From: Anders Svensson <anders@erlang.org>
Date: Sun, 21 Jun 2015 11:38:38 +0200
Subject: Fix connection timeouts in test transports

Without a timeout, TCP/SCTP connect can take some time to fail, which
resulted in failures in the pool suite after the parent commit fixed the
previously faulty sctp-first-then-tcp connect.
---
 lib/diameter/test/diameter_util.erl | 18 +++++++++++++++---
 1 file changed, 15 insertions(+), 3 deletions(-)

(limited to 'lib')

diff --git a/lib/diameter/test/diameter_util.erl b/lib/diameter/test/diameter_util.erl
index c9022b9c53..5701ede0c1 100644
--- a/lib/diameter/test/diameter_util.erl
+++ b/lib/diameter/test/diameter_util.erl
@@ -380,9 +380,21 @@ tmod(any) ->
     [diameter_sctp, diameter_tcp].
 
 opts(Prot, T) ->
-    lists:append([[{transport_module, M}, {transport_config, C}]
-                  || M <- tmod(Prot),
-                     C <- [cfg(M,T) ++ cfg(M) ++ cfg(T)]]).
+    tmo(T, lists:append([[{transport_module, M}, {transport_config, C}]
+                         || M <- tmod(Prot),
+                            C <- [cfg(M,T) ++ cfg(M) ++ cfg(T)]])).
+
+tmo(listen, Opts) ->
+    Opts;
+tmo(_, Opts) ->
+    tmo(Opts).
+
+%% Timeout on all but the last alternative.
+tmo([_,_] = Opts) ->
+    Opts;
+tmo([M, C | Opts]) ->
+    {transport_config = K, Cfg} = C,
+    [M, {K, Cfg, 5000} | tmo(Opts)].
 
 %% Listening SCTP socket need larger-than-default buffers to avoid
 %% resends on some platforms (eg. SLES 11).
-- 
cgit v1.2.3