More #6424 cleanups (#6442)

* Simplify logic, and more detailed debug logging
* Kill Nickel's FIFO on startup
Avoids udev/udhcpc scripts hanging when trying to open() it.
reviewable/pr6464/r1
NiLuJe 4 years ago committed by GitHub
parent fc35c6acc8
commit 2ad976387d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -359,7 +359,7 @@ function Kobo:init()
self.input.open("/dev/input/event0") -- Various HW Buttons, Switches & Synthetic NTX events
self.input.open("/dev/input/event1")
-- fake_events is only used for usb plug event so far
-- NOTE: usb hotplug event is also available in /tmp/nickel-hardware-status
-- NOTE: usb hotplug event is also available in /tmp/nickel-hardware-status (... but only when Nickel is running ;p)
self.input.open("fake_events")
if not self.needsTouchScreenProbe() then

@ -140,18 +140,21 @@ function NetworkListener:_scheduleActivityCheck()
local tx_packets = NetworkListener:_getTxPackets()
if self._last_tx_packets then
-- Compute noise margin based on the current delay
-- Compute noise threshold based on the current delay
local delay = self._activity_check_delay or default_network_timeout_seconds
local noise = delay / default_network_timeout_seconds * network_activity_noise_margin
local noise_threshold = delay / default_network_timeout_seconds * network_activity_noise_margin
local delta = tx_packets - self._last_tx_packets
-- If there was no meaningful activity (+/- a couple packets), kill the Wi-Fi
if math.max(0, tx_packets - noise) <= self._last_tx_packets then
logger.dbg("NetworkListener: No meaningful network activity ( then:", self._last_tx_packets, "vs. now:", tx_packets, "), disabling Wi-Fi")
if delta <= noise_threshold then
logger.dbg("NetworkListener: No meaningful network activity (delta:", delta, "<= threshold:", noise_threshold, "[ then:", self._last_tx_packets, "vs. now:", tx_packets, "]) -> disabling Wi-Fi")
keep_checking = false
local complete_callback = function()
UIManager:broadcastEvent(Event:new("NetworkDisconnected"))
end
NetworkMgr:turnOffWifi(complete_callback)
-- NOTE: We leave wifi_was_on as-is on purpose, we wouldn't want to break auto_restore_wifi workflows on the next start...
else
logger.dbg("NetworkListener: Significant network activity (delta:", delta, "> threshold:", noise_threshold, "[ then:", self._last_tx_packets, "vs. now:", tx_packets, "]) -> keeping Wi-Fi enabled")
end
end

@ -14,6 +14,7 @@ fi
# NOTE: dhcpcd -k waits for the signalled process to die, but busybox's killall doesn't have a -w, --wait flag,
# so we have to wait for udhcpc to die ourselves...
# NOTE: But if all is well, there *isn't* any udhcpc process or script left to begin with...
kill_timeout=0
while pkill -0 udhcpc; do
# Stop waiting after 5s

@ -115,6 +115,19 @@ if [ "${VIA_NICKEL}" = "true" ]; then
# A SIGTERM does not break anything, it'll just prevent automatic lease renewal until the time
# KOReader actually sets the if up itself (i.e., it'll do)...
killall -q -TERM nickel hindenburg sickel fickel adobehost dhcpcd-dbus dhcpcd fmon
# Wait for Nickel to die... (oh, procps with killall -w, how I miss you...)
kill_timeout=0
while pkill -0 nickel; do
# Stop waiting after 4s
if [ ${kill_timeout} -ge 15 ]; then
break
fi
usleep 250000
kill_timeout=$((kill_timeout + 1))
done
# Remove Nickel's FIFO to avoid udev & udhcpc scripts hanging on open() on it...
rm -f /tmp/nickel-hardware-status
fi
# fallback for old fmon, KFMon and advboot users (-> if no args were passed to the script, start the FM)

@ -35,6 +35,7 @@ if lsmod | grep -q sdio_wifi_pwr; then
fi
# NOTE: dhcpcd -k waits for the signalled process to die, but busybox's killall doesn't have a -w, --wait flag,
# so we have to wait for udhcpc to die ourselves...
# NOTE: But if all is well, there *isn't* any udhcpc process or script left to begin with...
kill_timeout=0
while pkill -0 udhcpc; do
# Stop waiting after 5s

@ -15,6 +15,7 @@ fi
# NOTE: dhcpcd -k waits for the signalled process to die, but busybox's killall doesn't have a -w, --wait flag,
# so we have to wait for udhcpc to die ourselves...
# NOTE: But if all is well, there *isn't* any udhcpc process or script left to begin with...
kill_timeout=0
while pkill -0 udhcpc; do
# Stop waiting after 5s

Loading…
Cancel
Save