Created
March 26, 2015 16:34
-
-
Save ofrobots/d725e7c2aa5fdafa8a13 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
var async_wrap = process.binding('async_wrap'); | |
var uid = 0; | |
var kCallInitHook = 0; | |
var asyncHooksObject = {}; | |
function asyncInit() { | |
this._asyncQueue = { uid: ++uid }; | |
process._rawDebug('init ' + this._asyncQueue.uid); | |
} | |
function asyncBefore() { | |
process._rawDebug('before: ' + this._asyncQueue.uid); | |
} | |
function asyncAfter() { | |
process._rawDebug('after: ' + this._asyncQueue.uid); | |
} | |
async_wrap.setupHooks(asyncHooksObject, asyncInit, asyncBefore, asyncAfter); | |
asyncHooksObject[kCallInitHook] = 1; | |
var net = require('net'); | |
var s = net.createServer(); | |
s.on('connection', function onConnection(c) { | |
c.end('Hello World\n'); | |
}); | |
s.listen(8000, function() { | |
// Don't want to trace the req making the conntion. Only the received | |
// req by the server. | |
asyncHooksObject[kCallInitHook] = 0; | |
// Create a connection for logging, then exit app. | |
net.connect(8000, function() { }); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Here's the annotated output