Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: erlang/otp
base: master
...
head fork: nox/otp
compare: reedr-opt-prim_inet-accept
Checking mergeability… Don’t worry, you can still create the pull request.
  • 2 commits
  • 3 files changed
  • 0 commit comments
  • 2 contributors
Commits on Aug 16, 2014
@reedr reedr Inherit options in gen_tcp:accept/1 in inet_drv directly
This removes a getopts/setopts roundtrip in prim_inet:accept/1.
d57d3ee
@nox nox Test that options are correctly inherited in gen_tcp:accept/1
The following options should be inherited: active, nodelay, keepalive,
delay_send, priority and tos.
905e54a
View
2  erts/emulator/drivers/common/inet_drv.c
@@ -8981,6 +8981,7 @@ static tcp_descriptor* tcp_inet_copy(tcp_descriptor* desc,SOCKET s,
}
/* Some flags must be inherited at this point */
+ copy_desc->inet.active = desc->inet.active;
copy_desc->inet.mode = desc->inet.mode;
copy_desc->inet.exitf = desc->inet.exitf;
copy_desc->inet.deliver = desc->inet.deliver;
@@ -8994,6 +8995,7 @@ static tcp_descriptor* tcp_inet_copy(tcp_descriptor* desc,SOCKET s,
copy_desc->low = desc->low;
copy_desc->send_timeout = desc->send_timeout;
copy_desc->send_timeout_close = desc->send_timeout_close;
+ copy_desc->tcp_add_flags = desc->tcp_add_flags & TCP_ADDF_DELAY_SEND;
/* The new port will be linked and connected to the original caller */
port = driver_create_port(port, owner, "tcp_inet", (ErlDrvData) copy_desc);
View
18 erts/preloaded/src/prim_inet.erl
@@ -307,26 +307,12 @@ accept0(L, Time) when is_port(L), is_integer(Time) ->
case async_accept(L, Time) of
{ok, Ref} ->
receive
- {inet_async, L, Ref, {ok,S}} ->
- accept_opts(L, S);
- {inet_async, L, Ref, Error} ->
- Error
+ {inet_async, L, Ref, Result} ->
+ Result
end;
Error -> Error
end.
-%% setup options from listen socket on the connected socket
-accept_opts(L, S) ->
- case getopts(L, [active, nodelay, keepalive, delay_send, priority, tos]) of
- {ok, Opts} ->
- case setopts(S, Opts) of
- ok -> {ok, S};
- Error -> close(S), Error
- end;
- Error ->
- close(S), Error
- end.
-
async_accept(L, Time) ->
case ctl_cmd(L,?INET_REQ_ACCEPT, [enc_time(Time)]) of
{ok, [R1,R0]} -> {ok, ?u16(R1,R0)};
View
19 lib/kernel/test/gen_tcp_misc_SUITE.erl
@@ -40,7 +40,7 @@
accept_timeouts_in_order/1,accept_timeouts_in_order2/1,
accept_timeouts_in_order3/1,accept_timeouts_mixed/1,
killing_acceptor/1,killing_multi_acceptors/1,killing_multi_acceptors2/1,
- several_accepts_in_one_go/1, accept_system_limit/1,
+ several_accepts_in_one_go/1,accept_system_limit/1,accept_inherit/1,
active_once_closed/1, send_timeout/1, send_timeout_active/1,
otp_7731/1, zombie_sockets/1, otp_7816/1, otp_8102/1, wrapping_oct/1,
otp_9389/1]).
@@ -102,6 +102,7 @@ all() ->
accept_timeouts_in_order3, accept_timeouts_mixed,
killing_acceptor, killing_multi_acceptors,
killing_multi_acceptors2, several_accepts_in_one_go, accept_system_limit,
+ accept_inherit,
active_once_closed, send_timeout, send_timeout_active, otp_7731,
wrapping_oct,
zombie_sockets, otp_7816, otp_8102, otp_9389].
@@ -2015,6 +2016,22 @@ open_ports(L) ->
end.
+accept_inherit(Config) when is_list(Config) ->
+ %% Options 'priority' and 'tos' are handled separately in so_priority/1
+ Opts = [{active,true},{nodelay,true},{keepalive,true},{delay_send,true}],
+ Keys = [active,nodelay,keepalive,delay_send],
+ {ok,LS} = gen_tcp:listen(0, Opts),
+ {ok,{{0,0,0,0},PortNum}} = inet:sockname(LS),
+ {ok,S} = gen_tcp:connect("localhost", PortNum, []),
+ {ok,AS} = gen_tcp:accept(LS),
+ {ok,Opts} = inet:getopts(LS, Keys),
+ {ok,Opts} = inet:getopts(AS, Keys),
+ gen_tcp:close(AS),
+ gen_tcp:close(S),
+ gen_tcp:close(LS),
+ ok.
+
+
active_once_closed(suite) ->
[];
active_once_closed(doc) ->

No commit comments for this range

Something went wrong with that request. Please try again.