From 0095f4fbf9c97dad563d999e5fa13afcb478f893 Mon Sep 17 00:00:00 2001 From: Badlop Date: Mon, 19 Oct 2009 14:53:39 +0000 Subject: [PATCH] Provide send_timeout_close option in TCP only in R13B or higher (EJAB-926) SVN Revision: 2682 --- src/ejabberd_listener.erl | 7 +++++-- src/ejabberd_s2s_out.erl | 6 +++++- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/ejabberd_listener.erl b/src/ejabberd_listener.erl index 7d5ca2fa8..bfed0e336 100644 --- a/src/ejabberd_listener.erl +++ b/src/ejabberd_listener.erl @@ -127,15 +127,18 @@ init_udp(PortIP, Module, Opts, SockOpts, Port, IPS) -> end. init_tcp(PortIP, Module, Opts, SockOpts, Port, IPS) -> + SockOpts2 = case erlang:system_info(otp_release) >= "R13B" of + true -> [{send_timeout_close, true} | SockOpts]; + false -> [] + end, Res = gen_tcp:listen(Port, [binary, {packet, 0}, {active, false}, {reuseaddr, true}, {nodelay, true}, {send_timeout, ?TCP_SEND_TIMEOUT}, - {send_timeout_close, true}, {keepalive, true} | - SockOpts]), + SockOpts2]), case Res of {ok, ListenSocket} -> %% Inform my parent that this port was opened succesfully diff --git a/src/ejabberd_s2s_out.erl b/src/ejabberd_s2s_out.erl index e601ff03f..261562f8c 100644 --- a/src/ejabberd_s2s_out.erl +++ b/src/ejabberd_s2s_out.erl @@ -257,11 +257,15 @@ open_socket1(Host, Port) -> open_socket2(Type, Addr, Port) -> ?DEBUG("s2s_out: connecting to ~p:~p~n", [Addr, Port]), Timeout = outgoing_s2s_timeout(), + SockOpts = case erlang:system_info(otp_release) >= "R13B" of + true -> [{send_timeout_close, true}]; + false -> [] + end, case (catch ejabberd_socket:connect(Addr, Port, [binary, {packet, 0}, {send_timeout, ?TCP_SEND_TIMEOUT}, {send_timeout_close, true}, - {active, false}, Type], + {active, false}, Type | SockOpts], Timeout)) of {ok, _Socket} = R -> R; {error, Reason} = R ->