[Slim-Checkins] r11085 - in /trunk/server/Slim: Control/Request.pm
Networking/Select.pm Utils/Scheduler.pm Utils/Timers.pm
adrian at svn.slimdevices.com
adrian at svn.slimdevices.com
Tue Jan 2 11:14:11 PST 2007
Author: adrian
Date: Tue Jan 2 11:14:10 2007
New Revision: 11085
URL: http://svn.slimdevices.com?rev=11085&view=rev
Log:
Bug: N/A
Description: wrap notify/select/scheduler/timer callbacks in eval to
protect server
Modified:
trunk/server/Slim/Control/Request.pm
trunk/server/Slim/Networking/Select.pm
trunk/server/Slim/Utils/Scheduler.pm
trunk/server/Slim/Utils/Timers.pm
Modified: trunk/server/Slim/Control/Request.pm
URL: http://svn.slimdevices.com/trunk/server/Slim/Control/Request.pm?rev=11085&r1=11084&r2=11085&view=diff
==============================================================================
--- trunk/server/Slim/Control/Request.pm (original)
+++ trunk/server/Slim/Control/Request.pm Tue Jan 2 11:14:10 2007
@@ -1638,7 +1638,11 @@
$::perfmon && (my $now = Time::HiRes::time());
- &$notifyFuncRef($self);
+ eval { &$notifyFuncRef($self) };
+
+ if ($@) {
+ logError("Failed notify: $@");
+ }
$::perfmon && $requestTask->log(Time::HiRes::time() - $now, "Notify: ", $notifyFuncRef);
Modified: trunk/server/Slim/Networking/Select.pm
URL: http://svn.slimdevices.com/trunk/server/Slim/Networking/Select.pm?rev=11085&r1=11084&r2=11085&view=diff
==============================================================================
--- trunk/server/Slim/Networking/Select.pm (original)
+++ trunk/server/Slim/Networking/Select.pm Tue Jan 2 11:14:10 2007
@@ -232,7 +232,11 @@
# the socket may have passthrough arguments set
my $passthrough = ${*$sock}{'passthrough'} || [];
- $callback->( $sock, @{$passthrough} );
+ eval { $callback->( $sock, @{$passthrough} ) };
+
+ if ($@) {
+ logError("Select task failed: $@");
+ }
$::perfmon && $now && $selectTask->log(Time::HiRes::time() - $now, undef, $callback);
}
Modified: trunk/server/Slim/Utils/Scheduler.pm
URL: http://svn.slimdevices.com/trunk/server/Slim/Utils/Scheduler.pm?rev=11085&r1=11084&r2=11085&view=diff
==============================================================================
--- trunk/server/Slim/Utils/Scheduler.pm (original)
+++ trunk/server/Slim/Utils/Scheduler.pm Tue Jan 2 11:14:10 2007
@@ -35,9 +35,7 @@
your function and a list of arguments.
Background tasks should be run whenever the server has extra time on its hands, ie,
- when we'd otherwise be sitting in select. To run background tasks, call run_tasks,
- passing as the argument the amount of time (in seconds; 0.1 or less is
- recommended) that you want to spend on them.
+ when we'd otherwise be sitting in select.
=cut
@@ -117,7 +115,7 @@
=cut
sub run_tasks {
- return 0 if scalar !@background_tasks;
+ return 0 unless @background_tasks;
my $busy = 0;
my $now = Time::HiRes::time();
@@ -141,7 +139,13 @@
my $taskptr = $background_tasks[$curtask];
my ($subptr, @subargs) = @$taskptr;
- if (&$subptr(@subargs) == 0) {
+ my $cont = eval { &$subptr(@subargs) };
+
+ if ($@) {
+ logError("Scheduled task failed: $@");
+ }
+
+ if ($@ || !$cont) {
# the task has finished. Remove it from the list.
$log->info("Task finished: $subptr");
Modified: trunk/server/Slim/Utils/Timers.pm
URL: http://svn.slimdevices.com/trunk/server/Slim/Utils/Timers.pm?rev=11085&r1=11084&r2=11085&view=diff
==============================================================================
--- trunk/server/Slim/Utils/Timers.pm (original)
+++ trunk/server/Slim/Utils/Timers.pm Tue Jan 2 11:14:10 2007
@@ -193,7 +193,11 @@
if ( $subptr ) {
- $subptr->($objRef, @{$args});
+ eval { $subptr->($objRef, @{$args}) };
+
+ if ($@) {
+ logError("Timer failed: $@");
+ }
} else {
More information about the checkins
mailing list