From 4a92dfaa65cd16ed8056115dd24dc4b2ee801501 Mon Sep 17 00:00:00 2001 From: Cloud Wu Date: Wed, 30 Apr 2014 12:23:15 +0800 Subject: [PATCH] multicast dispatch map should be weak --- lualib/multicast.lua | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/lualib/multicast.lua b/lualib/multicast.lua index 1664e844..502f8d21 100644 --- a/lualib/multicast.lua +++ b/lualib/multicast.lua @@ -3,17 +3,12 @@ local mc = require "multicast.c" local multicastd local multicast = {} -local dispatch = {} +local dispatch = setmetatable({} , {__mode = "kv" }) local chan = {} local chan_meta = { __index = chan, - __gc = function(self) - self:unsubscribe() - local c = self.channel - self.channel = nil - dispatch[c] = nil - end, + __gc = unsubscribe, __tostring = function (self) return string.format("[Multicast:%x]",self.channel) end,