[Slim-Checkins] r8818 - /trunk/server/Slim/Networking/Slimproto.pm

adrian at svn.slimdevices.com adrian at svn.slimdevices.com
Sat Aug 5 08:25:00 PDT 2006


Author: adrian
Date: Sat Aug  5 08:24:59 2006
New Revision: 8818

URL: http://svn.slimdevices.com?rev=8818&view=rev
Log:
Bug: N/A
Description: slight slimplification of last_check logic

Modified:
    trunk/server/Slim/Networking/Slimproto.pm

Modified: trunk/server/Slim/Networking/Slimproto.pm
URL: http://svn.slimdevices.com/trunk/server/Slim/Networking/Slimproto.pm?rev=8818&r1=8817&r2=8818&view=diff
==============================================================================
--- trunk/server/Slim/Networking/Slimproto.pm (original)
+++ trunk/server/Slim/Networking/Slimproto.pm Sat Aug  5 08:24:59 2006
@@ -35,7 +35,7 @@
 my $forget_disconnected_time = 300; # disconnected clients will be forgotten unless they reconnect before this
 
 my $check_all_clients_time = 5; # how often to look for disconnected clients
-my $last_check;                 # last time check_all_clients ran
+my $check_time;                 # time scheduled for next check_all_clients
 
 my $slimproto_socket;
 
@@ -116,8 +116,8 @@
 	Slim::Networking::Select::addRead($slimproto_socket, \&slimproto_accept);
 	
 	# Bug 2707, This timer checks for players that have gone away due to a power loss and disconnects them
-	$last_check = time();
-	Slim::Utils::Timers::setTimer( undef, Time::HiRes::time() + $check_all_clients_time, \&check_all_clients );
+	$check_time = time() + $check_all_clients_time;
+	Slim::Utils::Timers::setTimer( undef, $check_time, \&check_all_clients );
 
 	$::d_slimproto && msg "Squeezebox protocol listening on port $listenerport\n";	
 }
@@ -174,8 +174,6 @@
 
 sub check_all_clients {
 
-	my $now = time();
-	
 	for my $client ( values %sock2client ) {
 		
 		# SoftSqueeze does not report status
@@ -187,13 +185,8 @@
 			next;
 		}
 		
-		# adjust in case the server is running slow
-		if ( $now - $last_check > $check_all_clients_time ) {
-			$now = $last_check + $check_all_clients_time;
-		}
-		
 		# check when we last heard a stat response from the player
-		my $last_heard = $now - $heartbeat{$client};
+		my $last_heard = $check_time - $heartbeat{$client};
 		
 		if ( $last_heard >= $check_all_clients_time * 2 ) {
 			$::d_slimproto && msgf("Haven't heard from %s in %d seconds, closing connection\n",
@@ -210,9 +203,9 @@
 		}
 	}
 
-	$last_check = $now;
-
-	Slim::Utils::Timers::setTimer( undef, $now + $check_all_clients_time, \&check_all_clients );
+	$check_time = time() + $check_all_clients_time;
+
+	Slim::Utils::Timers::setTimer( undef, $check_time, \&check_all_clients );
 }
 
 sub slimproto_close {



More information about the checkins mailing list