Changeset 16744

Show
Ignore:
Timestamp:
06/30/08 16:46:39 (3 months ago)
Author:
rambo
Message:

forward port r16742 & r16743

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/midcom/midcom.helper.replicator/queuemanager.php

    r16736 r16744  
    1313class midcom_helper_replicator_queuemanager extends midcom_baseclasses_components_purecode 
    1414{ 
     15    var $max_queues_per_pass = 10; 
    1516    var $exporters = array(); 
    1617    var $transporters = array(); 
     
    675676        while (($queue_name = readdir($dp_queues)) !== false) 
    676677        { 
     678            // limit the amount of queues we process per subscription per request 
    677679            $queues[$queue_name] = $queue_name; 
    678680        } 
    679681        closedir($dp_queues); 
    680         uksort($queues, array($this, '_process_queue_sort_items')); 
    681         reset($queues); 
    682  
     682        /* 
     683        debug_push_class(__CLASS__, __FUNCTION__); 
     684        debug_print_r('$queues before sort: ', $queues); 
     685        */ 
     686        // ksort is enough here 
     687        ksort($queues); 
     688        /* 
     689        debug_print_r('$queues after sort: ', $queues); 
     690        debug_pop(); 
     691        */ 
     692 
     693        $i = 0; 
    683694        foreach ($queues as $queue_name) 
    684695        { 
     696            // Limit the amount of queues we process per request to avoid leaking memory 
     697            ++$i; 
     698            if ($i > $this->max_queues_per_pass) 
     699            { 
     700                debug_push_class(__CLASS__, __FUNCTION__); 
     701                debug_add("Queue limit of {$this->max_queues_per_pass} reached, breaking out of loop.", MIDCOM_LOG_INFO); 
     702                debug_pop(); 
     703                break; 
     704            } 
    685705            if ($this->_process_queue_queuepath($queue_name, $subscription_path, $subscription) === false) 
    686706            { 
     
    764784    function safe_sg_name($sitegroup = null) 
    765785    { 
     786        static $sg_obj_cache = array(); 
    766787        if (is_null($sitegroup)) 
    767788        { 
     
    773794            return 'sg0'; 
    774795        } 
    775          
    776         $sg = mgd_get_sitegroup($sitegroup); 
     796        if (!isset($sg_obj_cache[$sitegroup])) 
     797        { 
     798            $sg_obj_cache[$sitegroup] = mgd_get_sitegroup($sitegroup); 
     799        } 
     800        $sg =& $sg_obj_cache[$sitegroup]; 
    777801        if (   !is_object($sg) 
    778802            || empty($sg->name))