25
1
mirror of https://github.com/processone/ejabberd.git synced 2024-11-22 16:20:52 +01:00

Avoid generation of excessive records

This commit is contained in:
Evgeniy Khramtsov 2014-09-13 22:54:07 +04:00
parent c90786527e
commit 72fd353988
4 changed files with 52 additions and 180 deletions

View File

@ -1511,7 +1511,7 @@ client_state_master(Config) ->
Peer = ?config(slave, Config), Peer = ?config(slave, Config),
Presence = #presence{to = Peer}, Presence = #presence{to = Peer},
Message = #message{to = Peer, thread = <<"1">>, Message = #message{to = Peer, thread = <<"1">>,
sub_els = [#chatstate_active{}]}, sub_els = [#chatstate{type = active}]},
wait_for_slave(Config), wait_for_slave(Config),
%% Should be queued (but see below): %% Should be queued (but see below):
send(Config, Presence), send(Config, Presence),
@ -1531,16 +1531,16 @@ client_state_master(Config) ->
client_state_slave(Config) -> client_state_slave(Config) ->
true = ?config(csi, Config), true = ?config(csi, Config),
Peer = ?config(master, Config), Peer = ?config(master, Config),
send(Config, #csi_inactive{}), send(Config, #csi{type = inactive}),
wait_for_master(Config), wait_for_master(Config),
#presence{from = Peer, sub_els = [#delay{}]} = recv(), #presence{from = Peer, sub_els = [#delay{}]} = recv(),
#message{from = Peer, thread = <<"1">>, sub_els = [#chatstate_active{}], #message{from = Peer, thread = <<"1">>, sub_els = [#chatstate{type = active}],
body = [#text{data = <<"body">>}]} = recv(), body = [#text{data = <<"body">>}]} = recv(),
wait_for_master(Config), wait_for_master(Config),
send(Config, #csi_active{}), send(Config, #csi{type = active}),
?recv2(#presence{from = Peer, type = unavailable, sub_els = [#delay{}]}, ?recv2(#presence{from = Peer, type = unavailable, sub_els = [#delay{}]},
#message{from = Peer, thread = <<"1">>, #message{from = Peer, thread = <<"1">>,
sub_els = [#chatstate_active{}]}), sub_els = [#chatstate{type = active}]}),
disconnect(Config). disconnect(Config).
%%%=================================================================== %%%===================================================================

View File

@ -1902,23 +1902,23 @@ encode({pubsub, _, _, _, _, _, _, _, _} = Pubsub) ->
encode({shim, _} = Headers) -> encode({shim, _} = Headers) ->
encode_shim_headers(Headers, encode_shim_headers(Headers,
[{<<"xmlns">>, <<"http://jabber.org/protocol/shim">>}]); [{<<"xmlns">>, <<"http://jabber.org/protocol/shim">>}]);
encode({chatstate_active} = Active) -> encode({chatstate, active} = Active) ->
encode_chatstate_active(Active, encode_chatstate_active(Active,
[{<<"xmlns">>, [{<<"xmlns">>,
<<"http://jabber.org/protocol/chatstates">>}]); <<"http://jabber.org/protocol/chatstates">>}]);
encode({chatstate_composing} = Composing) -> encode({chatstate, composing} = Composing) ->
encode_chatstate_composing(Composing, encode_chatstate_composing(Composing,
[{<<"xmlns">>, [{<<"xmlns">>,
<<"http://jabber.org/protocol/chatstates">>}]); <<"http://jabber.org/protocol/chatstates">>}]);
encode({chatstate_gone} = Gone) -> encode({chatstate, gone} = Gone) ->
encode_chatstate_gone(Gone, encode_chatstate_gone(Gone,
[{<<"xmlns">>, [{<<"xmlns">>,
<<"http://jabber.org/protocol/chatstates">>}]); <<"http://jabber.org/protocol/chatstates">>}]);
encode({chatstate_inactive} = Inactive) -> encode({chatstate, inactive} = Inactive) ->
encode_chatstate_inactive(Inactive, encode_chatstate_inactive(Inactive,
[{<<"xmlns">>, [{<<"xmlns">>,
<<"http://jabber.org/protocol/chatstates">>}]); <<"http://jabber.org/protocol/chatstates">>}]);
encode({chatstate_paused} = Paused) -> encode({chatstate, paused} = Paused) ->
encode_chatstate_paused(Paused, encode_chatstate_paused(Paused,
[{<<"xmlns">>, [{<<"xmlns">>,
<<"http://jabber.org/protocol/chatstates">>}]); <<"http://jabber.org/protocol/chatstates">>}]);
@ -1994,10 +1994,10 @@ encode({carbons_sent, _} = Sent) ->
[{<<"xmlns">>, <<"urn:xmpp:carbons:2">>}]); [{<<"xmlns">>, <<"urn:xmpp:carbons:2">>}]);
encode({feature_csi, _} = Csi) -> encode({feature_csi, _} = Csi) ->
encode_feature_csi(Csi, []); encode_feature_csi(Csi, []);
encode({csi_active} = Active) -> encode({csi, active} = Active) ->
encode_csi_active(Active, encode_csi_active(Active,
[{<<"xmlns">>, <<"urn:xmpp:csi:0">>}]); [{<<"xmlns">>, <<"urn:xmpp:csi:0">>}]);
encode({csi_inactive} = Inactive) -> encode({csi, inactive} = Inactive) ->
encode_csi_inactive(Inactive, encode_csi_inactive(Inactive,
[{<<"xmlns">>, <<"urn:xmpp:csi:0">>}]); [{<<"xmlns">>, <<"urn:xmpp:csi:0">>}]);
encode({feature_sm, _} = Sm) -> encode({feature_sm, _} = Sm) ->
@ -2158,15 +2158,15 @@ get_ns({pubsub, _, _, _, _, _, _, _, _}) ->
<<"http://jabber.org/protocol/pubsub">>; <<"http://jabber.org/protocol/pubsub">>;
get_ns({shim, _}) -> get_ns({shim, _}) ->
<<"http://jabber.org/protocol/shim">>; <<"http://jabber.org/protocol/shim">>;
get_ns({chatstate_active}) -> get_ns({chatstate, active}) ->
<<"http://jabber.org/protocol/chatstates">>; <<"http://jabber.org/protocol/chatstates">>;
get_ns({chatstate_composing}) -> get_ns({chatstate, composing}) ->
<<"http://jabber.org/protocol/chatstates">>; <<"http://jabber.org/protocol/chatstates">>;
get_ns({chatstate_gone}) -> get_ns({chatstate, gone}) ->
<<"http://jabber.org/protocol/chatstates">>; <<"http://jabber.org/protocol/chatstates">>;
get_ns({chatstate_inactive}) -> get_ns({chatstate, inactive}) ->
<<"http://jabber.org/protocol/chatstates">>; <<"http://jabber.org/protocol/chatstates">>;
get_ns({chatstate_paused}) -> get_ns({chatstate, paused}) ->
<<"http://jabber.org/protocol/chatstates">>; <<"http://jabber.org/protocol/chatstates">>;
get_ns({delay, _, _}) -> <<"urn:xmpp:delay">>; get_ns({delay, _, _}) -> <<"urn:xmpp:delay">>;
get_ns({legacy_delay, _, _}) -> <<"jabber:x:delay">>; get_ns({legacy_delay, _, _}) -> <<"jabber:x:delay">>;
@ -2200,8 +2200,8 @@ get_ns({carbons_received, _}) ->
<<"urn:xmpp:carbons:2">>; <<"urn:xmpp:carbons:2">>;
get_ns({carbons_sent, _}) -> <<"urn:xmpp:carbons:2">>; get_ns({carbons_sent, _}) -> <<"urn:xmpp:carbons:2">>;
get_ns({feature_csi, _}) -> <<"urn:xmpp:csi:0">>; get_ns({feature_csi, _}) -> <<"urn:xmpp:csi:0">>;
get_ns({csi_active}) -> <<"urn:xmpp:csi:0">>; get_ns({csi, active}) -> <<"urn:xmpp:csi:0">>;
get_ns({csi_inactive}) -> <<"urn:xmpp:csi:0">>; get_ns({csi, inactive}) -> <<"urn:xmpp:csi:0">>;
get_ns(_) -> <<>>. get_ns(_) -> <<>>.
dec_int(Val) -> dec_int(Val, infinity, infinity). dec_int(Val) -> dec_int(Val, infinity, infinity).
@ -2359,11 +2359,7 @@ pp(pubsub, 8) ->
[subscriptions, affiliations, publish, subscribe, [subscriptions, affiliations, publish, subscribe,
unsubscribe, options, items, retract]; unsubscribe, options, items, retract];
pp(shim, 1) -> [headers]; pp(shim, 1) -> [headers];
pp(chatstate_active, 0) -> []; pp(chatstate, 1) -> [type];
pp(chatstate_composing, 0) -> [];
pp(chatstate_gone, 0) -> [];
pp(chatstate_inactive, 0) -> [];
pp(chatstate_paused, 0) -> [];
pp(delay, 2) -> [stamp, from]; pp(delay, 2) -> [stamp, from];
pp(legacy_delay, 2) -> [stamp, from]; pp(legacy_delay, 2) -> [stamp, from];
pp(streamhost, 3) -> [jid, host, port]; pp(streamhost, 3) -> [jid, host, port];
@ -2391,8 +2387,7 @@ pp(carbons_private, 0) -> [];
pp(carbons_received, 1) -> [forwarded]; pp(carbons_received, 1) -> [forwarded];
pp(carbons_sent, 1) -> [forwarded]; pp(carbons_sent, 1) -> [forwarded];
pp(feature_csi, 1) -> [xmlns]; pp(feature_csi, 1) -> [xmlns];
pp(csi_active, 0) -> []; pp(csi, 1) -> [type];
pp(csi_inactive, 0) -> [];
pp(feature_sm, 1) -> [xmlns]; pp(feature_sm, 1) -> [xmlns];
pp(sm_enable, 3) -> [max, resume, xmlns]; pp(sm_enable, 3) -> [max, resume, xmlns];
pp(sm_enabled, 5) -> [id, location, max, resume, xmlns]; pp(sm_enabled, 5) -> [id, location, max, resume, xmlns];
@ -3365,18 +3360,18 @@ encode_feature_sm_attr_xmlns(_val, _acc) ->
decode_csi_inactive(__TopXMLNS, __IgnoreEls, decode_csi_inactive(__TopXMLNS, __IgnoreEls,
{xmlel, <<"inactive">>, _attrs, _els}) -> {xmlel, <<"inactive">>, _attrs, _els}) ->
{csi_inactive}. {csi, inactive}.
encode_csi_inactive({csi_inactive}, _xmlns_attrs) -> encode_csi_inactive({csi, inactive}, _xmlns_attrs) ->
_els = [], _els = [],
_attrs = _xmlns_attrs, _attrs = _xmlns_attrs,
{xmlel, <<"inactive">>, _attrs, _els}. {xmlel, <<"inactive">>, _attrs, _els}.
decode_csi_active(__TopXMLNS, __IgnoreEls, decode_csi_active(__TopXMLNS, __IgnoreEls,
{xmlel, <<"active">>, _attrs, _els}) -> {xmlel, <<"active">>, _attrs, _els}) ->
{csi_active}. {csi, active}.
encode_csi_active({csi_active}, _xmlns_attrs) -> encode_csi_active({csi, active}, _xmlns_attrs) ->
_els = [], _els = [],
_attrs = _xmlns_attrs, _attrs = _xmlns_attrs,
{xmlel, <<"active">>, _attrs, _els}. {xmlel, <<"active">>, _attrs, _els}.
@ -5500,9 +5495,9 @@ encode_delay_attr_from(_val, _acc) ->
decode_chatstate_paused(__TopXMLNS, __IgnoreEls, decode_chatstate_paused(__TopXMLNS, __IgnoreEls,
{xmlel, <<"paused">>, _attrs, _els}) -> {xmlel, <<"paused">>, _attrs, _els}) ->
{chatstate_paused}. {chatstate, paused}.
encode_chatstate_paused({chatstate_paused}, encode_chatstate_paused({chatstate, paused},
_xmlns_attrs) -> _xmlns_attrs) ->
_els = [], _els = [],
_attrs = _xmlns_attrs, _attrs = _xmlns_attrs,
@ -5510,9 +5505,9 @@ encode_chatstate_paused({chatstate_paused},
decode_chatstate_inactive(__TopXMLNS, __IgnoreEls, decode_chatstate_inactive(__TopXMLNS, __IgnoreEls,
{xmlel, <<"inactive">>, _attrs, _els}) -> {xmlel, <<"inactive">>, _attrs, _els}) ->
{chatstate_inactive}. {chatstate, inactive}.
encode_chatstate_inactive({chatstate_inactive}, encode_chatstate_inactive({chatstate, inactive},
_xmlns_attrs) -> _xmlns_attrs) ->
_els = [], _els = [],
_attrs = _xmlns_attrs, _attrs = _xmlns_attrs,
@ -5520,18 +5515,19 @@ encode_chatstate_inactive({chatstate_inactive},
decode_chatstate_gone(__TopXMLNS, __IgnoreEls, decode_chatstate_gone(__TopXMLNS, __IgnoreEls,
{xmlel, <<"gone">>, _attrs, _els}) -> {xmlel, <<"gone">>, _attrs, _els}) ->
{chatstate_gone}. {chatstate, gone}.
encode_chatstate_gone({chatstate_gone}, _xmlns_attrs) -> encode_chatstate_gone({chatstate, gone},
_xmlns_attrs) ->
_els = [], _els = [],
_attrs = _xmlns_attrs, _attrs = _xmlns_attrs,
{xmlel, <<"gone">>, _attrs, _els}. {xmlel, <<"gone">>, _attrs, _els}.
decode_chatstate_composing(__TopXMLNS, __IgnoreEls, decode_chatstate_composing(__TopXMLNS, __IgnoreEls,
{xmlel, <<"composing">>, _attrs, _els}) -> {xmlel, <<"composing">>, _attrs, _els}) ->
{chatstate_composing}. {chatstate, composing}.
encode_chatstate_composing({chatstate_composing}, encode_chatstate_composing({chatstate, composing},
_xmlns_attrs) -> _xmlns_attrs) ->
_els = [], _els = [],
_attrs = _xmlns_attrs, _attrs = _xmlns_attrs,
@ -5539,9 +5535,9 @@ encode_chatstate_composing({chatstate_composing},
decode_chatstate_active(__TopXMLNS, __IgnoreEls, decode_chatstate_active(__TopXMLNS, __IgnoreEls,
{xmlel, <<"active">>, _attrs, _els}) -> {xmlel, <<"active">>, _attrs, _els}) ->
{chatstate_active}. {chatstate, active}.
encode_chatstate_active({chatstate_active}, encode_chatstate_active({chatstate, active},
_xmlns_attrs) -> _xmlns_attrs) ->
_els = [], _els = [],
_attrs = _xmlns_attrs, _attrs = _xmlns_attrs,

View File

@ -1,6 +1,10 @@
%% Created automatically by XML generator (xml_gen.erl) %% Created automatically by XML generator (xml_gen.erl)
%% Source: xmpp_codec.spec %% Source: xmpp_codec.spec
-record(chatstate, {type :: active | composing | gone | inactive | paused}).
-record(csi, {type :: active | inactive}).
-record(feature_register, {}). -record(feature_register, {}).
-record(sasl_success, {text :: any()}). -record(sasl_success, {text :: any()}).
@ -8,8 +12,6 @@
-record(text, {lang :: binary(), -record(text, {lang :: binary(),
data :: binary()}). data :: binary()}).
-record(chatstate_paused, {}).
-record(streamhost, {jid :: any(), -record(streamhost, {jid :: any(),
host :: binary(), host :: binary(),
port = 1080 :: non_neg_integer()}). port = 1080 :: non_neg_integer()}).
@ -26,8 +28,6 @@
jid :: any(), jid :: any(),
subid :: binary()}). subid :: binary()}).
-record(csi_inactive, {}).
-record(ping, {}). -record(ping, {}).
-record(delay, {stamp :: any(), -record(delay, {stamp :: any(),
@ -61,8 +61,6 @@
resume = false :: any(), resume = false :: any(),
xmlns :: binary()}). xmlns :: binary()}).
-record(chatstate_gone, {}).
-record(starttls_failure, {}). -record(starttls_failure, {}).
-record(sasl_challenge, {text :: any()}). -record(sasl_challenge, {text :: any()}).
@ -129,13 +127,9 @@
-record(sasl_response, {text :: any()}). -record(sasl_response, {text :: any()}).
-record(chatstate_inactive, {}).
-record(pubsub_subscribe, {node :: binary(), -record(pubsub_subscribe, {node :: binary(),
jid :: any()}). jid :: any()}).
-record(chatstate_composing, {}).
-record(sasl_auth, {mechanism :: binary(), -record(sasl_auth, {mechanism :: binary(),
text :: any()}). text :: any()}).
@ -232,8 +226,6 @@
-record(block_list, {}). -record(block_list, {}).
-record(csi_active, {}).
-record(xdata_field, {label :: binary(), -record(xdata_field, {label :: binary(),
type :: 'boolean' | 'fixed' | 'hidden' | 'jid-multi' | 'jid-single' | 'list-multi' | 'list-single' | 'text-multi' | 'text-private' | 'text-single', type :: 'boolean' | 'fixed' | 'hidden' | 'jid-multi' | 'jid-single' | 'list-multi' | 'list-single' | 'text-multi' | 'text-private' | 'text-single',
var :: binary(), var :: binary(),
@ -269,8 +261,6 @@
mode = tcp :: 'tcp' | 'udp', mode = tcp :: 'tcp' | 'udp',
sid :: binary()}). sid :: binary()}).
-record(chatstate_active, {}).
-record(vcard_org, {name :: binary(), -record(vcard_org, {name :: binary(),
units = [] :: [binary()]}). units = [] :: [binary()]}).
@ -491,122 +481,4 @@
-record(time, {tzo :: any(), -record(time, {tzo :: any(),
utc :: any()}). utc :: any()}).
-type xmpp_codec_type() :: #session{} |
#compression{} |
#pubsub_subscription{} |
#version{} |
#pubsub_affiliation{} |
#muc_admin{} |
#sm_a{} |
#carbons_sent{} |
#p1_rebind{} |
#sasl_abort{} |
#carbons_received{} |
#pubsub_retract{} |
#compressed{} |
#block_list{} |
#'see-other-host'{} |
#starttls_proceed{} |
#sm_resumed{} |
#forwarded{} |
#privacy_list{} |
#text{} |
#vcard_org{} |
#feature_sm{} |
#pubsub_item{} |
#roster_item{} |
#pubsub_event_item{} |
#muc_item{} |
#shim{} |
#pubsub_event_items{} |
#disco_items{} |
#pubsub_options{} |
#sasl_success{} |
#compress{} |
#bytestreams{} |
#vcard_key{} |
#identity{} |
#feature_csi{} |
#legacy_delay{} |
#muc_user_destroy{} |
#muc_owner_destroy{} |
#privacy{} |
#delay{} |
#muc_history{} |
#bookmark_url{} |
#vcard_email{} |
#vcard_label{} |
#vcard_tel{} |
#vcard_logo{} |
#disco_info{} |
#vcard_geo{} |
#vcard_photo{} |
#muc_owner{} |
#pubsub{} |
#sm_r{} |
#muc_actor{} |
#error{} |
#stream_error{} |
#feature_register{} |
#roster{} |
#muc_user{} |
#vcard_adr{} |
#register{} |
#csi_active{} |
#muc_invite{} |
#carbons_disable{} |
#chatstate_active{} |
#bookmark_conference{} |
#time{} |
#sasl_response{} |
#chatstate_inactive{} |
#pubsub_subscribe{} |
#presence{} |
#message{} |
#sm_enable{} |
#chatstate_gone{} |
#starttls_failure{} |
#sasl_challenge{} |
#gone{} |
#private{} |
#compress_failure{} |
#sasl_failure{} |
#bookmark_storage{} |
#vcard_name{} |
#sm_resume{} |
#carbons_enable{} |
#carbons_private{} |
#pubsub_unsubscribe{} |
#csi_inactive{} |
#muc_decline{} |
#sasl_auth{} |
#p1_push{} |
#pubsub_publish{} |
#unblock{} |
#p1_ack{} |
#block{} |
#xdata{} |
#iq{} |
#last{} |
#redirect{} |
#sm_enabled{} |
#pubsub_event{} |
#vcard_sound{} |
#chatstate_paused{} |
#streamhost{} |
#stat{} |
#xdata_field{} |
#bind{} |
#sm_failed{} |
#vcard{} |
#chatstate_composing{} |
#ping{} |
#disco_item{} |
#privacy_item{} |
#caps{} |
#muc{} |
#stream_features{} |
#stats{} |
#pubsub_items{} |
#starttls{} |
#sasl_mechanisms{}.

View File

@ -1757,30 +1757,32 @@
result = {shim, '$headers'}, result = {shim, '$headers'},
refs = [#ref{name = shim_header, label = '$headers'}]}). refs = [#ref{name = shim_header, label = '$headers'}]}).
-record(chatstate, {type :: active | composing | gone | inactive | paused}).
-xml(chatstate_active, -xml(chatstate_active,
#elem{name = <<"active">>, #elem{name = <<"active">>,
xmlns = <<"http://jabber.org/protocol/chatstates">>, xmlns = <<"http://jabber.org/protocol/chatstates">>,
result = {chatstate_active}}). result = {chatstate, active}}).
-xml(chatstate_composing, -xml(chatstate_composing,
#elem{name = <<"composing">>, #elem{name = <<"composing">>,
xmlns = <<"http://jabber.org/protocol/chatstates">>, xmlns = <<"http://jabber.org/protocol/chatstates">>,
result = {chatstate_composing}}). result = {chatstate, composing}}).
-xml(chatstate_gone, -xml(chatstate_gone,
#elem{name = <<"gone">>, #elem{name = <<"gone">>,
xmlns = <<"http://jabber.org/protocol/chatstates">>, xmlns = <<"http://jabber.org/protocol/chatstates">>,
result = {chatstate_gone}}). result = {chatstate, gone}}).
-xml(chatstate_inactive, -xml(chatstate_inactive,
#elem{name = <<"inactive">>, #elem{name = <<"inactive">>,
xmlns = <<"http://jabber.org/protocol/chatstates">>, xmlns = <<"http://jabber.org/protocol/chatstates">>,
result = {chatstate_inactive}}). result = {chatstate, inactive}}).
-xml(chatstate_paused, -xml(chatstate_paused,
#elem{name = <<"paused">>, #elem{name = <<"paused">>,
xmlns = <<"http://jabber.org/protocol/chatstates">>, xmlns = <<"http://jabber.org/protocol/chatstates">>,
result = {chatstate_paused}}). result = {chatstate, paused}}).
-xml(delay, -xml(delay,
#elem{name = <<"delay">>, #elem{name = <<"delay">>,
@ -2101,15 +2103,17 @@
result = {feature_csi, '$xmlns'}, result = {feature_csi, '$xmlns'},
attrs = [#attr{name = <<"xmlns">>}]}). attrs = [#attr{name = <<"xmlns">>}]}).
-record(csi, {type :: active | inactive}).
-xml(csi_active, -xml(csi_active,
#elem{name = <<"active">>, #elem{name = <<"active">>,
xmlns = <<"urn:xmpp:csi:0">>, xmlns = <<"urn:xmpp:csi:0">>,
result = {csi_active}}). result = {csi, active}}).
-xml(csi_inactive, -xml(csi_inactive,
#elem{name = <<"inactive">>, #elem{name = <<"inactive">>,
xmlns = <<"urn:xmpp:csi:0">>, xmlns = <<"urn:xmpp:csi:0">>,
result = {csi_inactive}}). result = {csi, inactive}}).
-xml(feature_sm, -xml(feature_sm,
#elem{name = <<"sm">>, #elem{name = <<"sm">>,