Skip to content

Commit

Permalink
luvit: timer: avoid double close
Browse files Browse the repository at this point in the history
a timer could be closed twice if it is unenrolled and expires in the
same loop, make sure this doesn't happen
  • Loading branch information
Brandon Philips committed Aug 8, 2012
1 parent 53e5ad5 commit a8cd419
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions lib/luvit/timer.lua
Expand Up @@ -84,9 +84,13 @@ expiration = function(timer, msecs)
end
end
end
timer:stop()
timer:close()
lists[msecs] = nil
-- Remove the timer if it wasn't already
-- removed by unenroll
if lists[msecs] ~= nil then
timer:stop()
timer:close()
lists[msecs] = nil
end
end
end
Expand Down Expand Up @@ -116,6 +120,7 @@ local function unenroll(item)
local list = lists[item._idleTimeout]
if list and isEmpty(list) then
-- empty list
list:stop()
list:close()
lists[item._idleTimeout] = nil
end
Expand Down

0 comments on commit a8cd419

Please sign in to comment.