Increase performance of filter_configure_sync



  • For systems with a lot of firewall rules, filter_configure_sync() in /etc/inc/filter.inc could be sped up by adding break; after line 102, so that you end up with:

        100                         foreach($config['filter']['rule'] as $rule) {
        101                                 if($rule['sched'])
        102                                         $time_based_rules = true;
        103                                         break;
        104                         }
    

    This way, once it finds a match and sets $time_based_rules, it doesn't keep searching through the rules…of which there might be many...just a suggestion...



  • It was early in the morning…I didn't notice that since the if statement only had one action, there were no brackets...the way I wrote it, it'll completely screw up.  Below is a corrected version.

        100                         foreach($config['filter']['rule'] as $rule) {
        101                                 if($rule['sched']) {
        102                                         $time_based_rules = true;
        103                                         break;
        104                                 }
        104                         }
    


  • thx for reminding this i forgot and that is not the best fix ;)



  • What is?  I'm always interested in learning.  :)



  • Short answer, no need to do the loop at all :D ::)


Log in to reply