[pkg-wpa-devel] [PATCH] remove bitrotted locking code
Jason Lunz
lunz at falooley.org
Sun Sep 24 02:34:23 UTC 2006
In figuring out why my wpa_cli/wpa_action kept getting into endless
loops, I looked at the locking code and noticed that it doesn't seem to
do anything useful. This patch removes it.
wpa_action_wait is clearly a noop - it does nothing unless the file
$WPA_LOCKFILE exists, but the $WPA_LOCKFILE variable is never set.
wpa_action_unlock is a noop by the same reasoning. The only reason the
lockfile is ever being deleted was that init_wpa_cli and kill_wpa_cli
do so when they are called by ifupdown.sh in response to interface
post-up and pre-down hooks. This is clearly unintentional, since it
unlocks before the (impotent) call to wpa_action_unlock.
The stated purpose of this stuff is, according to the changelog, to help
with infinite event loops like mine:
wpasupplicant (0.5.4-3) unstable; urgency=low
* ...
* Implement basic locking for wpa_action action's for when the user callable
"stop" action is executed while wpa_action is busy configuring the device.
The wpa_cli daemon is killed, then wpa_action waits for the current action
to finish gracefully before killing wpa_suppliant. This helps avoid
inconsistencies with ifupdown when volatile conditions are experienced as
part of the roaming setup (for example, driver problems causing connection
loops).
It didn't help my case at all; it only made it more confusing to find a
working solution. Better to delete this code.
Jason
---
debian/functions.sh | 44 --------------------------------------------
debian/wpa_action.sh | 5 -----
2 files changed, 49 deletions(-)
Index: wpasupplicant-0.5.5/debian/functions.sh
===================================================================
--- wpasupplicant-0.5.5.orig/debian/functions.sh
+++ wpasupplicant-0.5.5/debian/functions.sh
@@ -26,7 +26,6 @@
WPA_CLI_BIN="/sbin/wpa_cli"
WPA_CLI_PNAME="wpa_cli"
WPA_CLI_PIDFILE="/var/run/wpa_action.$IFACE.pid"
-WPA_CLI_LOCKFILE="/var/lock/wpa_action.$IFACE.lock"
WPA_CLI_LOGFILE="/var/log/wpa_action.log"
WPA_CLI_HYSTERESIS="/var/run/wpa_action.$IFACE.timestamp"
@@ -276,10 +275,6 @@
if [ -n "$WPA_ACTION_SCRIPT" ]; then
WPA_CLI_OPTIONS="-B -P $WPA_CLI_PIDFILE -i $IFACE"
- if [ -e "$WPA_CLI_LOCKFILE" ]; then
- rm -f "$WPA_CLI_LOCKFILE"
- fi
-
wpa_msg verbose "$WPA_CLI_BIN $WPA_CLI_OPTIONS -p $WPA_CTRL_DIR -a $WPA_ACTION_SCRIPT"
start-stop-daemon --start --oknodo $DAEMON_VERBOSITY \
@@ -309,10 +304,6 @@
if [ -f "$WPA_CLI_PIDFILE" ]; then
rm -f "$WPA_CLI_PIDFILE"
fi
-
- if [ -f "$WPA_CLI_LOCKFILE" ]; then
- rm -f "$WPA_CLI_LOCKFILE"
- fi
fi
}
@@ -648,41 +639,6 @@
fi
}
-#####################################################################
-## wpa_action basic locking mechanism
-# Locking each action improves situations that are encountered when
-# things go wrong (association storm and other driver problems)
-#
-wpa_action_lock () {
- if ! (umask 222; echo "$$" >"$WPA_CLI_LOCKFILE") 2>/dev/null; then
- echo "$0 is locked on $IFACE, \"$WPA_ACTION\" ACTION aborted"
- exit 0
- fi
-}
-
-# wait - for interactive commands
-wpa_action_wait () {
- if [ -e "$WPA_LOCKFILE" ]; then
- local ACTION_WAIT="0" MAX_ACTION_WAIT="60"
- echo "Waiting for current ACTION to finish (max. ${MAX_ACTION_WAIT}s) before processing \"$WPA_ACTION\""
- until [ ! -e "$WPA_LOCKFILE" ]; do
- if [ "$ACTION_WAIT" -ge "$MAX_ACTION_WAIT" ]; then
- rm -f "$WPA_LOCKFILE"
- else
- ACTION_WAIT=$(($ACTION_WAIT + 1))
- fi
- sleep 1
- done
- fi
-}
-
-# remove lockfile
-wpa_action_unlock () {
- if [ -e "$WPA_LOCKFILE" ]; then
- rm -f "$WPA_CLI_LOCKFILE"
- fi
-}
-
# with some wireless drivers (bcm43xx), the act of using tools like ifupdown or
# dhcp clients in response to CONNECTED/DISCONNECTED events can provoke further
# events, leading to endless loops.
Index: wpasupplicant-0.5.5/debian/wpa_action.sh
===================================================================
--- wpasupplicant-0.5.5.orig/debian/wpa_action.sh
+++ wpasupplicant-0.5.5/debian/wpa_action.sh
@@ -39,7 +39,6 @@
"CONNECTED")
wpa_log_init
wpa_hysteresis_check
- wpa_action_lock
wpa_log_action
wpa_log_environment
if ifupdown_check; then
@@ -47,26 +46,22 @@
fi
wpa_cli status
wpa_hysteresis_event
- wpa_action_unlock
;;
"DISCONNECTED")
wpa_log_init
wpa_hysteresis_check
- wpa_action_lock
wpa_log_action
wpa_log_environment
if ifupdown_check; then
ifdown
if_post_down_up
fi
- wpa_action_unlock
;;
"stop"|"down")
test_wpa_supplicant || exit 1
kill_wpa_cli
- wpa_action_wait
if ifupdown_check; then
ifdown
fi
More information about the Pkg-wpa-devel
mailing list