]> granicus.if.org Git - ejabberd/commitdiff
XEP-0198: Fix session timeout corner case
authorHolger Weiss <holger@zedat.fu-berlin.de>
Sat, 6 Feb 2016 21:28:55 +0000 (22:28 +0100)
committerHolger Weiss <holger@zedat.fu-berlin.de>
Sat, 6 Feb 2016 21:28:55 +0000 (22:28 +0100)
If the "resend_on_timeout" option is set to 'if_offline' and a pending
stream management session is terminated because a new session is opened
by the same resource (while no other resource is online), resend
unacknowledged messages rather than bouncing error messages.

src/ejabberd_c2s.erl

index 19fde38ff1eb614212484b3e7a73a84ad32b1e6c..8959ae50e571d36d725a8025044d7d47c7dd1eba 100644 (file)
@@ -2833,8 +2833,16 @@ handle_unacked_stanzas(StateData)
          Resend when is_boolean(Resend) ->
              Resend;
          if_offline ->
-             ejabberd_sm:get_user_resources(StateData#state.user,
-                                            StateData#state.server) == []
+             Resource = StateData#state.resource,
+             case ejabberd_sm:get_user_resources(StateData#state.user,
+                                                 StateData#state.server) of
+               [Resource] -> % Same resource opened new session
+                   true;
+               [] ->
+                   true;
+               _ ->
+                   false
+             end
        end,
     ReRoute = case ResendOnTimeout of
                true ->