mirror of
https://github.com/processone/ejabberd.git
synced 2024-11-20 16:15:59 +01:00
Fix several refactoring related bugs
This commit is contained in:
parent
4c2d2bd4e9
commit
299a0f823a
@ -292,7 +292,7 @@ wait_for_stream({xmlstreamstart, _Name, Attrs}, StateData) ->
|
||||
case lists:member(Server, ?MYHOSTS) of
|
||||
true ->
|
||||
Lang = case xml:get_attr_s(<<"xml:lang">>, Attrs) of
|
||||
Lang1 when length(Lang1) =< 35 ->
|
||||
Lang1 when size(Lang1) =< 35 ->
|
||||
%% As stated in BCP47, 4.4.1:
|
||||
%% Protocols or specifications that
|
||||
%% specify limited buffer sizes for
|
||||
|
@ -358,13 +358,13 @@ do_route(OrigFrom, OrigTo, OrigPacket) ->
|
||||
undefined ->
|
||||
case [R || R <- Rs, node(R#route.pid) == node()] of
|
||||
[] ->
|
||||
R = lists:nth(erlang:phash(Value, str:len(Rs)), Rs),
|
||||
R = lists:nth(erlang:phash(Value, length(Rs)), Rs),
|
||||
Pid = R#route.pid,
|
||||
if is_pid(Pid) -> Pid ! {route, From, To, Packet};
|
||||
true -> drop
|
||||
end;
|
||||
LRs ->
|
||||
R = lists:nth(erlang:phash(Value, str:len(LRs)),
|
||||
R = lists:nth(erlang:phash(Value, length(LRs)),
|
||||
LRs),
|
||||
Pid = R#route.pid,
|
||||
case R#route.local_hint of
|
||||
@ -375,7 +375,7 @@ do_route(OrigFrom, OrigTo, OrigPacket) ->
|
||||
end;
|
||||
_ ->
|
||||
SRs = lists:ukeysort(#route.local_hint, Rs),
|
||||
R = lists:nth(erlang:phash(Value, str:len(SRs)), SRs),
|
||||
R = lists:nth(erlang:phash(Value, length(SRs)), SRs),
|
||||
Pid = R#route.pid,
|
||||
if is_pid(Pid) -> Pid ! {route, From, To, Packet};
|
||||
true -> drop
|
||||
|
@ -50,16 +50,14 @@
|
||||
-include("ejabberd.hrl").
|
||||
-include("jlib.hrl").
|
||||
|
||||
-type sockmod() :: ejabberd_http_poll | ejabberd_bosh |
|
||||
ejabberd_http_bind | ejabberd_http_bindjson |
|
||||
ejabberd_http_ws | ejabberd_http_wsjson |
|
||||
-type sockmod() :: ejabberd_http_poll |
|
||||
ejabberd_http_bind |
|
||||
gen_tcp | tls | ejabberd_zlib.
|
||||
-type receiver() :: pid () | atom().
|
||||
-type socket() :: pid() | inet:socket() |
|
||||
tls:tls_socket() |
|
||||
ejabberd_zlib:zlib_socket() |
|
||||
ejabberd_bosh:bosh_socket() |
|
||||
ejabberd_http_ws:ws_socket() |
|
||||
ejabberd_http_bind:bind_socket() |
|
||||
ejabberd_http_poll:poll_socket().
|
||||
|
||||
-record(socket_state, {sockmod = gen_tcp :: sockmod(),
|
||||
|
@ -101,7 +101,7 @@ handle(Host, Module, Function, Opts, From, To, IQ) ->
|
||||
process_iq(Host, Module, Function, From, To, IQ);
|
||||
{one_queue, Pid} -> Pid ! {process_iq, From, To, IQ};
|
||||
{queues, Pids} ->
|
||||
Pid = lists:nth(erlang:phash(now(), str:len(Pids)),
|
||||
Pid = lists:nth(erlang:phash(now(), length(Pids)),
|
||||
Pids),
|
||||
Pid ! {process_iq, From, To, IQ};
|
||||
parallel ->
|
||||
|
@ -35,8 +35,8 @@
|
||||
stop/1]).
|
||||
|
||||
%% Hooks:
|
||||
-export([user_send_packet/4,
|
||||
user_receive_packet/5,
|
||||
-export([user_send_packet/3,
|
||||
user_receive_packet/4,
|
||||
iq_handler2/3,
|
||||
iq_handler1/3,
|
||||
remove_connection/4,
|
||||
@ -127,15 +127,15 @@ iq_handler(From, _To, #iq{type=set, sub_el = #xmlel{name = Operation, children
|
||||
iq_handler(_From, _To, IQ, _CC)->
|
||||
IQ#iq{type=error, sub_el = [?ERR_NOT_ALLOWED]}.
|
||||
|
||||
user_send_packet(_Debug, From, _To, Packet) ->
|
||||
user_send_packet(From, _To, Packet) ->
|
||||
check_and_forward(From, Packet, sent).
|
||||
|
||||
%% Only make carbon copies if the original destination was not a bare jid.
|
||||
%% If the original destination was a bare jid, the message is going to be delivered to all
|
||||
%% connected resources anyway. Avoid duplicate delivery. "XEP-0280 : 3.5 Receiving Messages"
|
||||
user_receive_packet(_Debug, JID, _From, #jid{resource=Resource} = _To, Packet) when Resource /= <<>> ->
|
||||
user_receive_packet(JID, _From, #jid{resource=Resource} = _To, Packet) when Resource /= <<>> ->
|
||||
check_and_forward(JID, Packet, received);
|
||||
user_receive_packet(_Debug, _JID, _From, _To, _Packet) ->
|
||||
user_receive_packet(_JID, _From, _To, _Packet) ->
|
||||
ok.
|
||||
|
||||
% verifier si le trafic est local
|
||||
|
@ -830,9 +830,10 @@ webadmin_user_parse_query(Acc, _Action, _User, _Server,
|
||||
count_offline_messages(LUser, LServer) ->
|
||||
Username = ejabberd_odbc:escape(LUser),
|
||||
case catch odbc_queries:count_records_where(
|
||||
LServer, "spool", "where username='" ++ Username ++ "'") of
|
||||
LServer, "spool",
|
||||
<<"where username='", Username/binary, "'">>) of
|
||||
{selected, [_], [{Res}]} ->
|
||||
list_to_integer(Res);
|
||||
jlib:binary_to_integer(Res);
|
||||
_ ->
|
||||
0
|
||||
end.
|
||||
|
@ -822,25 +822,5 @@ old_integer_to_hex(I) when I >= 16 ->
|
||||
N = trunc(I / 16),
|
||||
old_integer_to_hex(N) ++ old_integer_to_hex(I rem 16).
|
||||
|
||||
% The following code is mostly taken from yaws_ssl.erl
|
||||
|
||||
toupper(C) when C >= $a andalso C =< $z -> C - 32;
|
||||
toupper(C) -> C.
|
||||
|
||||
tolower(C) when C >= $A andalso C =< $Z -> C + 32;
|
||||
tolower(C) -> C.
|
||||
|
||||
normalize_header_name(Name) ->
|
||||
normalize_header_name(Name, [], true).
|
||||
|
||||
normalize_header_name(<<"">>, Acc, _) ->
|
||||
iolist_to_binary(Acc);
|
||||
normalize_header_name(<<"-", Rest/binary>>, Acc, _) ->
|
||||
normalize_header_name(Rest, [Acc, "-"], true);
|
||||
normalize_header_name(<<C:8, Rest/binary>>, Acc, true) ->
|
||||
normalize_header_name(Rest, [Acc, toupper(C)], false);
|
||||
normalize_header_name(<<C:8, Rest/binary>>, Acc, false) ->
|
||||
normalize_header_name(Rest, [Acc, tolower(C)], false).
|
||||
|
||||
%% strip_spaces(String, left) ->
|
||||
%% drop_spaces(String);
|
||||
|
Loading…
Reference in New Issue
Block a user