504 local timeout_start = math_max(session.hibernating, session.first_hibernated_push or session.hibernating); |
504 local timeout_start = math_max(session.hibernating, session.first_hibernated_push or session.hibernating); |
505 if session.push_identifier ~= nil and not session.first_hibernated_push then |
505 if session.push_identifier ~= nil and not session.first_hibernated_push then |
506 session.log("debug", "No push happened since hibernation started, hibernating session for up to %d extra seconds", resume_timeout); |
506 session.log("debug", "No push happened since hibernation started, hibernating session for up to %d extra seconds", resume_timeout); |
507 return resume_timeout; |
507 return resume_timeout; |
508 end |
508 end |
509 if current_time-timeout_start < resume_timeout and session.push_identifier ~= nil then |
509 if session.push_identifier ~= nil and current_time-timeout_start < resume_timeout then |
510 session.log("debug", "A push happened since hibernation started, hibernating session for up to %d extra seconds", current_time-timeout_start); |
510 session.log("debug", "A push happened since hibernation started, hibernating session for up to %d extra seconds", resume_timeout-(current_time-timeout_start)); |
511 return current_time-timeout_start; -- time left to wait |
511 return resume_timeout-(current_time-timeout_start); -- time left to wait |
512 end |
512 end |
513 session.log("debug", "Destroying session for hibernating too long"); |
513 session.log("debug", "Destroying session for hibernating too long"); |
514 session_registry.set(session.username, session.resumption_token, nil); |
514 session_registry.set(session.username, session.resumption_token, nil); |
515 -- save only actual h value and username/host (for security) |
515 -- save only actual h value and username/host (for security) |
516 old_session_registry.set(session.username, session.resumption_token, { |
516 old_session_registry.set(session.username, session.resumption_token, { |