? drupal-DRUPAL-6-cron_running_hooks.patch
Index: includes/common.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/common.inc,v
retrieving revision 1.756.2.97
diff -u -B -r1.756.2.97 common.inc
--- includes/common.inc	11 Aug 2010 21:10:41 -0000	1.756.2.97
+++ includes/common.inc	20 Aug 2010 15:00:54 -0000
@@ -2740,9 +2740,15 @@
     // Lock cron semaphore
     variable_set('cron_semaphore', time());
 
+    // Make sure cron_running_hooks() knows we're calling the hooks.
+    $GLOBALS['cron_running_hooks'] = TRUE;
+
     // Iterate through the modules calling their cron handlers (if any):
     module_invoke_all('cron');
 
+    // We're done calling hooks for the moment.
+    $GLOBALS['cron_running_hooks'] = FALSE;
+
     // Record cron time
     variable_set('cron_last', time());
     watchdog('cron', 'Cron run completed.', array(), WATCHDOG_NOTICE);
@@ -2756,6 +2762,23 @@
 }
 
 /**
+  * Check if cron hooks are being called and queues are being run.
+  *
+  * @return
+  *   Returns TRUE if one of the following is true:
+  *     - hook_cron() is being actively called.
+  *     - queues are being processed right now.
+  */
+ function cron_running_hooks() {
+   global $cron_running_hooks;
+ 
+   if (!isset($cron_running_hooks)) {
+     $cron_running_hooks = FALSE;
+   }
+   return $cron_running_hooks;
+ }
+ 
+/**
  * Shutdown function for cron cleanup.
  */
 function drupal_cron_cleanup() {
