Index: includes/common.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/common.inc,v
retrieving revision 1.756.2.24
diff -u -u -p -r1.756.2.24 common.inc
--- includes/common.inc	13 Aug 2008 23:59:12 -0000	1.756.2.24
+++ includes/common.inc	26 Aug 2008 13:29:04 -0000
@@ -294,6 +294,10 @@ function drupal_get_destination() {
  * @see drupal_get_destination()
  */
 function drupal_goto($path = '', $query = NULL, $fragment = NULL, $http_response_code = 302) {
+  // Ignore drupal_goto's within cron.php.
+  if (variable_get('cron_semaphore', 0)) {
+    return;
+  }
 
   if (isset($_REQUEST['destination'])) {
     extract(parse_url(urldecode($_REQUEST['destination'])));
Index: modules/node/node.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/node/node.module,v
retrieving revision 1.947.2.11
diff -u -u -p -r1.947.2.11 node.module
--- modules/node/node.module	25 Jun 2008 08:59:57 -0000	1.947.2.11
+++ modules/node/node.module	26 Aug 2008 13:29:35 -0000
@@ -1149,8 +1149,9 @@ function node_search($op = 'search', $ke
 
     case 'status':
       $total = db_result(db_query('SELECT COUNT(*) FROM {node} WHERE status = 1'));
-      $remaining = db_result(db_query("SELECT COUNT(*) FROM {node} n LEFT JOIN {search_dataset} d ON d.type = 'node' AND d.sid = n.nid WHERE n.status = 1 AND (d.sid IS NULL OR d.reindex <> 0)"));
-      return array('remaining' => $remaining, 'total' => $total);
+      $remaining = db_result(db_query("SELECT COUNT(*) FROM {node} n LEFT JOIN {search_dataset} d ON d.type = 'node' AND d.sid = n.nid WHERE n.status = 1 AND (d.sid IS NULL OR d.reindex > 0)"));
+      $pending = db_result(db_query("SELECT COUNT(*) FROM {node} n LEFT JOIN {search_dataset} d ON d.type = 'node' AND d.sid = n.nid WHERE n.status = 1 AND d.reindex < 0"));
+      return array('remaining' => $remaining, 'total' => $total, 'pending' => $pending);
 
     case 'admin':
       $form = array();
@@ -1781,7 +1782,7 @@ function node_update_index() {
   variable_set('node_cron_comments_scale', 1.0 / max(1, db_result(db_query('SELECT MAX(comment_count) FROM {node_comment_statistics}'))));
   variable_set('node_cron_views_scale', 1.0 / max(1, db_result(db_query('SELECT MAX(totalcount) FROM {node_counter}'))));
 
-  $result = db_query_range("SELECT n.nid FROM {node} n LEFT JOIN {search_dataset} d ON d.type = 'node' AND d.sid = n.nid WHERE d.sid IS NULL OR d.reindex <> 0 ORDER BY d.reindex ASC, n.nid ASC", 0, $limit);
+  $result = db_query_range("SELECT n.nid FROM {node} n LEFT JOIN {search_dataset} d ON d.type = 'node' AND d.sid = n.nid WHERE d.sid IS NULL OR d.reindex > 0 ORDER BY d.reindex ASC, n.nid ASC", 0, $limit);
 
   while ($node = db_fetch_object($result)) {
     _node_index_node($node);
@@ -1797,6 +1798,9 @@ function node_update_index() {
 function _node_index_node($node) {
   $node = node_load($node->nid);
 
+  // Mark the node with an index is in progress indicator.
+  search_touch_node($node->nid, TRUE);
+
   // save the changed time of the most recent indexed node, for the search results half-life calculation
   variable_set('node_cron_last', $node->changed);
 
Index: modules/search/search.admin.inc
===================================================================
RCS file: /cvs/drupal/drupal/modules/search/search.admin.inc,v
retrieving revision 1.4
diff -u -u -p -r1.4 search.admin.inc
--- modules/search/search.admin.inc	8 Jan 2008 10:35:42 -0000	1.4
+++ modules/search/search.admin.inc	26 Aug 2008 13:29:39 -0000
@@ -35,17 +35,23 @@ function search_wipe_confirm_submit(&$fo
  */
 function search_admin_settings() {
   // Collect some stats
-  $remaining = 0;
-  $total = 0;
+  $sum = array('remaining' => 0, 'total' => 0, 'pending' => 0);
   foreach (module_list() as $module) {
-    if (module_hook($module, 'search')) {
-      $status = module_invoke($module, 'search', 'status');
+    if (module_hook($module, 'search') && ($status = module_invoke($module, 'search', 'status'))) {
+      foreach ($status as $index => $count) {
+        $sum[$index] += $count;
+      }
       $remaining += $status['remaining'];
-      $total += $status['total'];
     }
   }
-  $count = format_plural($remaining, 'There is 1 item left to index.', 'There are @count items left to index.');
-  $percentage = ((int)min(100, 100 * ($total - $remaining) / max(1, $total))) .'%';
+  $count = '';
+  if (!empty($sum['remaining'])) {
+    $count .= format_plural($sum['remaining'], 'There is 1 item left to index.', 'There are @count items left to index.');
+  }
+  if (!empty($sum['pending'])) {
+    $count .= '  '. format_plural($sum['pending'], 'There is 1 item pending or failed indexing.', 'There are @count items being indexed or failed indexing.');
+  }
+  $percentage = ((int)min(100, 100 * ($sum['total'] - $sum['remaining'] - $sum['pending']) / max(1, $sum['total']))) .'%';
   $status = '<p><strong>'. t('%percentage of the site has been indexed.', array('%percentage' => $percentage)) .' '. $count .'</strong></p>';
   $form['status'] = array('#type' => 'fieldset', '#title' => t('Indexing status'));
   $form['status']['status'] = array('#value' => $status);
Index: modules/search/search.install
===================================================================
RCS file: /cvs/drupal/drupal/modules/search/search.install,v
retrieving revision 1.14
diff -u -u -p -r1.14 search.install
--- modules/search/search.install	28 Dec 2007 10:53:27 -0000	1.14
+++ modules/search/search.install	26 Aug 2008 13:29:39 -0000
@@ -49,7 +49,7 @@ function search_schema() {
       ),
       'reindex' => array(
         'type' => 'int',
-        'unsigned' => TRUE,
+        'unsigned' => FALSE,
         'not null' => TRUE,
         'default' => 0,
         'description' => t('Set to force node reindexing.'),
Index: modules/search/search.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/search/search.module,v
retrieving revision 1.250.2.3
diff -u -u -p -r1.250.2.3 search.module
--- modules/search/search.module	13 Aug 2008 06:59:49 -0000	1.250.2.3
+++ modules/search/search.module	26 Aug 2008 13:29:40 -0000
@@ -619,9 +619,12 @@ function search_index($sid, $type, $text
  *
  * @param $nid
  *   The nid of the node that needs reindexing.
+ * @param $pending
+ *   A bool, TRUE indicating to reindex the node,
+ *           FALSE indicating that the node is currently being reindexed.
  */
-function search_touch_node($nid) {
-  db_query("UPDATE {search_dataset} SET reindex = %d WHERE sid = %d AND type = 'node'", time(), $nid);
+function search_touch_node($nid, $pending = FALSE) {
+  db_query("UPDATE {search_dataset} SET reindex = %d WHERE sid = %d AND type = 'node'", (($pending) ? -1 : 1) * time(), $nid);
 }
 
 /**
Index: modules/system/system.install
===================================================================
RCS file: /cvs/drupal/drupal/modules/system/system.install,v
retrieving revision 1.238.2.3
diff -u -u -p -r1.238.2.3 system.install
--- modules/system/system.install	25 Apr 2008 21:24:20 -0000	1.238.2.3
+++ modules/system/system.install	26 Aug 2008 13:29:45 -0000
@@ -2512,6 +2512,15 @@ function system_update_6047() {
 }
 
 /**
+ * Change the search reindex column to be signed.
+ */
+function system_update_6049() {
+  $ret = array();
+  db_change_field($ret, 'search_dataset', 'reindex', 'reindex', array('type' => 'int', 'unsigned' => FALSE, 'not null' => TRUE, 'default' => 0));
+  return $ret;
+}
+
+/**
  * @} End of "defgroup updates-5.x-to-6.x"
  * The next series of updates should start at 7000.
  */


