diff options
author | Raimo Niskanen <raimo@erlang.org> | 2010-06-21 15:22:37 +0200 |
---|---|---|
committer | Raimo Niskanen <raimo@erlang.org> | 2010-07-07 11:44:40 +0200 |
commit | 2128fcef45951e159f05e5667841a7442acfa1be (patch) | |
tree | 3cf3f9be373e9c03dbc3b061a0d406b17a7fed81 | |
parent | 5ef0b06ddbaa48499394c30d56fc81e7162abf50 (diff) | |
download | otp-2128fcef45951e159f05e5667841a7442acfa1be.tar.gz otp-2128fcef45951e159f05e5667841a7442acfa1be.tar.bz2 otp-2128fcef45951e159f05e5667841a7442acfa1be.zip |
Fix inet_drv to detect passive mode UDP errors for SCTP builds
Debug and patch by Per Hedeland for R13B04 on erlang-patches:
Connected UDP (and handling of any other errors in UDP recv())
is broken in passive mode for all SCTP-enabled builds.
-rw-r--r-- | erts/emulator/drivers/common/inet_drv.c | 8 | ||||
-rw-r--r-- | lib/kernel/test/gen_udp_SUITE.erl | 21 |
2 files changed, 24 insertions, 5 deletions
diff --git a/erts/emulator/drivers/common/inet_drv.c b/erts/emulator/drivers/common/inet_drv.c index 87691fc1bc..0ea54930ba 100644 --- a/erts/emulator/drivers/common/inet_drv.c +++ b/erts/emulator/drivers/common/inet_drv.c @@ -9333,11 +9333,13 @@ static int packet_inet_input(udp_descriptor* udesc, HANDLE event) if (err != ERRNO_BLOCK) { if (!desc->active) { #ifdef HAVE_SCTP - if (short_recv) + if (short_recv) { async_error_am(desc, am_short_recv); - else -#else + } else { async_error(desc, err); + } +#else + async_error(desc, err); #endif driver_cancel_timer(desc->port); sock_select(desc,FD_READ,0); diff --git a/lib/kernel/test/gen_udp_SUITE.erl b/lib/kernel/test/gen_udp_SUITE.erl index bd5685952e..fa1991872b 100644 --- a/lib/kernel/test/gen_udp_SUITE.erl +++ b/lib/kernel/test/gen_udp_SUITE.erl @@ -34,12 +34,12 @@ -export([send_to_closed/1, buffer_size/1, binary_passive_recv/1, bad_address/1, - read_packets/1, open_fd/1]). + read_packets/1, open_fd/1, connect/1]). all(suite) -> [send_to_closed, buffer_size, binary_passive_recv, bad_address, read_packets, - open_fd]. + open_fd, connect]. init_per_testcase(_Case, Config) -> ?line Dog=test_server:timetrap(?default_timeout), @@ -408,3 +408,20 @@ start_node(Name) -> stop_node(Node) -> ?t:stop_node(Node). + + +connect(suite) -> + []; +connect(doc) -> + ["Test that connect/3 has effect"]; +connect(Config) when is_list(Config) -> + Addr = {127,0,0,1}, + {ok,S1} = gen_udp:open(0), + {ok,P1} = inet:port(S1), + {ok,S2} = gen_udp:open(0), + ok = inet:setopts(S2, [{active,false}]), + ok = gen_udp:close(S1), + ok = gen_udp:connect(S2, Addr, P1), + ok = gen_udp:send(S2, <<16#deadbeef:32>>), + {error,econnrefused} = gen_udp:recv(S2, 0, 5), + ok. |