diff --git a/src/node_io_watcher.cc b/src/node_io_watcher.cc index 59afd7221d6..8ef841918fd 100644 --- a/src/node_io_watcher.cc +++ b/src/node_io_watcher.cc @@ -196,8 +196,8 @@ Handle IOWatcher::Set(const Arguments& args) { * */ -// To enable this debug output, do: -// echo "CPPFLAGS += -DDUMP_DEBUG" >> config.mak +// To enable this debug output, add '-DDUMP_DEBUG' to +// 'build/c4che/default.cache.py' and // make clean all #ifdef DUMP_DEBUG #define DEBUG_PRINT(fmt,...) do { \ @@ -215,7 +215,6 @@ void IOWatcher::Dump(EV_P_ ev_prepare *watcher, int revents) { HandleScope scope; - #define IOV_SIZE 10000 static struct iovec iov[IOV_SIZE]; diff --git a/test/fixtures/dumper2.js b/test/fixtures/dumper2.js index 4923bf9e867..a7a8e235a55 100644 --- a/test/fixtures/dumper2.js +++ b/test/fixtures/dumper2.js @@ -1,31 +1,62 @@ var assert =require('assert'); -var net = require('net'); var IOWatcher = process.binding('io_watcher').IOWatcher; +var net = require('net'); -var stdout = new net.Stream(1); -var w = stdout._writeWatcher; mb = 1024*1024; +N = 50; +expected = N * mb; +nread = 0; + +// Create a pipe +var fds = process.binding('net').pipe(); + +// Use writev/dumper to send data down the write end of the pipe, fds[1]. +// This requires a IOWatcher. +var w = new IOWatcher(); +w.set(fds[1], false, false); + +// The read end, fds[0], will be used to count how much comes through. +// This sets up a readable stream on fds[0]. +var stream = new net.Stream(); +stream.open(fds[0]); +stream.readable = true; +stream.resume(); + + +// Count the data as it arrives on the read end of the pipe. +stream.on('data', function (d) { + nread += d.length; + process.stdout.write("."); + + if (nread >= expected) { + //w.stop(); + // stream.destroy(); + console.error("\ndone"); + process.binding('net').close(fds[1]); + } +}); + + +// Create out single 1mb buffer. b = Buffer(mb); for (var i = 0; i < mb; i++) { b[i] = 100; } - +// Fill the dumpQueue with N copies of that buffer. IOWatcher.dumpQueue.next = w; var bucket = w.buckets = { data: b }; -for (var i = 0; i < 50; i++) { +for (var i = 0; i < N-1; i++) { bucket = bucket.next = { data: b }; } -/* Total size 50*(1024*1024) = 524288000 */ -setTimeout(function () { - // In the first 10 ms, we haven't pushed out the data. - assert.ok(null !== IOWatcher.dumpQueue.next); -}, 10); + process.on('exit', function () { - assert.ok(!IOWatcher.dumpQueue.next); + console.log("nread: %d", nread); + assert.equal(expected, nread); }); + diff --git a/test/pummel/test-dumper2.js b/test/pummel/test-dumper2.js deleted file mode 100644 index 26084e70b80..00000000000 --- a/test/pummel/test-dumper2.js +++ /dev/null @@ -1,28 +0,0 @@ -var common = require("../common"); -var assert = require("assert"); -var spawn = require('child_process').spawn; - -var script = require('path').join(common.fixturesDir, "dumper2.js"); - -var child = spawn(process.execPath, [script]); - -var size = 0; -child.stdout.on('data', function (d) { - assert.equal(100, d[0]); - process.stdout.write('.'); - size += d.length; -}); - -child.stderr.setEncoding('utf8'); -child.stderr.on('data', function (d) { - console.error(d); -}); - -child.on('exit', function (status) { - assert.equal(0, status); -}); - -process.on('exit', function () { - assert.equal(50*(1024*1024), size); -}); -