diff options
author | Scott Ullrich <sullrich@pfsense.org> | 2005-05-31 22:54:09 +0000 |
---|---|---|
committer | Scott Ullrich <sullrich@pfsense.org> | 2005-05-31 22:54:09 +0000 |
commit | d6caad17bba4980ce5b68a8e4f94cd338009c866 (patch) | |
tree | 77861a4976820b30cb1b056965457736b3e52ef7 /etc | |
parent | 10655b3c779e3d2c9278ed3a983ca3587ad03a20 (diff) | |
download | pfsense-d6caad17bba4980ce5b68a8e4f94cd338009c866.zip pfsense-d6caad17bba4980ce5b68a8e4f94cd338009c866.tar.gz |
Cache the contents of find_carp_interface() to speed up subsequent requests
Diffstat (limited to 'etc')
-rw-r--r-- | etc/inc/pfsense-utils.inc | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/etc/inc/pfsense-utils.inc b/etc/inc/pfsense-utils.inc index 2f3b7f7..6641905 100644 --- a/etc/inc/pfsense-utils.inc +++ b/etc/inc/pfsense-utils.inc @@ -401,13 +401,19 @@ function get_pfsync_interface_status($pfsyncinterface) { * find_carp_interface($ip): return the carp interface where an ip is defined */ function find_carp_interface($ip) { - $num_carp_ints = find_number_of_created_carp_interfaces(); - for($x=0; $x<$num_carp_ints; $x++) { - $result = does_interface_exist("carp{$x}"); - if($result <> true) return; - $ifconfig = exec_command("/sbin/ifconfig carp{$x}"); - if(stristr($ifconfig,$ip)) - return "carp" . $x; + global $find_carp_ifconfig; + if($find_carp_ifconfig == "") { + $find_carp_ifconfig = array(); + $num_carp_ints = find_number_of_created_carp_interfaces(); + for($x=0; $x<$num_carp_ints; $x++) { + $find_carp_ifconfig[$x] = exec_command("/sbin/ifconfig carp{$x}"); + } + } + $carps = 0; + foreach($find_carp_ifconfig as $fci) { + if(stristr($fci, $ip) == true) + return "carp{$carps}"; + $carps++; } } |