From ece782fc0c135b4413ecdec338e68393a4de08d5 Mon Sep 17 00:00:00 2001
From: Barracuda <omega8cc@gmail.com>
Date: Sun, 28 Nov 2010 18:41:27 +0100
Subject: [PATCH] Check and release too old cron semaphore if exist.

---
 modules/hosting/hosting.queues.inc |    9 +++++++++
 1 files changed, 9 insertions(+), 0 deletions(-)

diff --git a/modules/hosting/hosting.queues.inc b/modules/hosting/hosting.queues.inc
index 57636aa..9a4200e 100644
--- a/modules/hosting/hosting.queues.inc
+++ b/modules/hosting/hosting.queues.inc
@@ -32,6 +32,15 @@ function hosting_get_queues($refresh = false) {
     foreach ($queues as $key => $queue) {
       $queue = array_merge($defaults, $queue);
 
+      // Check and release too old cron semaphore if exist
+      $old_semaphore = variable_get('hosting_queue_' . $key . '_running', false);
+      if ($old_semaphore) {
+        if (mktime() - $old_semaphore > 3600) {
+          // Release too old cron semaphore
+          variable_del('hosting_queue_' . $key . '_running', false);
+        }
+      }
+
       // Configurable settings. 
       $configured = array(
         'frequency' => variable_get('hosting_queue_' . $key . '_frequency', $queue['frequency']),
-- 
1.6.1

