From c6a39b7c0c317dbb9d8807ceb4d1aa9bff3e1e45 Mon Sep 17 00:00:00 2001 From: Daniel Berteaud Date: Wed, 17 Jun 2015 09:23:27 +0200 Subject: [PATCH] Purge expired rooms and invitation in an IOLoop instead of the ping hack --- vroom.pl | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/vroom.pl b/vroom.pl index 0679d9e..c5998ee 100755 --- a/vroom.pl +++ b/vroom.pl @@ -1186,6 +1186,12 @@ Mojo::IOLoop->recurring( 3 => sub { } }); +# Purge every 5 minutes +Mojo::IOLoop->recurring( 300 => sub { + app->purge_rooms; + app->purge_invitations; +}); + # Route / to the index page get '/' => sub { my $self = shift; @@ -1566,11 +1572,6 @@ any '/api' => sub { # Handle activity pings sent every minute by each participant elsif ($req->{action} eq 'ping'){ $self->update_room_last_activity($room->{name}); - # Cleanup expired rooms every ~10 pings - if ((int (rand 100)) <= 10){ - $self->purge_rooms; - $self->purge_invitations; - } # Check if we got any invitation response to process my $invitations = $self->get_invitation_list($self->session('id')); my $msg = '';