Skip to content

Instantly share code, notes, and snippets.

@rphillips
Created August 7, 2012 21:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rphillips/f8fe1913369298e4a1f3 to your computer and use it in GitHub Desktop.
Save rphillips/f8fe1913369298e4a1f3 to your computer and use it in GitHub Desktop.
diff --git a/lib/luvit/uv.lua b/lib/luvit/uv.lua
index 74fbc3c..5ceef7b 100644
--- a/lib/luvit/uv.lua
+++ b/lib/luvit/uv.lua
@@ -23,7 +23,14 @@ uv.Handle = Handle
-- Wrapper around `uv_close`. Closes the underlying file descriptor of a handle.
-- Handle:close()
-Handle.close = native.close
+Handle.close = function(self)
+ if self._closed then
+ process.stdout.write('Double close detected\n')
+ return
+ end
+ native.close(self)
+ self._closed = true
+end
--[[
This is used by Emitters to register with native events when the first listener
@@ -241,7 +248,6 @@ uv.Timer = Timer
function Timer:initialize()
self.userdata = native.newTimer()
self._active = false
- self._closed = false
end
function Timer:_update()
@@ -255,13 +261,6 @@ function Timer:start(timeout, interval, callback)
self:_update()
end
-function Timer:close()
- if not self._closed then
- Handle.close(self)
- end
- self._closed = true
-end
-
-- Timer:stop()
function Timer:stop()
native.timerStop(self)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment