Skip to content

Commit

Permalink
XEP-0198: Fix session timeout corner case
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
weiss committed Feb 6, 2016
1 parent 7435ee4 commit a31f59e
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/ejabberd_c2s.erl
Expand Up @@ -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 ->
Expand Down

1 comment on commit a31f59e

@mremond
Copy link
Member

@mremond mremond commented on a31f59e Feb 7, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks !

Please sign in to comment.