Last active
December 27, 2015 21:49
-
-
Save tjfontaine/7394912 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
From 626c8ac5634c543a3e922e60c83b0e2dfdd5b094 Mon Sep 17 00:00:00 2001 | |
From: Timothy J Fontaine <[email protected]> | |
Date: Mon, 11 Nov 2013 02:09:12 +0000 | |
Subject: [PATCH] src: HandleWrap::OnClose needs HandleScope | |
--- | |
src/handle_wrap.cc | 1 + | |
1 file changed, 1 insertion(+) | |
diff --git a/src/handle_wrap.cc b/src/handle_wrap.cc | |
index a63421b..0839f24 100644 | |
--- a/src/handle_wrap.cc | |
+++ b/src/handle_wrap.cc | |
@@ -144,6 +144,7 @@ void HandleWrap::OnClose(uv_handle_t* handle) { | |
if (wrap->flags_ & kCloseCallback) { | |
assert(close_sym.IsEmpty() == false); | |
+ HandleScope scope; | |
MakeCallback(wrap->object_, close_sym, 0, NULL); | |
} | |
-- | |
1.8.3.1 |
This file contains hidden or 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
#!/usr/sbin/dtrace -s | |
pid$1::*HandleScopeC1*:entry | |
{ | |
self->cone++; | |
} | |
pid$1::*HandleScopeD1*:entry | |
/self->cone/ | |
{ | |
self->cone--; | |
} | |
pid$1::*HandleScopeC2*:entry | |
{ | |
self->ctwo++; | |
} | |
pid$1::*HandleScopeD2*:entry | |
/self->ctwo/ | |
{ | |
self->ctwo--; | |
} | |
pid$1::*_ZN4node12MakeCallbackEN2v86HandleINS0_6ObjectEEENS1_INS0_6StringEEEiPNS1_INS0_5ValueEEE*:entry | |
/self->cone < 1 || self->ctwo < 1/ | |
{ | |
@[jstack(200, 8000)] = count(); | |
} | |
tick-10s | |
{ | |
printf("one: %d, two: %d\n", self->cone, self->ctwo); | |
printa(@); | |
} |
This file contains hidden or 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
require('http').createServer(function(req, res) { | |
req.resume(); | |
res.end(); | |
}).listen(8000); |
This file contains hidden or 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
// Load modules | |
var Url = require('url'); | |
var Http = require('http'); | |
var ignore = function () { }; | |
var request = function (method, url, options, callback) { | |
var uri = Url.parse(url); | |
var timeoutId; | |
uri.method = method.toUpperCase(); | |
uri.headers = options.headers; | |
var req = Http.request(uri); | |
// Register handlers | |
var isFinished = false; | |
var finish = function (err, res) { | |
if (res) { | |
res.destroy(); | |
} | |
req.abort(); | |
if (!isFinished) { | |
isFinished = true; | |
req.removeAllListeners(); | |
req.on('error', ignore); | |
clearTimeout(timeoutId); | |
return callback(err, res); | |
} | |
}; | |
req.once('error', function (err) { | |
return finish(err); | |
}); | |
req.once('response', function (res) { | |
return finish(null, res); | |
}); | |
req.write(options.payload); | |
timeoutId = setTimeout(function () { | |
return finish(new Error('Client request timeout')); | |
}, 60000); | |
req.end(); | |
}; | |
var envelope = { | |
a: 1, | |
b: 'asd', | |
c: { | |
d: 123, | |
e: 'asd' | |
} | |
}; | |
var pending = 0; | |
var send = function () { | |
var options = { | |
headers: { | |
'content-type': 'application/json' | |
}, | |
payload: JSON.stringify(envelope) | |
}; | |
++pending; | |
request('post', 'http://localhost:8000/', options, function (err, res) { | |
--pending; | |
}); | |
}; | |
setInterval(function () { | |
for (var i = 0; i < 400; ++i) { | |
send(); | |
} | |
}, 1000); | |
var max = 0; | |
setInterval(gc, 500); | |
setInterval(function () { | |
var stats = process.memoryUsage(); | |
if (stats.rss > max) { | |
max = stats.rss; | |
console.log('ZOMG NEW RSS', max); | |
} | |
}, 1000); | |
setInterval(function () { | |
var stats = process.memoryUsage(); | |
console.log(stats.rss, stats.heapTotal, stats.heapUsed, pending); | |
}, 9997); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
15150 times
MakeCallback
was called without aHandleScope
fromOnClose