aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRaimo Niskanen <[email protected]>2011-09-19 11:36:35 +0200
committerRaimo Niskanen <[email protected]>2011-09-19 11:36:35 +0200
commitff371b3b33e435f63962615be06404f6f8af3d5e (patch)
tree557a78eaf20bb1fe415d95fd01905f1417a85366
parent801ec3847e330b7d67b1e4ae700211380da0d6bd (diff)
downloadotp-ff371b3b33e435f63962615be06404f6f8af3d5e.tar.gz
otp-ff371b3b33e435f63962615be06404f6f8af3d5e.tar.bz2
otp-ff371b3b33e435f63962615be06404f6f8af3d5e.zip
erts: Fix bug SCTP send can only be called from controlling process
Conflicts: lib/kernel/test/gen_sctp_SUITE.erl
-rw-r--r--erts/emulator/drivers/common/inet_drv.c5
-rw-r--r--lib/kernel/test/gen_sctp_SUITE.erl34
2 files changed, 34 insertions, 5 deletions
diff --git a/erts/emulator/drivers/common/inet_drv.c b/erts/emulator/drivers/common/inet_drv.c
index c6e23ee647..3c4be8eea4 100644
--- a/erts/emulator/drivers/common/inet_drv.c
+++ b/erts/emulator/drivers/common/inet_drv.c
@@ -1,7 +1,7 @@
/*
* %CopyrightBegin%
*
- * Copyright Ericsson AB 1997-2009. All Rights Reserved.
+ * Copyright Ericsson AB 1997-2011. All Rights Reserved.
*
* The contents of this file are subject to the Erlang Public License,
* Version 1.1, (the "License"); you may not use this file except in
@@ -6425,8 +6425,7 @@ static int sctp_fill_opts(inet_descriptor* desc, char* buf, int buflen,
i = LOAD_TUPLE(spec, i, 3);
/* Now, convert "spec" into the returnable term: */
- /* desc->caller = 0; What does it mean? */
- driver_output_term(desc->port, spec, i);
+ driver_send_term(desc->port, driver_caller(desc->port), spec, i);
FREE(spec);
(*dest)[0] = INET_REP_SCTP;
diff --git a/lib/kernel/test/gen_sctp_SUITE.erl b/lib/kernel/test/gen_sctp_SUITE.erl
index fad8c7398b..da2f533097 100644
--- a/lib/kernel/test/gen_sctp_SUITE.erl
+++ b/lib/kernel/test/gen_sctp_SUITE.erl
@@ -1,7 +1,7 @@
%%
%% %CopyrightBegin%
%%
-%% Copyright Ericsson AB 2007-2010. All Rights Reserved.
+%% Copyright Ericsson AB 2007-2011. All Rights Reserved.
%%
%% The contents of this file are subject to the Erlang Public License,
%% Version 1.1, (the "License"); you may not use this file except in
@@ -172,7 +172,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,
@@ -382,3 +384,31 @@ api_connect_init(Config) when is_list(Config) ->
?line ok = gen_sctp:close(Sa),
?line ok = gen_sctp:close(Sb),
ok.
+
+
+
+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.