From ff371b3b33e435f63962615be06404f6f8af3d5e Mon Sep 17 00:00:00 2001 From: Raimo Niskanen Date: Mon, 19 Sep 2011 11:36:35 +0200 Subject: erts: Fix bug SCTP send can only be called from controlling process Conflicts: lib/kernel/test/gen_sctp_SUITE.erl --- erts/emulator/drivers/common/inet_drv.c | 5 ++--- lib/kernel/test/gen_sctp_SUITE.erl | 34 +++++++++++++++++++++++++++++++-- 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. -- cgit v1.2.3 From 0159f7a9598c1d88b2e184dcc442c254ef8f14c9 Mon Sep 17 00:00:00 2001 From: Raimo Niskanen Date: Mon, 19 Sep 2011 12:10:46 +0200 Subject: erts,kernel: Bugfix - read SCTP socket options from right protocol layer Socket options 'sndbuf', 'recbuf' and 'linger were read from the SCTP protocol layer instead of from the socket protocol layer. Conflicts: lib/kernel/test/gen_sctp_SUITE.erl --- erts/emulator/drivers/common/inet_drv.c | 6 +++--- lib/kernel/test/gen_sctp_SUITE.erl | 21 +++++++++++++++++++-- 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/erts/emulator/drivers/common/inet_drv.c b/erts/emulator/drivers/common/inet_drv.c index 3c4be8eea4..2bff5bd4f7 100644 --- a/erts/emulator/drivers/common/inet_drv.c +++ b/erts/emulator/drivers/common/inet_drv.c @@ -5941,7 +5941,7 @@ static int sctp_fill_opts(inet_descriptor* desc, char* buf, int buflen, struct linger lg; unsigned int sz = sizeof(lg); - if (sock_getopt(desc->s, IPPROTO_SCTP, SO_LINGER, + if (sock_getopt(desc->s, SOL_SOCKET, SO_LINGER, &lg, &sz) < 0) continue; /* Fill in the response: */ PLACE_FOR(spec, i, @@ -5977,7 +5977,7 @@ static int sctp_fill_opts(inet_descriptor* desc, char* buf, int buflen, { case INET_OPT_RCVBUF : { - proto = IPPROTO_SCTP; + proto = SOL_SOCKET; type = SO_RCVBUF; is_int = 1; tag = am_recbuf; @@ -5985,7 +5985,7 @@ static int sctp_fill_opts(inet_descriptor* desc, char* buf, int buflen, } case INET_OPT_SNDBUF : { - proto = IPPROTO_SCTP; + proto = SOL_SOCKET; type = SO_SNDBUF; is_int = 1; tag = am_sndbuf; diff --git a/lib/kernel/test/gen_sctp_SUITE.erl b/lib/kernel/test/gen_sctp_SUITE.erl index da2f533097..9ba226864d 100644 --- a/lib/kernel/test/gen_sctp_SUITE.erl +++ b/lib/kernel/test/gen_sctp_SUITE.erl @@ -24,11 +24,11 @@ %%-compile(export_all). -export([all/1,init_per_testcase/2,fin_per_testcase/2, - basic/1,api_open_close/1,api_listen/1,api_connect_init/1, + basic/1,api_open_close/1,api_listen/1,api_connect_init/1,api_opts/1, xfer_min/1,xfer_active/1]). all(suite) -> - [basic,api_open_close,api_listen,api_connect_init,xfer_min,xfer_active]. + [basic,api_open_close,api_listen,api_connect_init,api_opts,xfer_min,xfer_active]. init_per_testcase(_Func, Config) -> Dog = test_server:timetrap(test_server:seconds(15)), @@ -385,6 +385,23 @@ api_connect_init(Config) when is_list(Config) -> ?line ok = gen_sctp:close(Sb), ok. +api_opts(doc) -> + "Test socket options"; +api_opts(suite) -> + []; +api_opts(Config) when is_list(Config) -> + ?line Sndbuf = 32768, + ?line Recbuf = 65536, + ?line {ok,S} = gen_sctp:open(0), + ?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. + do_from_other_process(Fun) -> -- cgit v1.2.3 From f8b20b4a995727f0339074d23a0fae50712683d2 Mon Sep 17 00:00:00 2001 From: Erlang/OTP Date: Mon, 19 Sep 2011 12:24:34 +0200 Subject: Prepare release --- erts/doc/src/notes.xml | 18 ++++++++++++++++++ erts/vsn.mk | 2 +- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/erts/doc/src/notes.xml b/erts/doc/src/notes.xml index 824ad6d94e..09950e865b 100644 --- a/erts/doc/src/notes.xml +++ b/erts/doc/src/notes.xml @@ -30,6 +30,24 @@

This document describes the changes made to the ERTS application.

+
Erts 5.7.5.2 + +
Known Bugs and Problems + + +

+ Two bugs in gen_sctp has been corrected: getopts/setopts + hence also send could only be called from socket owner, + and options 'linger', 'rcvbuf' and 'sndbuf' was read from + wrong protocol layer hence read wrong values by getopts.

+

+ Own Id: OTP-9544

+
+
+
+ +
+
Erts 5.7.5.1
Fixed Bugs and Malfunctions diff --git a/erts/vsn.mk b/erts/vsn.mk index 14c6a3e4dd..4e6571c70b 100644 --- a/erts/vsn.mk +++ b/erts/vsn.mk @@ -17,7 +17,7 @@ # %CopyrightEnd% # -VSN = 5.7.5.1 +VSN = 5.7.5.2 SYSTEM_VSN = R13B04 # Port number 4365 in 4.2 -- cgit v1.2.3