aboutsummaryrefslogtreecommitdiffstats
path: root/lib/inets/src/http_server/httpd_sup.erl
diff options
context:
space:
mode:
authorMicael Karlberg <[email protected]>2011-04-12 18:12:27 +0200
committerMicael Karlberg <[email protected]>2011-04-12 18:12:27 +0200
commitf9346bbd247b8fcef5e4f68e94b429cb39f9d4ac (patch)
tree08a69b3f5050ab97e1571b99bff1a494780bccd2 /lib/inets/src/http_server/httpd_sup.erl
parenta0c01db642374fb9fbbbb47263929f1e442e20d7 (diff)
parentd0f399b4b08b5cd9fb54bec5d71c82b560199c86 (diff)
downloadotp-f9346bbd247b8fcef5e4f68e94b429cb39f9d4ac.tar.gz
otp-f9346bbd247b8fcef5e4f68e94b429cb39f9d4ac.tar.bz2
otp-f9346bbd247b8fcef5e4f68e94b429cb39f9d4ac.zip
Merge branch 'bmk/inets/httpd/extended_fd/OTP-9202' into bmk/inets/inet56_integration
OTP-9202
Diffstat (limited to 'lib/inets/src/http_server/httpd_sup.erl')
-rw-r--r--lib/inets/src/http_server/httpd_sup.erl45
1 files changed, 27 insertions, 18 deletions
diff --git a/lib/inets/src/http_server/httpd_sup.erl b/lib/inets/src/http_server/httpd_sup.erl
index b248c9bcf0..d028a19bf0 100644
--- a/lib/inets/src/http_server/httpd_sup.erl
+++ b/lib/inets/src/http_server/httpd_sup.erl
@@ -182,24 +182,32 @@ httpd_child_spec(ConfigFile, AcceptTimeout, Debug) ->
Error
end.
-httpd_child_spec(Config, AcceptTimeout, Debug, Addr, 0) ->
- case start_listen(Addr, 0, Config) of
- {Pid, {NewPort, NewConfig, ListenSocket}} ->
- Name = {httpd_instance_sup, Addr, NewPort},
- StartFunc = {httpd_instance_sup, start_link,
- [NewConfig, AcceptTimeout,
- {Pid, ListenSocket}, Debug]},
- Restart = permanent,
- Shutdown = infinity,
- Modules = [httpd_instance_sup],
- Type = supervisor,
- {Name, StartFunc, Restart, Shutdown, Type, Modules};
- {Pid, {error, Reason}} ->
- exit(Pid, normal),
- {error, Reason}
- end;
-
httpd_child_spec(Config, AcceptTimeout, Debug, Addr, Port) ->
+ case Port == 0 orelse proplists:is_defined(fd, Config) of
+ true ->
+ httpd_child_spec_listen(Config, AcceptTimeout, Debug, Addr, Port);
+ false ->
+ httpd_child_spec_nolisten(Config, AcceptTimeout, Debug, Addr, Port)
+ end.
+
+httpd_child_spec_listen(Config, AcceptTimeout, Debug, Addr, Port) ->
+ case start_listen(Addr, Port, Config) of
+ {Pid, {NewPort, NewConfig, ListenSocket}} ->
+ Name = {httpd_instance_sup, Addr, NewPort},
+ StartFunc = {httpd_instance_sup, start_link,
+ [NewConfig, AcceptTimeout,
+ {Pid, ListenSocket}, Debug]},
+ Restart = permanent,
+ Shutdown = infinity,
+ Modules = [httpd_instance_sup],
+ Type = supervisor,
+ {Name, StartFunc, Restart, Shutdown, Type, Modules};
+ {Pid, {error, Reason}} ->
+ exit(Pid, normal),
+ {error, Reason}
+ end.
+
+httpd_child_spec_nolisten(Config, AcceptTimeout, Debug, Addr, Port) ->
Name = {httpd_instance_sup, Addr, Port},
StartFunc = {httpd_instance_sup, start_link,
[Config, AcceptTimeout, Debug]},
@@ -224,7 +232,8 @@ listen(Address, Port, Config) ->
SocketType = proplists:get_value(socket_type, Config, ip_comm),
case http_transport:start(SocketType) of
ok ->
- case http_transport:listen(SocketType, Address, Port) of
+ Fd = proplists:get_value(fd, Config),
+ case http_transport:listen(SocketType, Address, Port, Fd) of
{ok, ListenSocket} ->
NewConfig = proplists:delete(port, Config),
{ok, NewPort} = inet:port(ListenSocket),