Add a $cache_timeout-based backstop for infinite loops
authorMike Rylander <mrylander@gmail.com>
Fri, 26 Apr 2013 15:28:38 +0000 (11:28 -0400)
committerMike Rylander <mrylander@gmail.com>
Thu, 2 May 2013 14:09:01 +0000 (10:09 -0400)
Signed-off-by: Mike Rylander <mrylander@gmail.com>
Signed-off-by: Jason Etheridge <jason@esilibrary.com>
Open-ILS/src/perlmods/lib/OpenILS/Application/Search/Biblio.pm

index 3975eda..5ea3602 100644 (file)
@@ -1302,7 +1302,8 @@ sub staged_search {
     # and complexity, this is close to the best we can do.
 
     if ($cache_data->{running}) { # someone is already doing the search...
-        while ( sleep(1) ) { # sleep for a second ... maybe they'll finish
+        my $stop_looping = time() + $cache_timeout;
+        while ( sleep(1) and time() < $stop_looping ) { # sleep for a second ... maybe they'll finish
             $cache_data = $cache->get_cache($key) || {};
             last if (!$cache_data->{running});
         }