Author: michael
Date: Mon Feb  1 01:44:52 2010
New Revision: 8433

URL: http://svn.slimdevices.com/jive?rev=8433&view=rev
Log:
Bug: 15522
Description: wait up to 10 seconds for SBS to be stopped before continuing the 
firmware download. Always use kill() instead of os.execute() to stop SBS.

We still have to better handle out of memory issues in other cases (as seen on 
Radio too)

Modified:
    
7.5/trunk/squeezeplay/src/squeezeplay_fab4/share/applets/SqueezeCenter/SqueezeCenterApplet.lua
    
7.5/trunk/squeezeplay/src/squeezeplay_squeezeos/share/applets/SetupFirmwareUpgrade/SetupFirmwareUpgradeApplet.lua

Modified: 
7.5/trunk/squeezeplay/src/squeezeplay_fab4/share/applets/SqueezeCenter/SqueezeCenterApplet.lua
URL: 
http://svn.slimdevices.com/jive/7.5/trunk/squeezeplay/src/squeezeplay_fab4/share/applets/SqueezeCenter/SqueezeCenterApplet.lua?rev=8433&r1=8432&r2=8433&view=diff
==============================================================================
--- 
7.5/trunk/squeezeplay/src/squeezeplay_fab4/share/applets/SqueezeCenter/SqueezeCenterApplet.lua
 (original)
+++ 
7.5/trunk/squeezeplay/src/squeezeplay_fab4/share/applets/SqueezeCenter/SqueezeCenterApplet.lua
 Mon Feb  1 01:44:52 2010
@@ -265,28 +265,25 @@
                )
        end
 
-       os.execute("/etc/init.d/squeezecenter " .. action);
-
-end
-
-function stopSqueezeCenter(self)
-       -- first try the regular way
-       self:_stopServer(true)
-
-       -- try harder if this didn't work
-       if self:serverRunning() then
-
-               -- stop server
-               self:_killByPidFile("/var/run/squeezecenter.pid")
-               
-               -- stop resize helper daemon
-               self:_killByPidFile("/var/run/gdresized.pid")
-
-               -- stop scanner
---             local pid = _pidfor('scanner.pl')
---             if pid then
---                     squeezeos.kill(pid, 15)
---             end
+       if action == 'stop' then
+               -- don't use shell script, we might be out of memory
+               if self:serverRunning() then
+
+                       -- stop server
+                       self:_killByPidFile("/var/run/squeezecenter.pid")
+                       
+                       -- stop resize helper daemon
+                       self:_killByPidFile("/var/run/gdresized.pid")
+       
+                       -- stop scanner
+       --              local pid = _pidfor('scanner.pl')
+       --              if pid then
+       --                      squeezeos.kill(pid, 15)
+       --              end
+               end
+
+       else
+               os.execute("/etc/init.d/squeezecenter " .. action);
        end
 end
 
@@ -487,10 +484,15 @@
        if self:serverRunning() then
                -- attempt to stop SC
                log:debug('STOP SERVER')
-               self:_squeezecenterAction("icon_connecting", 
"STOPPING_SQUEEZECENTER", nil, 2000, "stop", silent)
-       end
-
-end
+               self:_squeezecenterAction("icon_connecting", 
"STOPPING_SQUEEZECENTER", nil, 3000, "stop", silent)
+       end
+
+end
+
+function stopSqueezeCenter(self)
+       self:_stopServer(true)
+end
+
 
 -- _unmountingDrive
 -- full screen popup that appears until unmounting is complete or failed

Modified: 
7.5/trunk/squeezeplay/src/squeezeplay_squeezeos/share/applets/SetupFirmwareUpgrade/SetupFirmwareUpgradeApplet.lua
URL: 
http://svn.slimdevices.com/jive/7.5/trunk/squeezeplay/src/squeezeplay_squeezeos/share/applets/SetupFirmwareUpgrade/SetupFirmwareUpgradeApplet.lua?rev=8433&r1=8432&r2=8433&view=diff
==============================================================================
--- 
7.5/trunk/squeezeplay/src/squeezeplay_squeezeos/share/applets/SetupFirmwareUpgrade/SetupFirmwareUpgradeApplet.lua
 (original)
+++ 
7.5/trunk/squeezeplay/src/squeezeplay_squeezeos/share/applets/SetupFirmwareUpgrade/SetupFirmwareUpgradeApplet.lua
 Mon Feb  1 01:44:52 2010
@@ -56,6 +56,8 @@
 
 
 local MEDIA_PATH = "/media/"
+local STOP_SERVER_TIMEOUT = 10
+
 
 module(..., Framework.constants)
 oo.class(_M, Applet)
@@ -472,12 +474,6 @@
 function _t_upgrade(self)
        Task:yield(true)
 
-       -- stop memory hungry services before upgrading
-       os.execute("/etc/init.d/squeezecenter stop");
-       os.execute("/etc/init.d/samba stop");
-
-       Task:yield(true)
-
        local upgrade = Upgrade()
        local t, err = upgrade:start(self.url,
                function(...)
@@ -543,11 +539,27 @@
 
        -- stop memory hungry services before upgrading
        if (System:getMachine() == "fab4") then
+
                appletManager:callService("stopSqueezeCenter")
-       end     
-
-       -- start the upgrade
-       Task("upgrade", self, _t_upgrade, _upgradeFailed):addTask()
+               os.execute("/etc/init.d/samba stop");
+
+               -- start the upgrade once SBS is shut down or timed out
+               local timeout = 0
+               self.serverStopTimer = self.popup:addTimer(1000, function()
+
+                       timeout = timeout + 1
+                       
+                       if timeout <= STOP_SERVER_TIMEOUT and 
appletManager:callService("isBuiltInSCRunning") then
+                               return
+                       end
+
+                       Task("upgrade", self, _t_upgrade, 
_upgradeFailed):addTask()
+                       
+                       self.popup:removeTimer(self.serverStopTimer)
+               end)
+       else
+               Task("upgrade", self, _t_upgrade, _upgradeFailed):addTask()
+       end
 
        self:tieAndShowWindow(self.popup)
        return window

_______________________________________________
Jive-checkins mailing list
[email protected]
http://lists.slimdevices.com/mailman/listinfo/jive-checkins

Reply via email to