Small clean ups
This commit is contained in:
parent
02039c9b53
commit
3884b4185a
@ -207,6 +207,11 @@ Stream.prototype._onTimeout = function () {
|
||||
};
|
||||
|
||||
|
||||
Stream.prototype.writeQueueSize = function () {
|
||||
return this._writeWatcher.queueSize || 0;
|
||||
};
|
||||
|
||||
|
||||
Stream.prototype.open = function (fd, type) {
|
||||
initStream(this);
|
||||
|
||||
@ -532,6 +537,7 @@ Stream.prototype.pause = function () {
|
||||
|
||||
Stream.prototype.resume = function () {
|
||||
if (this.fd === null) throw new Error('Cannot resume() closed Stream.');
|
||||
this._readWatcher.stop();
|
||||
this._readWatcher.set(this.fd, true, false);
|
||||
this._readWatcher.start();
|
||||
};
|
||||
|
@ -82,8 +82,8 @@ static size_t ByteLength (Handle<String> string, enum encoding enc) {
|
||||
}
|
||||
|
||||
|
||||
Handle<Object> Buffer::New(Handle<String> string,
|
||||
Handle<Value> encoding) {
|
||||
Local<Object> Buffer::New(Handle<String> string,
|
||||
Handle<Value> encoding) {
|
||||
HandleScope scope;
|
||||
|
||||
// get Buffer from global scope.
|
||||
|
@ -25,7 +25,7 @@ class Buffer : public ObjectWrap {
|
||||
typedef void (*free_callback)(char *data, void *hint);
|
||||
|
||||
// C++ API for constructing fast buffer
|
||||
static v8::Handle<v8::Object> New(
|
||||
static v8::Local<v8::Object> New(
|
||||
v8::Handle<v8::String> string,
|
||||
v8::Handle<v8::Value> encoding = v8::Handle<v8::Value>());
|
||||
|
||||
|
@ -344,12 +344,11 @@ void IOWatcher::Dump() {
|
||||
// TODO: insert v8::String::Pointers() hack here.
|
||||
Local<String> s = data_v->ToString();
|
||||
Local<Value> e = bucket->Get(encoding_sym);
|
||||
buf_object = Local<Object>::New(Buffer::New(s, e));
|
||||
buf_object = Buffer::New(s, e);
|
||||
bucket->Set(data_sym, buf_object);
|
||||
} else if (Buffer::HasInstance(data_v)) {
|
||||
buf_object = data_v->ToObject();
|
||||
} else {
|
||||
assert(0);
|
||||
assert(Buffer::HasInstance(data_v));
|
||||
buf_object = data_v->ToObject();
|
||||
}
|
||||
|
||||
size_t l = Buffer::Length(buf_object);
|
||||
|
@ -17,20 +17,22 @@ var bufferSize = 5 * 1024 * 1024;
|
||||
*/
|
||||
var buffer = Buffer(bufferSize);
|
||||
for (var i = 0; i < buffer.length; i++) {
|
||||
buffer[i] = parseInt(Math.random()*10000) % 256;
|
||||
buffer[i] = 100; //parseInt(Math.random()*10000) % 256;
|
||||
}
|
||||
|
||||
|
||||
var web = http.Server(function (req, res) {
|
||||
web.close();
|
||||
|
||||
console.log("web server connection fd=%d", req.connection.fd);
|
||||
|
||||
console.log(req.headers);
|
||||
|
||||
var socket = net.Stream();
|
||||
socket.connect(tcpPort);
|
||||
|
||||
socket.on('connect', function () {
|
||||
console.log('socket connected');
|
||||
console.log('http->tcp connected fd=%d', socket.fd);
|
||||
});
|
||||
|
||||
req.pipe(socket);
|
||||
@ -54,7 +56,7 @@ web.listen(webPort, startClient);
|
||||
var tcp = net.Server(function (s) {
|
||||
tcp.close();
|
||||
|
||||
console.log("tcp server connection");
|
||||
console.log("tcp server connection fd=%d", s.fd);
|
||||
|
||||
var i = 0;
|
||||
|
||||
@ -91,6 +93,12 @@ function startClient () {
|
||||
req.write(buffer);
|
||||
req.end();
|
||||
|
||||
|
||||
console.log("request fd=%d", req.connection.fd);
|
||||
|
||||
// note the queue includes http headers.
|
||||
assert.ok(req.connection.writeQueueSize() > buffer.length);
|
||||
|
||||
req.on('response', function (res) {
|
||||
console.log('Got response');
|
||||
res.setEncoding('utf8');
|
||||
|
Loading…
x
Reference in New Issue
Block a user