aboutsummaryrefslogtreecommitdiffstats
path: root/lib/kernel
diff options
context:
space:
mode:
authorRaimo Niskanen <[email protected]>2011-09-19 13:44:59 +0200
committerRaimo Niskanen <[email protected]>2011-09-19 13:44:59 +0200
commit30937b22530827f0e4686494230d17a15ff7accb (patch)
treec80503327b23fb6c02c393a803f35ca6e9e265b2 /lib/kernel
parent171407b6afb043c7d56fb78c8692fab3b99c4be6 (diff)
parent0159f7a9598c1d88b2e184dcc442c254ef8f14c9 (diff)
downloadotp-30937b22530827f0e4686494230d17a15ff7accb.tar.gz
otp-30937b22530827f0e4686494230d17a15ff7accb.tar.bz2
otp-30937b22530827f0e4686494230d17a15ff7accb.zip
Merge branch 'raimo/sctp-getsetopts/OTP-9544' into raimo/sctp-getsetopts-dev/OTP-9544
Conflicts: erts/emulator/drivers/common/inet_drv.c lib/kernel/test/gen_sctp_SUITE.erl
Diffstat (limited to 'lib/kernel')
-rw-r--r--lib/kernel/test/gen_sctp_SUITE.erl57
1 files changed, 50 insertions, 7 deletions
diff --git a/lib/kernel/test/gen_sctp_SUITE.erl b/lib/kernel/test/gen_sctp_SUITE.erl
index 03e734445c..1b534a5fc4 100644
--- a/lib/kernel/test/gen_sctp_SUITE.erl
+++ b/lib/kernel/test/gen_sctp_SUITE.erl
@@ -212,7 +212,9 @@ xfer_active(Config) when is_list(Config) ->
?line test_server:fail({unexpected,flush()})
end,
?line io:format("SbAssocId=~p~n", [SbAssocId]),
- ?line ok = gen_sctp:send(Sa, SaAssocId, 0, Data),
+ ?line ok =
+ do_from_other_process(
+ fun () -> gen_sctp:send(Sa, SaAssocId, 0, Data) end),
?line receive
{sctp,Sb,Loopback,Pa,
{[#sctp_sndrcvinfo{stream=Stream,
@@ -378,11 +380,14 @@ def_sndrcvinfo(Config) when is_list(Config) ->
end
end,
?line ok =
- gen_sctp:send(
- S2,
- #sctp_sndrcvinfo{stream=0, ppid=20, assoc_id=S2AssocId},
- <<"4: ",Data/binary>>),
- ?line case ok(gen_sctp:recv(S1)) of
+ do_from_other_process(
+ fun () ->
+ gen_sctp:send(
+ S2,
+ #sctp_sndrcvinfo{stream=0, ppid=20, assoc_id=S2AssocId},
+ <<"4: ",Data/binary>>)
+ end),
+ ?line case ok(do_from_other_process(fun() -> gen_sctp:recv(S1) end)) of
{Loopback,P2,
[#sctp_sndrcvinfo{
stream=0, ppid=20, context=0, assoc_id=S1AssocId}],
@@ -575,6 +580,8 @@ api_opts(doc) ->
api_opts(suite) ->
[];
api_opts(Config) when is_list(Config) ->
+ ?line Sndbuf = 32768,
+ ?line Recbuf = 65536,
?line {ok,S} = gen_sctp:open(0),
?line OSType = os:type(),
?line case {inet:setopts(S, [{linger,{true,2}}]),OSType} of
@@ -582,7 +589,15 @@ api_opts(Config) when is_list(Config) ->
ok;
{{error,einval},{unix,sunos}} ->
ok
- end.
+ end,
+ ?line ok = inet:setopts(S, [{sndbuf,Sndbuf}]),
+ ?line ok = inet:setopts(S, [{recbuf,Recbuf}]),
+ ?line case inet:getopts(S, [sndbuf]) of
+ {ok,[{sndbuf,SB}]} when SB >= Sndbuf -> ok
+ end,
+ ?line case inet:getopts(S, [recbuf]) of
+ {ok,[{recbuf,RB}]} when RB >= Recbuf -> ok
+ end.
implicit_inet6(Config) when is_list(Config) ->
?line Hostname = ok(inet:gethostname()),
@@ -638,3 +653,31 @@ implicit_inet6(S1, Addr) ->
{{0,0,0,0,0,0,0,0},P2} -> ok
end,
?line ok = gen_sctp:close(S2).
+
+
+
+do_from_other_process(Fun) ->
+ Parent = self(),
+ Ref = make_ref(),
+ Child =
+ spawn(fun () ->
+ try Fun() of
+ Result ->
+ Parent ! {Ref,Result}
+ catch
+ Class:Reason ->
+ Stacktrace = erlang:get_stacktrace(),
+ Parent ! {Ref,Class,Reason,Stacktrace}
+ end
+ end),
+ Mref = erlang:monitor(process, Child),
+ receive
+ {Ref,Result} ->
+ receive {'DOWN',Mref,_,_,_} -> Result end;
+ {Ref,Class,Reason,Stacktrace} ->
+ receive {'DOWN',Mref,_,_,_} ->
+ erlang:raise(Class, Reason, Stacktrace)
+ end;
+ {'DOWN',Mref,_,_,Reason} ->
+ erlang:exit(Reason)
+ end.