]> git.openstreetmap.org Git - nominatim.git/blobdiff - lib/leakybucket.php
update osm2pgsql (waterway multiline geometries)
[nominatim.git] / lib / leakybucket.php
index 778fe580fe6e065eeb06fef7b0368608e55945a4..6d4e8f293d4987bc1619419c9345ab32a477fc22 100644 (file)
@@ -26,7 +26,7 @@
                        $aCurrentBlock = $m->get($sKey);
                        if (!$aCurrentBlock)
                        {
-                               $aCurrentBlock = array($iRequestCost, $t);
+                               $aCurrentBlock = array($iRequestCost, $t, false);
                        }
                        else
                        {
                return $iMaxVal;
         }
 
+       function isBucketSleeping($asKey)
+       {
+               $m = getBucketMemcache();
+               if (!$m) return false;
+
+               foreach($asKey as $sKey)
+               {
+                       $aCurrentBlock = $m->get($sKey);
+                       if ($aCurrentBlock[2]) return true;
+               }
+               return false;
+       }
+
+       function setBucketSleeping($asKey, $bVal)
+       {
+               $m = getBucketMemcache();
+               if (!$m) return false;
+
+               $iMaxVal = 0;
+               $t = time();
+
+               foreach($asKey as $sKey)
+               {
+                       $aCurrentBlock = $m->get($sKey);
+                       $aCurrentBlock[2] = $bVal;
+                       $m->set($sKey, $aCurrentBlock, $t + 1 + $aCurrentBlock[0]/CONST_ConnectionBucket_LeakRate);
+               }
+               return true;
+       }
+
        function byValue1($a, $b)
        {
                if ($a[1] == $b[1])
                        $aBlockedList[$sKey] = array(
                                'totalBlocks' => $aDetails[0],
                                'lastBlockTimestamp' => $aDetails[1],
+                               'isSleeping' => (isset($aCurrentBlock[2])?$aCurrentBlock[2]:false),
                                'currentBucketSize' => $iCurrentBucketSize,
                                'currentlyBlocked' => $iCurrentBucketSize + (CONST_ConnectionBucket_Cost_Reverse) >= CONST_ConnectionBucket_BlockLimit,
                                );