mirror of
https://github.com/processone/ejabberd.git
synced 2024-11-24 16:23:40 +01:00
Fixed conversion to ezlib
This commit is contained in:
parent
a616123200
commit
862a08e9eb
@ -1739,8 +1739,8 @@ get_conn_type(StateData) ->
|
|||||||
case (StateData#state.sockmod):get_sockmod(StateData#state.socket) of
|
case (StateData#state.sockmod):get_sockmod(StateData#state.socket) of
|
||||||
gen_tcp -> c2s;
|
gen_tcp -> c2s;
|
||||||
tls -> c2s_tls;
|
tls -> c2s_tls;
|
||||||
ejabberd_zlib ->
|
ezlib ->
|
||||||
case ejabberd_zlib:get_sockmod((StateData#state.socket)#socket_state.socket) of
|
case ezlib:get_sockmod((StateData#state.socket)#socket_state.socket) of
|
||||||
gen_tcp -> c2s_compressed;
|
gen_tcp -> c2s_compressed;
|
||||||
tls -> c2s_compressed_tls
|
tls -> c2s_compressed_tls
|
||||||
end;
|
end;
|
||||||
|
@ -104,9 +104,7 @@ starttls(FsmRef, TLSOpts, Data) ->
|
|||||||
gen_server:call(FsmRef, {starttls, TLSOpts, Data}),
|
gen_server:call(FsmRef, {starttls, TLSOpts, Data}),
|
||||||
FsmRef.
|
FsmRef.
|
||||||
|
|
||||||
compress(FsmRef) ->
|
compress(FsmRef) -> compress(FsmRef, undefined).
|
||||||
gen_server:call(FsmRef, compress),
|
|
||||||
FsmRef.
|
|
||||||
|
|
||||||
compress(FsmRef, Data) ->
|
compress(FsmRef, Data) ->
|
||||||
gen_server:call(FsmRef, {compress, Data}), FsmRef.
|
gen_server:call(FsmRef, {compress, Data}), FsmRef.
|
||||||
@ -188,22 +186,9 @@ handle_call({starttls, TLSOpts, Data}, _From, State) ->
|
|||||||
State#state{socket = TLSSocket, sockmod = tls},
|
State#state{socket = TLSSocket, sockmod = tls},
|
||||||
?HIBERNATE_TIMEOUT};
|
?HIBERNATE_TIMEOUT};
|
||||||
|
|
||||||
handle_call(compress, _From, State) ->
|
|
||||||
{ok, ZlibSocket} = ejabberd_zlib:enable_zlib(
|
|
||||||
State#state.sockmod,
|
|
||||||
State#state.socket),
|
|
||||||
ejabberd_receiver:compress(State#state.receiver, ZlibSocket),
|
|
||||||
Reply = ok,
|
|
||||||
{reply, Reply, State#state{socket = ZlibSocket, sockmod = ejabberd_zlib},
|
|
||||||
?HIBERNATE_TIMEOUT};
|
|
||||||
|
|
||||||
handle_call({compress, Data}, _From, State) ->
|
handle_call({compress, Data}, _From, State) ->
|
||||||
{ok, ZlibSocket} = ejabberd_zlib:enable_zlib(
|
{ok, ZlibSocket} =
|
||||||
State#state.sockmod,
|
ejabberd_receiver:compress(State#state.receiver, Data),
|
||||||
State#state.socket),
|
|
||||||
ejabberd_receiver:compress(State#state.receiver, ZlibSocket),
|
|
||||||
catch (State#state.sockmod):send(
|
|
||||||
State#state.socket, Data),
|
|
||||||
Reply = ok,
|
Reply = ok,
|
||||||
{reply, Reply,
|
{reply, Reply,
|
||||||
State#state{socket = ZlibSocket, sockmod = ezlib},
|
State#state{socket = ZlibSocket, sockmod = ezlib},
|
||||||
|
@ -53,7 +53,7 @@
|
|||||||
|
|
||||||
-type sockmod() :: ejabberd_http_poll |
|
-type sockmod() :: ejabberd_http_poll |
|
||||||
ejabberd_http_bind |
|
ejabberd_http_bind |
|
||||||
gen_tcp | tls | ejabberd_zlib.
|
gen_tcp | tls | ezlib.
|
||||||
-type receiver() :: pid () | atom().
|
-type receiver() :: pid () | atom().
|
||||||
-type socket() :: pid() | inet:socket() |
|
-type socket() :: pid() | inet:socket() |
|
||||||
tls:tls_socket() |
|
tls:tls_socket() |
|
||||||
@ -160,12 +160,7 @@ starttls(SocketData, TLSOpts, Data) ->
|
|||||||
send(SocketData, Data),
|
send(SocketData, Data),
|
||||||
SocketData#socket_state{socket = TLSSocket, sockmod = tls}.
|
SocketData#socket_state{socket = TLSSocket, sockmod = tls}.
|
||||||
|
|
||||||
compress(SocketData) ->
|
compress(SocketData) -> compress(SocketData, undefined).
|
||||||
{ok, ZlibSocket} = ejabberd_zlib:enable_zlib(
|
|
||||||
SocketData#socket_state.sockmod,
|
|
||||||
SocketData#socket_state.socket),
|
|
||||||
ejabberd_receiver:compress(SocketData#socket_state.receiver, ZlibSocket),
|
|
||||||
SocketData#socket_state{socket = ZlibSocket, sockmod = ejabberd_zlib}.
|
|
||||||
|
|
||||||
compress(SocketData, Data) ->
|
compress(SocketData, Data) ->
|
||||||
{ok, ZlibSocket} =
|
{ok, ZlibSocket} =
|
||||||
@ -181,7 +176,8 @@ reset_stream(SocketData)
|
|||||||
when is_atom(SocketData#socket_state.receiver) ->
|
when is_atom(SocketData#socket_state.receiver) ->
|
||||||
(SocketData#socket_state.receiver):reset_stream(SocketData#socket_state.socket).
|
(SocketData#socket_state.receiver):reset_stream(SocketData#socket_state.socket).
|
||||||
|
|
||||||
%% sockmod=gen_tcp|tls|ejabberd_zlib
|
-spec send(socket_state(), iodata()) -> ok.
|
||||||
|
|
||||||
send(SocketData, Data) ->
|
send(SocketData, Data) ->
|
||||||
case catch (SocketData#socket_state.sockmod):send(
|
case catch (SocketData#socket_state.sockmod):send(
|
||||||
SocketData#socket_state.socket, Data) of
|
SocketData#socket_state.socket, Data) of
|
||||||
|
Loading…
Reference in New Issue
Block a user