We don't need to kill any processes in failsafe, because we are already at
a low memory footprint. This patch fix also sysupgrade in failsafe. sysupgrade
in failsafe was broken because it kills all processes. It also kills the lock
which keeps the device in rescue modus and prevent procd from continuing
booting. procd continues now the boot process until it get stuck
in initd/preinit.c:spawn_procd() because it find out that a sysupgrade is
happening and is going to sleep() inside a while(true) loop.

Now we have:
sysupgrade flashing the device,
procd sleep()ing inside a while(true) loop.

Because procd is in the while(true) loop, the hw watchdog doesn't receive
anymore refreshes and reboot the device after 30 seconds. This is usually
faster than flashing the device.

Signed-off-by: Alexander Couzens <lyn...@fe80.eu>
---
 package/base-files/Makefile              |  2 +-
 package/base-files/files/sbin/sysupgrade | 10 +++++++---
 2 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/package/base-files/Makefile b/package/base-files/Makefile
index 0160e41..d6c5938 100644
--- a/package/base-files/Makefile
+++ b/package/base-files/Makefile
@@ -11,7 +11,7 @@ include $(INCLUDE_DIR)/kernel.mk
 include $(INCLUDE_DIR)/version.mk
 
 PKG_NAME:=base-files
-PKG_RELEASE:=149
+PKG_RELEASE:=150
 
 PKG_FILE_DEPENDS:=$(PLATFORM_DIR)/ $(GENERIC_PLATFORM_DIR)/base-files/
 PKG_BUILD_DEPENDS:=opkg/host
diff --git a/package/base-files/files/sbin/sysupgrade 
b/package/base-files/files/sbin/sysupgrade
index 56e9a92..106b9f1 100755
--- a/package/base-files/files/sbin/sysupgrade
+++ b/package/base-files/files/sbin/sysupgrade
@@ -210,9 +210,13 @@ run_hooks "" $sysupgrade_pre_upgrade
 ubus call system upgrade
 touch /tmp/sysupgrade
 
-kill_remaining TERM
-sleep 3
-kill_remaining KILL
+if [ ! -f /tmp/failsafe ] ; then
+       kill_remaining TERM
+       sleep 3
+       kill_remaining KILL
+else
+       v "In failsafe mode: do not kill anything"
+fi
 
 if [ -n "$(rootfs_type)" ]; then
        v "Switching to ramdisk..."
-- 
1.8.5.2
_______________________________________________
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel

Reply via email to