From 73ee49f20460fe724258153aabcd61be8bc4f52f Mon Sep 17 00:00:00 2001 From: gnhb Date: Sat, 10 Apr 2010 20:28:59 +0700 Subject: [PATCH] Rework interface_bring_down function a bit. Remove un-needed unlink calls to mpd.links Moved three "unlink_if_exists" calls to happen after calling kill_by_pid for mpd processes. The unlinked files are useful during the process of brining down the mpd interfaces for calculating the link uptime in the "linkdown" script. --- etc/inc/interfaces.inc | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/etc/inc/interfaces.inc b/etc/inc/interfaces.inc index 65e3996f85..9dc9f9b9d7 100644 --- a/etc/inc/interfaces.inc +++ b/etc/inc/interfaces.inc @@ -816,24 +816,16 @@ function interface_bring_down($interface = "wan", $destroy = false) { $realif = get_real_interface($interface); - - /* remove interface up file if it exists */ - unlink_if_exists("{$g['tmp_path']}/{$realif}up"); - unlink_if_exists("{$g['vardb_path']}/{$interface}ip"); - unlink_if_exists("{$g['tmp_path']}/{$realif}_router"); - switch ($ifcfg['ipaddr']) { case "pppoe": killbypid("{$g['varrun_path']}/pppoe_{$interface}.pid"); sleep(2); unlink_if_exists("{$g['varetc_path']}/mpd_{$interface}.conf"); - unlink_if_exists("{$g['varetc_path']}/mpd_{$interface}.links"); break; case "pptp": killbypid("{$g['varrun_path']}/pptp_{$interface}.pid"); sleep(2); unlink_if_exists("{$g['varetc_path']}/mpd_{$interface}.conf"); - unlink_if_exists("{$g['varetc_path']}/mpd_{$interface}.links"); break; case "carpdev-dhcp": /* @@ -854,6 +846,8 @@ function interface_bring_down($interface = "wan", $destroy = false) { break; case "ppp": killbypid("{$g['varrun_path']}/ppp_{$interface}.pid"); + sleep(2); + unlink_if_exists("{$g['varetc_path']}/mpd_{$interface}.conf"); break; default: if(does_interface_exist("$realif")) { @@ -864,6 +858,11 @@ function interface_bring_down($interface = "wan", $destroy = false) { break; } + /* remove interface up file if it exists */ + unlink_if_exists("{$g['tmp_path']}/{$realif}up"); + unlink_if_exists("{$g['vardb_path']}/{$interface}ip"); + unlink_if_exists("{$g['tmp_path']}/{$realif}_router"); + /* hostapd and wpa_supplicant do not need to be running when the interface is down. * They will also use 100% CPU if running after the wireless clone gets deleted. */ if (is_array($ifcfg['wireless'])) {