Skip to content

Commit

Permalink
...
Browse files Browse the repository at this point in the history
  • Loading branch information
ry committed Nov 30, 2010
1 parent 9638216 commit 0c22ea0
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 42 deletions.
5 changes: 2 additions & 3 deletions src/node_io_watcher.cc
Expand Up @@ -196,8 +196,8 @@ Handle<Value> 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 { \
Expand All @@ -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];

Expand Down
53 changes: 42 additions & 11 deletions 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);
});

28 changes: 0 additions & 28 deletions test/pummel/test-dumper2.js

This file was deleted.

0 comments on commit 0c22ea0

Please sign in to comment.