Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorRyan Dahl <ry@tinyclouds.org>2010-11-13 03:24:53 +0300
committerRyan Dahl <ry@tinyclouds.org>2010-11-19 03:47:38 +0300
commitfa556a142512ab932b7359760e5e4585e4e035b6 (patch)
tree00a1ab1f741fb84190d14c99a2b90a9592cbcc2c /test
parenta6d84253824694b6e6ec148ec57cb344727d3a84 (diff)
Add callback to socket.write(), fix test-sendfds
Diffstat (limited to 'test')
-rw-r--r--test/fixtures/recvfd.js16
-rw-r--r--test/simple/test-sendfd.js17
2 files changed, 15 insertions, 18 deletions
diff --git a/test/fixtures/recvfd.js b/test/fixtures/recvfd.js
index 09b2864b7ed..8f064693895 100644
--- a/test/fixtures/recvfd.js
+++ b/test/fixtures/recvfd.js
@@ -22,35 +22,33 @@ function processData(s) {
// version of our modified object back. Clean up when we're done.
var pipeStream = new net.Stream(fd);
- var drainFunc = function() {
+ pipeStream.resume();
+
+ pipeStream.write(JSON.stringify(d) + '\n', function () {
pipeStream.destroy();
if (++numSentMessages == 2) {
s.destroy();
}
- };
-
- pipeStream.addListener('drain', drainFunc);
- pipeStream.resume();
-
- if (pipeStream.write(JSON.stringify(d) + '\n')) {
- drainFunc();
- }
+ });
};
// Create a UNIX socket to the path defined by argv[2] and read a file
// descriptor and misc data from it.
var s = new net.Stream();
+
s.addListener('fd', function(fd) {
receivedFDs.unshift(fd);
processData(s);
});
+
s.addListener('data', function(data) {
data.toString('utf8').trim().split('\n').forEach(function(d) {
receivedData.unshift(JSON.parse(d));
});
processData(s);
});
+
s.connect(process.argv[2]);
// vim:ts=2 sw=2 et
diff --git a/test/simple/test-sendfd.js b/test/simple/test-sendfd.js
index 7ed7b02c1a9..8052a136673 100644
--- a/test/simple/test-sendfd.js
+++ b/test/simple/test-sendfd.js
@@ -53,7 +53,7 @@ var logChild = function(d) {
d.split('\n').forEach(function(l) {
if (l.length > 0) {
- common.debug('CHILD: ' + l);
+ console.error('CHILD: ' + l);
}
});
};
@@ -96,19 +96,18 @@ var srv = net.createServer(function(s) {
buf.write(JSON.stringify(DATA) + '\n', 'utf8');
s.write(str, 'utf8', pipeFDs[1]);
- if (s.write(buf, undefined, pipeFDs[1])) {
+
+ s.write(buf, pipeFDs[1], function () {
+ console.error("close pipeFDs[1]");
netBinding.close(pipeFDs[1]);
- } else {
- s.addListener('drain', function() {
- netBinding.close(pipeFDs[1]);
- });
- }
+ });
});
srv.listen(SOCK_PATH);
// Spawn a child running test/fixtures/recvfd.js
-var cp = child_process.spawn(process.argv[0],
- [path.join(common.fixturesDir, 'recvfd.js'), SOCK_PATH]);
+var cp = child_process.spawn(process.execPath,
+ [path.join(common.fixturesDir, 'recvfd.js'),
+ SOCK_PATH]);
cp.stdout.addListener('data', logChild);
cp.stderr.addListener('data', logChild);