Index: imagecache.module
===================================================================
--- imagecache.module	(revision 295)
+++ imagecache.module	(working copy)
@@ -463,10 +463,16 @@
 
   $lockfile = file_directory_temp() .'/'. $preset['presetname'] . basename($src);
   if (file_exists($lockfile)) {
-    watchdog('imagecache', 'ImageCache already generating: %dst, Lock file: %tmp.', array('%dst' => $dst, '%tmp' => $lockfile), WATCHDOG_NOTICE);
-    // 307 Temporary Redirect, to myself. Lets hope the image is done next time around.
-    header('Location: '. request_uri(), TRUE, 307);
-    exit;
+    // If the lockfile is too old (older than the max_execution_time). Most probably, derivative creation failed.
+    if (time() - filemtime($lockfile) > ini_get('max_execution_time')) {
+      file_delete($lockfile);
+    }
+    else {
+      watchdog('imagecache', 'ImageCache already generating: %dst, Lock file: %tmp.', array('%dst' => $dst, '%tmp' => $lockfile), WATCHDOG_NOTICE);
+      // 307 Temporary Redirect, to myself. Lets hope the image is done next time around.
+      header('Location: '. request_uri(), TRUE, 307);
+      exit;
+    }
   }
   touch($lockfile);
   // register the shtdown function to clean up lock files. by the time shutdown
