Skip to content

Commit

Permalink
src: all wraps now use actual FunctionTemplate
Browse files Browse the repository at this point in the history
Instead of simply creating a new v8::Object to contain the connection
information, instantiate a new instance of a FunctionTemplate. This will
allow future improvements for debugging and performance probes.

Additionally, the "provider" argument in the ReqWrap constructor is no
longer optional.

PR-URL: nodejs/node-v0.x-archive#8110
Signed-off-by: Trevor Norris <[email protected]>
Reviewed-by: Fedor Indutny <[email protected]>
Reviewed-by: Alexis Campailla <[email protected]>
Reviewed-by: Julien Gilli <[email protected]>
  • Loading branch information
trevnorris authored and piscisaureus committed Dec 9, 2014
1 parent 8f41db6 commit 819690f
Show file tree
Hide file tree
Showing 17 changed files with 407 additions and 168 deletions.
4 changes: 3 additions & 1 deletion lib/child_process.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ var assert = require('assert');
var util = require('util');

var Process = process.binding('process_wrap').Process;
var WriteWrap = process.binding('stream_wrap').WriteWrap;
var uv = process.binding('uv');

var spawn_sync; // Lazy-loaded process.binding('spawn_sync')
Expand Down Expand Up @@ -475,7 +476,8 @@ function setupChannel(target, channel) {
return;
}

var req = { oncomplete: nop };
var req = new WriteWrap();
req.oncomplete = nop;
var string = JSON.stringify(message) + '\n';
var err = channel.writeUtf8String(req, string, handle);

Expand Down
5 changes: 4 additions & 1 deletion lib/dgram.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ var events = require('events');
var constants = require('constants');

var UDP = process.binding('udp_wrap').UDP;
var SendWrap = process.binding('udp_wrap').SendWrap;

var BIND_STATE_UNBOUND = 0;
var BIND_STATE_BINDING = 1;
Expand Down Expand Up @@ -319,7 +320,9 @@ Socket.prototype.send = function(buffer,
self.emit('error', ex);
}
else if (self._handle) {
var req = { buffer: buffer, length: length }; // Keep reference alive.
var req = new SendWrap();
req.buffer = buffer; // Keep reference alive.
req.length = length;
if (callback) {
req.callback = callback;
req.oncomplete = afterSend;
Expand Down
26 changes: 14 additions & 12 deletions lib/dns.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ var util = require('util');
var cares = process.binding('cares_wrap');
var uv = process.binding('uv');

var GetAddrInfoReqWrap = cares.GetAddrInfoReqWrap;
var GetNameInfoReqWrap = cares.GetNameInfoReqWrap;

var isIp = net.isIP;


Expand Down Expand Up @@ -144,12 +147,11 @@ exports.lookup = function lookup(hostname, options, callback) {
return {};
}

var req = {
callback: callback,
family: family,
hostname: hostname,
oncomplete: onlookup
};
var req = new GetAddrInfoReqWrap();
req.callback = callback;
req.family = family;
req.hostname = hostname;
req.oncomplete = onlookup;

var err = cares.getaddrinfo(req, hostname, family, hints);
if (err) {
Expand Down Expand Up @@ -180,12 +182,12 @@ exports.lookupService = function(host, port, callback) {

callback = makeAsync(callback);

var req = {
callback: callback,
host: host,
port: port,
oncomplete: onlookupservice
};
var req = new GetNameInfoReqWrap();
req.callback = callback;
req.host = host;
req.port = port;
req.oncomplete = onlookupservice;

var err = cares.getnameinfo(req, host, port);
if (err) throw errnoException(err, 'getnameinfo', host);

Expand Down
Loading

0 comments on commit 819690f

Please sign in to comment.