Permalink
Browse files

fix for the server termination in windows.

This happening because the stream is piped to the binary.
When stream receives 'close', the event handler for it calls destroys of the destination stream.
In this case, it is the binary() which doesn't have a destroy() method. So it was crashing in this place.
No idea why it din't crash in mac because the module is the same.
TODO: Investigate in mac.
  • Loading branch information...
1 parent 9d21b75 commit b2e8698c5c71fd6fa013a4537d87b3e4241bd5fa @rajasekaran2003 committed Jun 28, 2012
Showing with 7 additions and 4 deletions.
  1. +7 −2 lib/messages.js
  2. +0 −2 manual_tests/two_requests.py
View
@@ -18,7 +18,7 @@ var Receiver = function() {
var receiver = this;
this.server = net.createServer();
this.server.on('connection', function(socket) {
- socket.write(ConnectionValidation)
+ socket.write(ConnectionValidation);
new Parser(receiver, socket);
});
} else {
@@ -73,8 +73,13 @@ var Parser = function(emitter, stream) {
};
var message_parser = binary();
+ // Seriously this is strange, that it is happening only in windows
+ message_parser.destroy = function destroy(){
+ console.log('Surprise surprise, you are on windows!')
+ message_parser.flush();
+ }
parse_new_message(message_parser);
- stream.pipe(message_parser);
+ stream.pipe(message_parser);
} else {
return new Parser(emitter, stream);
}
@@ -19,7 +19,5 @@
printer.printString("Blah!")
print "Finished operation 1!"
-import time
-time.sleep(0.1)
printer.printString("Blah a second time!")
print "Finished operation 2!"

0 comments on commit b2e8698

Please sign in to comment.