]> granicus.if.org Git - ejabberd/commitdiff
Merge branch 'push-requirements' of https://github.com/weiss/ejabberd into weiss...
authorChristophe Romain <christophe.romain@process-one.net>
Tue, 13 Sep 2016 12:29:14 +0000 (14:29 +0200)
committerChristophe Romain <christophe.romain@process-one.net>
Tue, 13 Sep 2016 12:29:14 +0000 (14:29 +0200)
1  2 
src/ejabberd_c2s.erl

index 1bcb77e7f5fcdd296bd79bb0a94e655804611a86,73cc57247664a48afe5c3491e735eea257b7e6e4..226c5e0da4cf351af97076fb705cc1542eeaeca3
@@@ -1766,13 -1769,12 +1792,17 @@@ handle_info({broadcast, Type, From, Pac
                From, jid:make(USR), Packet)
        end, lists:usort(Recipients)),
      fsm_next_state(StateName, StateData);
+ handle_info({set_csi_state, CsiState}, StateName, StateData) ->
+     fsm_next_state(StateName, StateData#state{csi_state = CsiState});
+ handle_info({set_resume_timeout, Timeout}, StateName, StateData) ->
+     fsm_next_state(StateName, StateData#state{mgmt_timeout = Timeout});
  handle_info(dont_ask_offline, StateName, StateData) ->
      fsm_next_state(StateName, StateData#state{ask_offline = false});
 +handle_info(close, StateName, StateData) ->
 +    ?DEBUG("Timeout waiting for stream management acknowledgement of ~s",
 +         [jid:to_string(StateData#state.jid)]),
 +    close(self()),
 +    fsm_next_state(StateName, StateData#state{mgmt_ack_timer = undefined});
  handle_info({_Ref, {resume, OldStateData}}, StateName, StateData) ->
      %% This happens if the resume_session/1 request timed out; the new session
      %% now receives the late response.
@@@ -2493,19 -2495,19 +2523,25 @@@ fsm_next_state(session_established, Sta
       ?C2S_HIBERNATE_TIMEOUT};
  fsm_next_state(wait_for_resume, #state{mgmt_timeout = 0} = StateData) ->
      {stop, normal, StateData};
- fsm_next_state(wait_for_resume, #state{mgmt_pending_since = undefined} =
-              StateData) ->
+ fsm_next_state(wait_for_resume, #state{mgmt_pending_since = undefined,
+                                      sid = SID, jid = JID, ip = IP,
+                                      conn = Conn, auth_module = AuthModule,
+                                      server = Host} = StateData) ->
 +    case StateData of
 +      #state{mgmt_ack_timer = undefined} ->
 +        ok;
 +      #state{mgmt_ack_timer = Timer} ->
 +        erlang:cancel_timer(Timer)
 +    end,
      ?INFO_MSG("Waiting for resumption of stream for ~s",
-             [jid:to_string(StateData#state.jid)]),
+             [jid:to_string(JID)]),
+     Info = [{ip, IP}, {conn, Conn}, {auth_module, AuthModule}],
+     NewStateData = ejabberd_hooks:run_fold(c2s_session_pending, Host, StateData,
+                                          [SID, JID, Info]),
      {next_state, wait_for_resume,
-      StateData#state{mgmt_state = pending, mgmt_pending_since = os:timestamp()},
-      StateData#state.mgmt_timeout};
+      NewStateData#state{mgmt_state = pending,
+                       mgmt_pending_since = os:timestamp()},
+      NewStateData#state.mgmt_timeout};
  fsm_next_state(wait_for_resume, StateData) ->
      Diff = timer:now_diff(os:timestamp(), StateData#state.mgmt_pending_since),
      Timeout = max(StateData#state.mgmt_timeout - Diff div 1000, 1),