From 0ad63bcc5523f0b560c843b3ed02c08e1369e522 Mon Sep 17 00:00:00 2001 From: Sverker Eriksson Date: Tue, 27 Nov 2018 21:16:47 +0100 Subject: erts: Fix bug in sendfile for active socket driver_select() was called after port had been killed by tcp_inet_sendfile() calling tcp_send_error(). --- lib/kernel/test/sendfile_SUITE.erl | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'lib') diff --git a/lib/kernel/test/sendfile_SUITE.erl b/lib/kernel/test/sendfile_SUITE.erl index 0c0b1cbcb6..062209fa29 100644 --- a/lib/kernel/test/sendfile_SUITE.erl +++ b/lib/kernel/test/sendfile_SUITE.erl @@ -341,7 +341,9 @@ t_sendfile_closeduring(Config) -> -1 end, - ok = sendfile_send({127,0,0,1}, Send, 0). + ok = sendfile_send({127,0,0,1}, Send, 0, [{active,false}]), + ok = sendfile_send({127,0,0,1}, Send, 0, [{active,true}]). + t_sendfile_crashduring(Config) -> Filename = proplists:get_value(big_file, Config), @@ -409,12 +411,16 @@ sendfile_send(Send) -> sendfile_send(Host, Send) -> sendfile_send(Host, Send, []). sendfile_send(Host, Send, Orig) -> + sendfile_send(Host, Send, Orig, [{active,false}]). + +sendfile_send(Host, Send, Orig, SockOpts) -> + SFServer = spawn_link(?MODULE, sendfile_server, [self(), Orig]), receive {server, Port} -> - {ok, Sock} = gen_tcp:connect(Host, Port, - [binary,{packet,0}, - {active,false}]), + Opts = [binary,{packet,0}|SockOpts], + io:format("connect with opts = ~p\n", [Opts]), + {ok, Sock} = gen_tcp:connect(Host, Port, Opts), Data = case proplists:get_value(arity,erlang:fun_info(Send)) of 1 -> Send(Sock); -- cgit v1.2.3 From 06c46662022efb6892c036eeaf8c957e51fc17f7 Mon Sep 17 00:00:00 2001 From: Sverker Eriksson Date: Wed, 28 Nov 2018 20:31:37 +0100 Subject: erts: Fix unexpected inet_reply message from failing file:sendfile A failing file:sendfile call would often send a message {inet_reply, Port, {error, Reason}} that would pollute the mailbox of the calling process. TCP_REQ_SENDFILE has its own reply messages format {sendfile, _, _} and does not expect an inet_reply message. Solution: Suppress inet_reply error message if TCP_ADDF_SENDFILE is set. --- lib/kernel/test/sendfile_SUITE.erl | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/kernel/test/sendfile_SUITE.erl b/lib/kernel/test/sendfile_SUITE.erl index 062209fa29..ad060aa05c 100644 --- a/lib/kernel/test/sendfile_SUITE.erl +++ b/lib/kernel/test/sendfile_SUITE.erl @@ -342,8 +342,20 @@ t_sendfile_closeduring(Config) -> end, ok = sendfile_send({127,0,0,1}, Send, 0, [{active,false}]), - ok = sendfile_send({127,0,0,1}, Send, 0, [{active,true}]). + [] = flush(), + ok = sendfile_send({127,0,0,1}, Send, 0, [{active,true}]), + [] = flush(), + ok. + +flush() -> + lists:reverse(flush([])). +flush(Acc) -> + receive M -> + flush([M | Acc]) + after 0 -> + Acc + end. t_sendfile_crashduring(Config) -> Filename = proplists:get_value(big_file, Config), -- cgit v1.2.3