-
-
Save rphillips/f8fe1913369298e4a1f3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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