From 3ee07d8bb4cad2eb265c140f92dd7169e601b2a1 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Gerg=C5=91=20Tisza?= Date: Fri, 27 Jun 2014 19:39:47 +0000 Subject: [PATCH] Use separate PoolCounter config for expensive thumbnails Depends on Ic62984e0f4a761642b2bdd1bfa362301ed94c284 and If40e223c328ddd15310d13f2a49000bf6e08200e Bug: 65691 Change-Id: Ic737673b5a31974d866b9bf5afa4b4036baa03bb --- thumb.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/thumb.php b/thumb.php index d7bf453382..c611dc3ca7 100644 --- a/thumb.php +++ b/thumb.php @@ -387,9 +387,17 @@ function wfGenerateThumbnail( File $file, array $params, $thumbName, $thumbPath $thumb = false; $errorHtml = false; + // guard thumbnail rendering with PoolCounter to avoid stampedes + // expensive files use a separate PoolCounter config so it is possible to set up a global limit on them + if ( $file->isExpensiveToThumbnail() ) { + $poolCounterType = 'FileRenderExpensive'; + } else { + $poolCounterType = 'FileRender'; + } + // Thumbnail isn't already there, so create the new thumbnail... try { - $work = new PoolCounterWorkViaCallback( 'FileRender', sha1( $file->getName() ), + $work = new PoolCounterWorkViaCallback( $poolCounterType, sha1( $file->getName() ), array( 'doWork' => function() use ( $file, $params ) { return $file->transform( $params, File::RENDER_NOW ); -- 2.20.1