Changeset View
Changeset View
Standalone View
Standalone View
apps/kolab_guam/src/kolab_guam_listener.erl
Show First 20 Lines • Show All 69 Lines • ▼ Show 20 Lines | |||||
listen_options(Iface, Hostname) -> | listen_options(Iface, Hostname) -> | ||||
{ ok, Ifaces } = inet:getifaddrs(), | { ok, Ifaces } = inet:getifaddrs(), | ||||
case proplists:get_value(Iface, Ifaces) of | case proplists:get_value(Iface, Ifaces) of | ||||
undefined -> listen_options(none, Hostname); | undefined -> listen_options(none, Hostname); | ||||
Info -> Addr = proplists:get_value(addr, Info, none), | Info -> Addr = proplists:get_value(addr, Info, none), | ||||
listen_options(none, Addr) | listen_options(none, Addr) | ||||
end. | end. | ||||
default_listen_options() -> [ { reuseaddr, true }, {active, false}, inet6 ]. | default_listen_options() -> [ { reuseaddr, true }, {active, false} | ipv6_opts() ]. | ||||
ipv6_opts() -> | |||||
case check_for_ipv6(inet:getifaddrs()) of | |||||
true -> [inet6]; | |||||
_ -> [] | |||||
end. | |||||
check_for_ipv6({ok, Ifaddrs}) -> check_for_ipv6(Ifaddrs); | |||||
check_for_ipv6([]) -> false; | |||||
check_for_ipv6([{_iface, Attrs}|Ifaddrs]) -> | |||||
Addrs = proplists:get_all_values(addr, Attrs), | |||||
case lists:any(fun(Addr) -> size(Addr) == 8 end, Addrs) of | |||||
true -> true; | |||||
_ -> check_for_ipv6(Ifaddrs) | |||||
end; | |||||
check_for_ipv6(_) -> false. | |||||
create_initial_listeners(ListenerPoolSize, PID) when is_pid(PID) -> | create_initial_listeners(ListenerPoolSize, PID) when is_pid(PID) -> | ||||
lager:debug("Creating session pool of size ~p for listener ~p", [ListenerPoolSize, PID]), | lager:debug("Creating session pool of size ~p for listener ~p", [ListenerPoolSize, PID]), | ||||
[ supervisor:start_child(PID, []) || _ <- lists:seq(1, ListenerPoolSize) ]. | [ supervisor:start_child(PID, []) || _ <- lists:seq(1, ListenerPoolSize) ]. | ||||
cleanup(Socket) -> | cleanup(Socket) -> | ||||
process_flag(trap_exit, true), | process_flag(trap_exit, true), | ||||
receive | receive | ||||
Show All 10 Lines |