Permalink
Browse files

[fix] Connections to carapace should not force it to stay open (this …

…allows long lived connections)
  • Loading branch information...
1 parent 8701628 commit 8b93dc836b5cff120766be080daf4a6131441ba7 @bmeck bmeck committed Jul 15, 2011
Showing with 14 additions and 6 deletions.
  1. +7 −1 bin/carapace
  2. +7 −5 examples/loader.js
View
@@ -14,7 +14,7 @@ var dnode = require('dnode');
// Carapace arguments are for the rooting environment
// * carapace.bridge
//
-var bridgePath = process.argv.splice(2,1)[0];
+var bridgePath = path.resolve(process.argv.splice(2,1)[0]);
var bridgeServer = net.createServer();
bridgeServer.listen(bridgePath);
//
@@ -31,6 +31,12 @@ var bridge = new dnode({
}
});
bridge.listen(bridgeServer);
+bridgeServer.on('connection', function(conn) {
+ libev.Unref();
+ conn.on('close',function(){
+ libev.Ref();
+ })
+});
carapace.on('plugin',function(toRequire, done) {
try {
View
@@ -1,18 +1,20 @@
var path = require('path');
var carapace = require('../');
var bridgePath = path.resolve(process.argv[2]);
+
console.log('connecting to ' + bridgePath)
require('dnode').connect(bridgePath, function(client, conn) {
console.log('loading plugin ' + carapace.plugins.chroot);
+ //
+ // Connections to Carapace do not keep it open!
+ //
+ conn.on('end',function(){
+ console.log('Carapace connection had ended.')
+ });
client.emit('plugin',carapace.plugins.chroot, function() {
console.log('plugin done')
- console.dir(arguments)
client.emit('chroot:root','..', function() {
client.emit('run', 'examples/server.js');
- //
- // Kill our connection to carapace (this connection will prevent carapace from closing due to IOWatchers)
- //
- conn.end();
});
})
});

0 comments on commit 8b93dc8

Please sign in to comment.