From 9b35e2b168d6416b0e77b3caa6a86ebd83f8afab Mon Sep 17 00:00:00 2001 From: "Paul S. Owen" Date: Thu, 25 Jul 2002 15:50:57 +0000 Subject: [PATCH] Throw in a load check for the hell of it ... git-svn-id: file:///svn/phpbb/trunk@2742 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/admin/admin_search.php | 34 +++++++++++++++++++++++++++++----- 1 file changed, 29 insertions(+), 5 deletions(-) diff --git a/phpBB/admin/admin_search.php b/phpBB/admin/admin_search.php index 5d0359f434..998955d401 100644 --- a/phpBB/admin/admin_search.php +++ b/phpBB/admin/admin_search.php @@ -54,6 +54,31 @@ if ( !$acl->get_acl_admin('general') ) // if ( isset($HTTP_POST_VARS['start']) || isset($HTTP_GET_VARS['batchstart']) ) { + $batchsize = 200; // Process this many posts per batch + $batchstart = ( !isset($HTTP_GET_VARS['batchstart']) ) ? $row['min_post_id'] : $HTTP_GET_VARS['batchstart']; + $batchcount = ( !isset($HTTP_GET_VARS['batchcount']) ) ? 1 : $HTTP_GET_VARS['batchcount']; + $loopcount = 0; + $batchend = $batchstart + $batchsize; + + // + // Search re-indexing is tough on the server ... so we'll check the load + // each loop and if we're on a 1min load of 3 or more we'll re-load the page + // and try again. No idea how well this will work in practice so we'll see ... + // + if ( file_exists('/proc/loadavg') ) + { + if ( $load = @file('/proc/loadavg') ) + { + list($load) = explode(' ', $load[0]); + + if ( $load > 3 ) + { + header("Location: admin_search.$phpEx$SID&batchstart=$batchstart&batchcount=$batch_count"); + exit; + } + } + } + // // Try and load stopword and synonym files // @@ -112,11 +137,8 @@ if ( isset($HTTP_POST_VARS['start']) || isset($HTTP_GET_VARS['batchstart']) ) $totalposts = $row['total']; $max_post_id = $row['max_post_id']; - $batchsize = 200; // Process this many posts per batch - $batchstart = ( !isset($HTTP_GET_VARS['batchstart']) ) ? $row['min_post_id'] : $HTTP_GET_VARS['batchstart']; - $batchcount = ( !isset($HTTP_GET_VARS['batchcount']) ) ? 1 : $HTTP_GET_VARS['batchcount']; - $batchend = $batchstart + $batchsize; - + $db->sql_freeresult($result); + $sql = "SELECT * FROM " . POSTS_TEXT_TABLE . " WHERE post_id @@ -251,6 +273,8 @@ if ( isset($HTTP_POST_VARS['start']) || isset($HTTP_GET_VARS['batchstart']) ) while ( $row = $db->sql_fetchrow($result) ); } + $db->sql_freeresult($result); + // Remove common words after the first 2 batches and after every 4th batch after that. if ( $batchcount % 4 == 3 ) {