Browse Source

Fix a few 'listening' race conditions

in
test-net-timeout
test-http-client-parse-error
v0.7.4-release
Ryan Dahl 15 years ago
parent
commit
44234e9cc7
  1. 2
      test/pummel/test-net-timeout.js
  2. 7
      test/simple/test-http-client-parse-error.js

2
test/pummel/test-net-timeout.js

@ -32,7 +32,6 @@ var echo_server = net.createServer(function (socket) {
echo_server.listen(common.PORT, function () { echo_server.listen(common.PORT, function () {
console.log("server listening at " + common.PORT); console.log("server listening at " + common.PORT);
});
var client = net.createConnection(common.PORT); var client = net.createConnection(common.PORT);
client.setEncoding("UTF8"); client.setEncoding("UTF8");
@ -71,6 +70,7 @@ client.addListener("close", function () {
console.log("client disconnect"); console.log("client disconnect");
echo_server.close(); echo_server.close();
}); });
});
process.addListener("exit", function () { process.addListener("exit", function () {
assert.ok(starttime != null); assert.ok(starttime != null);

7
test/simple/test-http-client-parse-error.js

@ -12,19 +12,20 @@ var srv = net.createServer(function(c) {
c.addListener('end', function() { c.end(); }); c.addListener('end', function() { c.end(); });
}); });
srv.listen(common.PORT, '127.0.0.1');
var parseError = false;
srv.listen(common.PORT, '127.0.0.1', function () {
var hc = http.createClient(common.PORT, '127.0.0.1'); var hc = http.createClient(common.PORT, '127.0.0.1');
hc.request('GET', '/').end(); hc.request('GET', '/').end();
var parseError = false;
hc.on('error', function (e) { hc.on('error', function (e) {
console.log("got error from client"); console.log("got error from client");
srv.close(); srv.close();
assert.ok(e.message.indexOf("Parse Error") >= 0); assert.ok(e.message.indexOf("Parse Error") >= 0);
parseError = true; parseError = true;
}); });
});
process.addListener('exit', function() { process.addListener('exit', function() {

Loading…
Cancel
Save