diff options
author | Ingela Anderton Andin <[email protected]> | 2015-09-10 09:13:50 +0200 |
---|---|---|
committer | Ingela Anderton Andin <[email protected]> | 2015-09-10 09:13:50 +0200 |
commit | 45f29845fea2fa036e03f0faf451ca98813b3112 (patch) | |
tree | 4e3c55305a35454ad20e87783fe7838c5c184389 /lib/inets/src/http_server/httpd_sup.erl | |
parent | 79da6e851e98729d103979ba466d47f4fa4421b2 (diff) | |
parent | 628553c2946649ef1715feacc05e8f75d38ef2e3 (diff) | |
download | otp-45f29845fea2fa036e03f0faf451ca98813b3112.tar.gz otp-45f29845fea2fa036e03f0faf451ca98813b3112.tar.bz2 otp-45f29845fea2fa036e03f0faf451ca98813b3112.zip |
Merge branch 'ia/inets/httpd/tftpd/fd/OTP-12875/OTP-12898' into maint
* ia/inets/httpd/tftpd/fd/OTP-12875/OTP-12898:
inets: Add test suite for socket_wrap feature
inets: Ctify inets_SUITE
inets: tftpd - Mend broken fd option
inets: httpd - Mend broken fd option
Diffstat (limited to 'lib/inets/src/http_server/httpd_sup.erl')
-rw-r--r-- | lib/inets/src/http_server/httpd_sup.erl | 34 |
1 files changed, 27 insertions, 7 deletions
diff --git a/lib/inets/src/http_server/httpd_sup.erl b/lib/inets/src/http_server/httpd_sup.erl index de08624d44..f0b1942e2f 100644 --- a/lib/inets/src/http_server/httpd_sup.erl +++ b/lib/inets/src/http_server/httpd_sup.erl @@ -185,12 +185,16 @@ httpd_child_spec(ConfigFile, AcceptTimeoutDef, DebugDef) -> end. httpd_child_spec(Config, AcceptTimeout, Debug, Addr, Port, Profile) -> - Fd = proplists:get_value(fd, Config, undefined), - case Port == 0 orelse Fd =/= undefined of - true -> - httpd_child_spec_listen(Config, AcceptTimeout, Debug, Addr, Port, Profile); - false -> - httpd_child_spec_nolisten(Config, AcceptTimeout, Debug, Addr, Port, Profile) + case get_fd(Port) of + {ok, Fd} -> + case Port == 0 orelse Fd =/= undefined of + true -> + httpd_child_spec_listen(Config, AcceptTimeout, Debug, Addr, Port, Profile); + false -> + httpd_child_spec_nolisten(Config, AcceptTimeout, Debug, Addr, Port, Profile) + end; + Error -> + Error end. httpd_child_spec_listen(Config, AcceptTimeout, Debug, Addr, Port, Profile) -> @@ -236,7 +240,7 @@ listen(Address, Port, Config) -> SocketType -> case http_transport:start(SocketType) of ok -> - Fd = proplists:get_value(fd, Config), + {ok, Fd} = get_fd(Port), IpFamily = proplists:get_value(ipfamily, Config, inet6fb4), case http_transport:listen(SocketType, Address, Port, Fd, IpFamily) of {ok, ListenSocket} -> @@ -355,3 +359,19 @@ ssl_ca_certificate_file(Config) -> File -> [{cacertfile, File}] end. + +get_fd(0) -> + {ok, undefined}; +get_fd(Port) -> + FdKey = list_to_atom("httpd_" ++ integer_to_list(Port)), + case init:get_argument(FdKey) of + {ok, [[Value]]} -> + case (catch list_to_integer(Value)) of + N when is_integer(N) -> + {ok, N}; + _ -> + {error, {bad_descriptor, Value}} + end; + _ -> + {ok, undefined} + end. |