From: Paweł Chmielowski Date: Fri, 8 Apr 2016 08:46:21 +0000 (+0200) Subject: Make sure that ejabberd_sm sid are unique X-Git-Tag: 16.04~40 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=86dfbe6ecef37fe19857193b5f7ec92dea39ac4f;p=ejabberd Make sure that ejabberd_sm sid are unique --- diff --git a/rebar.config b/rebar.config index 5b6676a13..d006dc64c 100644 --- a/rebar.config +++ b/rebar.config @@ -8,7 +8,7 @@ %%%------------------------------------------------------------------- {deps, [{lager, ".*", {git, "https://github.com/basho/lager", {tag, "3.0.2"}}}, - {p1_utils, ".*", {git, "https://github.com/processone/p1_utils", {tag, "1.0.3"}}}, + {p1_utils, ".*", {git, "https://github.com/processone/p1_utils", {tag, "1.0.4"}}}, {cache_tab, ".*", {git, "https://github.com/processone/cache_tab", {tag, "1.0.2"}}}, {fast_tls, ".*", {git, "https://github.com/processone/fast_tls", {tag, "1.0.1"}}}, {stringprep, ".*", {git, "https://github.com/processone/stringprep", {tag, "1.0.3"}}}, diff --git a/src/ejabberd_auth_anonymous.erl b/src/ejabberd_auth_anonymous.erl index 9c4b719c3..5a5b395bf 100644 --- a/src/ejabberd_auth_anonymous.erl +++ b/src/ejabberd_auth_anonymous.erl @@ -56,7 +56,7 @@ %% Create the anonymous table if at least one virtual host has anonymous features enabled %% Register to login / logout events -record(anonymous, {us = {<<"">>, <<"">>} :: {binary(), binary()}, - sid = {p1_time_compat:timestamp(), self()} :: ejabberd_sm:sid()}). + sid = ejabberd_sm:make_sid() :: ejabberd_sm:sid()}). start(Host) -> %% TODO: Check cluster mode diff --git a/src/ejabberd_c2s.erl b/src/ejabberd_c2s.erl index 9fe1100b5..948e2027b 100644 --- a/src/ejabberd_c2s.erl +++ b/src/ejabberd_c2s.erl @@ -327,7 +327,7 @@ init([{SockMod, Socket}, Opts]) -> xml_socket = XMLSocket, zlib = Zlib, tls = TLS, tls_required = StartTLSRequired, tls_enabled = TLSEnabled, tls_options = TLSOpts, - sid = {p1_time_compat:timestamp(), self()}, streamid = new_id(), + sid = ejabberd_sm:make_sid(), streamid = new_id(), access = Access, shaper = Shaper, ip = IP, mgmt_state = StreamMgmtState, mgmt_max_queue = MaxAckQueue, diff --git a/src/ejabberd_sm.erl b/src/ejabberd_sm.erl index 4f7cfeeaa..7ab0a5f78 100644 --- a/src/ejabberd_sm.erl +++ b/src/ejabberd_sm.erl @@ -66,7 +66,8 @@ get_max_user_sessions/2, get_all_pids/0, is_existing_resource/3, - get_commands_spec/0 + get_commands_spec/0, + make_sid/0 ]). -export([init/1, handle_call/3, handle_cast/2, @@ -806,6 +807,9 @@ kick_user(User, Server) -> end, Resources), length(Resources). +make_sid() -> + {p1_time_compat:unique_timestamp(), self()}. + opt_type(sm_db_type) -> fun (mnesia) -> mnesia; (internal) -> mnesia;