summaryrefslogtreecommitdiff
path: root/test/fixtures/recvfd.js
diff options
context:
space:
mode:
authorRyan Dahl <ry@tinyclouds.org>2010-11-12 16:24:53 -0800
committerRyan Dahl <ry@tinyclouds.org>2010-11-18 16:47:38 -0800
commitfa556a142512ab932b7359760e5e4585e4e035b6 (patch)
tree00a1ab1f741fb84190d14c99a2b90a9592cbcc2c /test/fixtures/recvfd.js
parenta6d84253824694b6e6ec148ec57cb344727d3a84 (diff)
downloadnode-new-fa556a142512ab932b7359760e5e4585e4e035b6.tar.gz
Add callback to socket.write(), fix test-sendfds
Diffstat (limited to 'test/fixtures/recvfd.js')
-rw-r--r--test/fixtures/recvfd.js16
1 files changed, 7 insertions, 9 deletions
diff --git a/test/fixtures/recvfd.js b/test/fixtures/recvfd.js
index 09b2864b7e..8f06469389 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