Author: titmuss
Date: Thu Jun 12 03:52:23 2008
New Revision: 2558

URL: http://svn.slimdevices.com?rev=2558&root=Jive&view=rev
Log:
Bug: 6683
Description:

IMPORTANT: Made the jnt subscriptions weak, so if the function subscribing goes 
out of 
scope then the subscription is automatically cancelled.

All code the subscribes using the jnt needs reviewing to see if it breaks.

This change is needed to make sure objects like SlimServer get correctly 
garbage collected 
when on longer required (in this case when the SC is stopped). The jnt 
subscription was 
keeping the object alive in the garbage collector.

This change will cause problems if you subscribe a closure and don't keep a 
reference to 
the closure in the calling code. I decided that the new behaviour is correct, 
because 
previously any unreferenced closure actually created a memory leak.


Modified:
    
7.1/branches/discovery-refactor/squeezeplay/src/squeezeplay/share/applets/SqueezeDiscovery/SqueezeDiscoveryApplet.lua
    
7.1/branches/discovery-refactor/squeezeplay/src/squeezeplay/share/jive/AppletManager.lua
    
7.1/branches/discovery-refactor/squeezeplay/src/squeezeplay/share/jive/net/NetworkThread.lua

Modified: 
7.1/branches/discovery-refactor/squeezeplay/src/squeezeplay/share/applets/SqueezeDiscovery/SqueezeDiscoveryApplet.lua
URL: 
http://svn.slimdevices.com/7.1/branches/discovery-refactor/squeezeplay/src/squeezeplay/share/applets/SqueezeDiscovery/SqueezeDiscoveryApplet.lua?rev=2558&root=Jive&r1=2557&r2=2558&view=diff
==============================================================================
--- 
7.1/branches/discovery-refactor/squeezeplay/src/squeezeplay/share/applets/SqueezeDiscovery/SqueezeDiscoveryApplet.lua
 (original)
+++ 
7.1/branches/discovery-refactor/squeezeplay/src/squeezeplay/share/applets/SqueezeDiscovery/SqueezeDiscoveryApplet.lua
 Thu Jun 12 03:52:23 2008
@@ -38,6 +38,7 @@
 local Player        = require("jive.slim.Player")
 local SlimServer    = require("jive.slim.SlimServer")
 
+local debug         = require("jive.utils.debug")
 local log           = require("jive.utils.log").logger("applets.setup")
 
 local jnt           = jnt
@@ -239,13 +240,15 @@
 
 
 function _debug(self)
+       local now = Framework:getTicks()
+
        log:warn("state=", self.state)
        log:warn("currentPlayer=", self.currentPlayer)
        if self.currentPlayer then
                log:warn("activeServer=", self.currentPlayer:getSlimServer())
        end
        for i, server in SlimServer.iterate() do
-               log:warn(" server=", server:getName(), " connected=", 
server:isConnected())
+               log:warn(" server=", server:getName(), " connected=", 
server:isConnected(), " lastseen=", now - server:getLastSeen())
        end
 end
 

Modified: 
7.1/branches/discovery-refactor/squeezeplay/src/squeezeplay/share/jive/AppletManager.lua
URL: 
http://svn.slimdevices.com/7.1/branches/discovery-refactor/squeezeplay/src/squeezeplay/share/jive/AppletManager.lua?rev=2558&root=Jive&r1=2557&r2=2558&view=diff
==============================================================================
--- 
7.1/branches/discovery-refactor/squeezeplay/src/squeezeplay/share/jive/AppletManager.lua
 (original)
+++ 
7.1/branches/discovery-refactor/squeezeplay/src/squeezeplay/share/jive/AppletManager.lua
 Thu Jun 12 03:52:23 2008
@@ -57,6 +57,15 @@
 -- applet services
 local _services = {}
 
+-- allowed applets, can be used for debugging to limit applets loaded
+--[[
+local allowedApplets = {
+       DefaultSkin = true,
+       SqueezeDiscovery = true,
+}
+--]]
+
+
 
 -- _init
 -- creates an AppletManager object
@@ -72,6 +81,10 @@
 local function _saveApplet(name, dir)
        log:debug("Found applet ", name, " in ", dir)
        
+       if allowedApplets and not allowedApplets[name] then
+               return
+       end
+
        if not _appletsDb[name] then
        
                local newEntry = {
@@ -284,8 +297,10 @@
        -- sound is played without delay.
        -- FIXME make the startup order of applet configurable
        local soundEffectsEntry = _appletsDb["SetupSoundEffects"]
-       _loadMeta(soundEffectsEntry)
-       _evalMeta(soundEffectsEntry)
+       if soundEffectsEntry then
+               _loadMeta(soundEffectsEntry)
+               _evalMeta(soundEffectsEntry)
+       end
 
        _loadMetas()
        _evalMetas()

Modified: 
7.1/branches/discovery-refactor/squeezeplay/src/squeezeplay/share/jive/net/NetworkThread.lua
URL: 
http://svn.slimdevices.com/7.1/branches/discovery-refactor/squeezeplay/src/squeezeplay/share/jive/net/NetworkThread.lua?rev=2558&root=Jive&r1=2557&r2=2558&view=diff
==============================================================================
--- 
7.1/branches/discovery-refactor/squeezeplay/src/squeezeplay/share/jive/net/NetworkThread.lua
 (original)
+++ 
7.1/branches/discovery-refactor/squeezeplay/src/squeezeplay/share/jive/net/NetworkThread.lua
 Thu Jun 12 03:52:23 2008
@@ -29,7 +29,7 @@
 
 
 -- stuff we use
-local _assert, tostring, table, ipairs, pairs, pcall, select, type  = _assert, 
tostring, table, ipairs, pairs, pcall, select, type
+local _assert, tostring, table, ipairs, pairs, pcall, select, setmetatable, 
type  = _assert, tostring, table, ipairs, pairs, pcall, select, setmetatable, 
type
 
 local io                = require("io")
 local os                = require("os")
@@ -387,6 +387,9 @@
                activeCount = 0,
        })
 
+       -- subscriptions are gc weak
+       setmetatable(obj.subscribers, { __mode = 'k' })
+
        -- create dns resolver
        DNS(obj)
 

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

Reply via email to