Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -40,3 +40,4 @@ ipch/ | |
email.md | ||
blog.html | ||
deps/v8-* | ||
node_modules |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
// just like test/gc/http-client.js, | ||
// but aborting every connection that comes in. | ||
|
||
function serverHandler(req, res) { | ||
res.connection.destroy(); | ||
} | ||
|
||
var http = require('http'), | ||
weak = require('weak'), | ||
done = 0, | ||
count = 0, | ||
countGC = 0, | ||
todo = 18, | ||
common = require('../common.js'), | ||
assert = require('assert'), | ||
PORT = common.PORT; | ||
|
||
console.log('We should do '+ todo +' requests'); | ||
|
||
var http = require('http'); | ||
var server = http.createServer(serverHandler); | ||
server.listen(PORT, getall); | ||
|
||
function getall() { | ||
for (var i = 0; i < todo; i++) { | ||
(function(){ | ||
function cb(res) { | ||
done+=1; | ||
statusLater(); | ||
} | ||
|
||
var req = http.get({ | ||
hostname: 'localhost', | ||
pathname: '/', | ||
port: PORT | ||
}, cb).on('error', cb); | ||
|
||
count++; | ||
weak(req, afterGC); | ||
This comment has been minimized.
Sorry, something went wrong.
Filirom1
|
||
})() | ||
} | ||
} | ||
|
||
function afterGC(){ | ||
countGC ++; | ||
} | ||
|
||
function statusLater() { | ||
setTimeout(status, 1); | ||
} | ||
|
||
function status() { | ||
gc(); | ||
console.log('Done: %d/%d', done, todo); | ||
console.log('Collected: %d/%d', countGC, count); | ||
if (done === todo) { | ||
console.log('All should be collected now.'); | ||
assert(count === countGC); | ||
process.exit(0); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
// just like test/gc/http-client.js, | ||
// but with an on('error') handler that does nothing. | ||
|
||
function serverHandler(req, res) { | ||
res.writeHead(200, {'Content-Type': 'text/plain'}); | ||
res.end('Hello World\n'); | ||
} | ||
|
||
var http = require('http'), | ||
weak = require('weak'), | ||
done = 0, | ||
count = 0, | ||
countGC = 0, | ||
todo = 18, | ||
common = require('../common.js'), | ||
assert = require('assert'), | ||
PORT = common.PORT; | ||
|
||
console.log('We should do '+ todo +' requests'); | ||
|
||
var http = require('http'); | ||
var server = http.createServer(serverHandler); | ||
server.listen(PORT, getall); | ||
|
||
function getall() { | ||
for (var i = 0; i < todo; i++) { | ||
(function(){ | ||
function cb(res) { | ||
done+=1; | ||
statusLater(); | ||
} | ||
function onerror(er) { | ||
throw er; | ||
} | ||
|
||
var req = http.get({ | ||
hostname: 'localhost', | ||
pathname: '/', | ||
port: PORT | ||
}, cb).on('error', onerror); | ||
|
||
count++; | ||
weak(req, afterGC); | ||
})() | ||
} | ||
} | ||
|
||
function afterGC(){ | ||
countGC ++; | ||
} | ||
|
||
function statusLater() { | ||
setTimeout(status, 1); | ||
} | ||
|
||
function status() { | ||
gc(); | ||
console.log('Done: %d/%d', done, todo); | ||
console.log('Collected: %d/%d', countGC, count); | ||
if (done === todo) { | ||
console.log('All should be collected now.'); | ||
assert(count === countGC); | ||
process.exit(0); | ||
} | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
// just like test/gc/http-client.js, | ||
// but with a timeout set | ||
|
||
function serverHandler(req, res) { | ||
setTimeout(function () { | ||
res.writeHead(200) | ||
res.end('hello\n'); | ||
}, 100); | ||
} | ||
|
||
var http = require('http'), | ||
weak = require('weak'), | ||
done = 0, | ||
count = 0, | ||
countGC = 0, | ||
todo = 18, | ||
common = require('../common.js'), | ||
assert = require('assert'), | ||
PORT = common.PORT; | ||
|
||
console.log('We should do '+ todo +' requests'); | ||
|
||
var http = require('http'); | ||
var server = http.createServer(serverHandler); | ||
server.listen(PORT, getall); | ||
|
||
function getall() { | ||
for (var i = 0; i < todo; i++) { | ||
(function(){ | ||
function cb() { | ||
done+=1; | ||
statusLater(); | ||
} | ||
|
||
var req = http.get({ | ||
hostname: 'localhost', | ||
pathname: '/', | ||
port: PORT | ||
}, cb); | ||
req.on('error', cb); | ||
req.setTimeout(10, function(){ | ||
console.log('timeout (expected)') | ||
}); | ||
|
||
count++; | ||
weak(req, afterGC); | ||
})() | ||
} | ||
} | ||
|
||
function afterGC(){ | ||
countGC ++; | ||
} | ||
|
||
function statusLater() { | ||
setTimeout(status, 1); | ||
} | ||
|
||
function status() { | ||
gc(); | ||
console.log('Done: %d/%d', done, todo); | ||
console.log('Collected: %d/%d', countGC, count); | ||
if (done === todo) { | ||
console.log('All should be collected now.'); | ||
assert(count === countGC); | ||
process.exit(0); | ||
} | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
// just a simple http server and client. | ||
|
||
function serverHandler(req, res) { | ||
res.writeHead(200, {'Content-Type': 'text/plain'}); | ||
res.end('Hello World\n'); | ||
} | ||
|
||
var http = require('http'), | ||
weak = require('weak'), | ||
done = 0, | ||
count = 0, | ||
countGC = 0, | ||
todo = 5, | ||
common = require('../common.js'), | ||
assert = require('assert'), | ||
PORT = common.PORT; | ||
|
||
console.log('We should do '+ todo +' requests'); | ||
|
||
var http = require('http'); | ||
var server = http.createServer(serverHandler); | ||
server.listen(PORT, getall); | ||
|
||
|
||
function getall() { | ||
for (var i = 0; i < todo; i++) { | ||
(function(){ | ||
function cb(res) { | ||
console.error('in cb') | ||
done+=1; | ||
res.on('end', statusLater); | ||
} | ||
|
||
var req = http.get({ | ||
hostname: 'localhost', | ||
pathname: '/', | ||
port: PORT | ||
}, cb) | ||
|
||
count++; | ||
weak(req, afterGC); | ||
})() | ||
} | ||
} | ||
|
||
function afterGC(){ | ||
countGC ++; | ||
} | ||
|
||
function statusLater() { | ||
setTimeout(status, 1); | ||
} | ||
|
||
function status() { | ||
gc(); | ||
console.log('Done: %d/%d', done, todo); | ||
console.log('Collected: %d/%d', countGC, count); | ||
if (done === todo) { | ||
console.log('All should be collected now.'); | ||
assert(count === countGC); | ||
process.exit(0); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
// just like test/gc/http-client-timeout.js, | ||
// but using a net server/client instead | ||
|
||
function serverHandler(sock) { | ||
sock.setTimeout(120000); | ||
setTimeout(function () { | ||
sock.end('hello\n'); | ||
}, 100); | ||
} | ||
|
||
var net = require('net'), | ||
weak = require('weak'), | ||
done = 0, | ||
count = 0, | ||
countGC = 0, | ||
todo = 18, | ||
common = require('../common.js'), | ||
assert = require('assert'), | ||
PORT = common.PORT; | ||
|
||
console.log('We should do '+ todo +' requests'); | ||
|
||
var server = net.createServer(serverHandler); | ||
server.listen(PORT, getall); | ||
|
||
function getall() { | ||
for (var i = 0; i < todo; i++) { | ||
(function(){ | ||
var req = net.connect(PORT, '127.0.0.1'); | ||
req.setTimeout(10, function() { | ||
console.log('timeout (expected)') | ||
req.destroy(); | ||
done++; | ||
statusLater(); | ||
}); | ||
|
||
count++; | ||
weak(req, afterGC); | ||
})() | ||
} | ||
} | ||
|
||
function afterGC(){ | ||
countGC ++; | ||
} | ||
|
||
function statusLater() { | ||
setTimeout(status, 1); | ||
} | ||
|
||
function status() { | ||
gc(); | ||
console.log('Done: %d/%d', done, todo); | ||
console.log('Collected: %d/%d', countGC, count); | ||
if (done === todo) { | ||
console.log('All should be collected now.'); | ||
assert(count === countGC); | ||
process.exit(0); | ||
} | ||
} | ||
|
Only simple message tests are run : there is no need to depend on 'node_modules/weak' target here.