Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.

Commit

Permalink
Merge remote branch 'origin/v0.6'
Browse files Browse the repository at this point in the history
Conflicts:
	deps/v8/src/version.cc
  • Loading branch information
ry committed Dec 23, 2011
2 parents e4731f8 + d85c85a commit c2d9e62
Show file tree
Hide file tree
Showing 11 changed files with 138 additions and 46 deletions.
41 changes: 41 additions & 0 deletions benchmark/next-tick-2.js
@@ -0,0 +1,41 @@
// Copyright Joyent, Inc. and other Node contributors.
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to permit
// persons to whom the Software is furnished to do so, subject to the
// following conditions:
//
// The above copyright notice and this permission notice shall be included
// in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
// USE OR OTHER DEALINGS IN THE SOFTWARE.

var count = 2e6,
left = count,
start;

function onNextTick() {
if (--left) {
process.nextTick(onNextTick);
} else {
finalize();
}
}

function finalize() {
var duration = (new Date()).getTime() - start,
ticksPerSec = count / duration * 1000;
console.log("nextTick callbacks per second: " + Math.round(ticksPerSec));
}

start = (new Date()).getTime();
process.nextTick(onNextTick);
18 changes: 9 additions & 9 deletions doc/about/index.html
@@ -1,21 +1,21 @@
<!doctype html>
<html>
<head>
<style type="text/css">
<meta charset="utf-8">
<style>
ul {
padding: 0;
margin: 0;
}
</style>
<link type="image/x-icon" rel="icon" href="../favicon.ico">
<link type="image/x-icon" rel="shortcut icon" href="../favicon.ico">
<link type="text/css" rel="stylesheet" href="../pipe.css">
<link type="text/css" rel="stylesheet" href="../sh_vim-dark.css">
<link rel="stylesheet" href="../pipe.css">
<link rel="stylesheet" href="../sh_vim-dark.css">
<link rel="alternate"
type="application/rss+xml"
title="node blog"
href="http://feeds.feedburner.com/nodejs/123123123">
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<title>node.js</title>
</head>
<body>
Expand Down Expand Up @@ -109,16 +109,16 @@ <h2>About</h2>
is a <a href="trademark-policy.pdf">trademark of Joyent, Inc</a>.
</div>

<script type="text/javascript" src="../sh_main.js"></script>
<script type="text/javascript" src="../sh_javascript.min.js"></script>
<script type="text/javascript">highlight(undefined, undefined, 'pre');</script>
<script src="../sh_main.js"></script>
<script src="../sh_javascript.min.js"></script>
<script>highlight(undefined, undefined, 'pre');</script>

<script type="text/javascript">
<script>
var gaJsHost = (("https:" == document.location.protocol) ?
"https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
<script>
try {
var pageTracker = _gat._getTracker("UA-10874194-2");
pageTracker._trackPageview();
Expand Down
2 changes: 1 addition & 1 deletion doc/api/addons.markdown
Expand Up @@ -88,4 +88,4 @@ the recently built module:
console.log(addon.hello()); // 'world'

For the moment, that is all the documentation on addons. Please see
<https://github.com/ry/node_postgres> for a real example.
<https://github.com/pietern/hiredis-node> for a real example.
7 changes: 4 additions & 3 deletions doc/api/crypto.markdown
Expand Up @@ -47,9 +47,10 @@ Example: this program that takes the sha1 sum of a file
console.log(d + ' ' + filename);
});

### hash.update(data)
### hash.update(data, input_encoding='binary')

Updates the hash content with the given `data`.
Updates the hash content with the given `data`, the encoding of which is given
in `input_encoding` and can be `'utf8'`, `'ascii'` or `'binary'`.
This can be called many times with new data as it is streamed.

### hash.digest(encoding='binary')
Expand Down Expand Up @@ -255,4 +256,4 @@ Generates cryptographically strong pseudo-random data. Usage:
console.log('Have %d bytes of random data: %s', buf.length, buf);
} catch (ex) {
// handle error
}
}
17 changes: 8 additions & 9 deletions doc/community/index.html
@@ -1,15 +1,15 @@
<!doctype html>
<html>
<head>
<style type="text/css">
<meta charset="utf-8">
<style>
ul {
padding: 0;
margin: 0;
}
</style>
<script type='text/javascript' src='http://ajax.googleapis.com/ajax/libs/jquery/1.5/jquery.min.js?ver=3.1.3'></script>
<script type="text/javascript" src="../sh_main.js"></script>
<script type="text/javascript" src="../sh_javascript.min.js"></script>
<script src="../sh_main.js"></script>
<script src="../sh_javascript.min.js"></script>
<link type="image/x-icon" rel="icon" href="../favicon.ico">
<link type="image/x-icon" rel="shortcut icon" href="../favicon.ico">
<link type="text/css" rel="stylesheet" href="../pipe.css">
Expand All @@ -18,7 +18,6 @@
type="application/rss+xml"
title="node blog"
href="http://feeds.feedburner.com/nodejs/123123123">
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<title>node.js</title>
</head>
<body>
Expand Down Expand Up @@ -148,16 +147,16 @@ <h2>Localized Sites</h2>
is a <a href="trademark-policy.pdf">trademark of Joyent, Inc</a>.
</div>

<script type="text/javascript">
<script>
var gaJsHost = (("https:" == document.location.protocol) ?
"https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
<script>
try {
var pageTracker = _gat._getTracker("UA-10874194-2");
pageTracker._trackPageview();
} catch(err) {}
</script>

</body></html>
</body>
</html>
20 changes: 10 additions & 10 deletions doc/index.html
@@ -1,21 +1,21 @@
<!doctype html>
<html>
<html lang="en">
<head>
<style type="text/css">
<meta charset="utf-8">
<style>
ul {
padding: 0;
margin: 0;
}
</style>
<link type="image/x-icon" rel="icon" href="favicon.ico">
<link type="image/x-icon" rel="shortcut icon" href="favicon.ico">
<link type="text/css" rel="stylesheet" href="pipe.css">
<link type="text/css" rel="stylesheet" href="sh_vim-dark.css">
<link rel="stylesheet" href="pipe.css">
<link rel="stylesheet" href="sh_vim-dark.css">
<link rel="alternate"
type="application/rss+xml"
title="node blog"
href="http://feeds.feedburner.com/nodejs/123123123">
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<title>node.js</title>
</head>
<body>
Expand Down Expand Up @@ -200,16 +200,16 @@ <h2>Explore Node.js</h2>
is a <a href="trademark-policy.pdf">trademark of Joyent, Inc</a>.
</div>

<script type="text/javascript" src="sh_main.js"></script>
<script type="text/javascript" src="sh_javascript.min.js"></script>
<script type="text/javascript">highlight(undefined, undefined, 'pre');</script>
<script src="sh_main.js"></script>
<script src="sh_javascript.min.js"></script>
<script>highlight(undefined, undefined, 'pre');</script>

<script type="text/javascript">
<script>
var gaJsHost = (("https:" == document.location.protocol) ?
"https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
<script>
try {
var pageTracker = _gat._getTracker("UA-10874194-2");
pageTracker._trackPageview();
Expand Down
11 changes: 5 additions & 6 deletions doc/template.html
@@ -1,7 +1,7 @@
<!DOCTYPE html>
<html>
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta charset="utf-8">
<title>{{section}}Node.js v0.6.6 Manual &amp; Documentation</title>
<link rel="stylesheet" href="assets/style.css">
<link rel="stylesheet" href="assets/sh.css">
Expand All @@ -21,16 +21,15 @@ <h1>Node.js v0.6.6 Manual &amp; Documentation</h1>
<script src="assets/sh_main.js"></script>
<script src="assets/sh_javascript.min.js"></script>
<script>highlight(undefined, undefined, 'pre');</script>
<script type="text/javascript">
<script>
var gaJsHost = (("https:" == document.location.protocol) ?
"https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
<script>
try {
var pageTracker = _gat._getTracker("UA-10874194-2");
pageTracker._trackPageview();
} catch(err) {}</script>
<script type="text/javascript">highlight(undefined, undefined, 'pre');</script>
</body>
</html>
4 changes: 2 additions & 2 deletions lib/buffer.js
Expand Up @@ -698,7 +698,7 @@ Buffer.prototype.readInt8 = function(offset, noAssert) {
};

function readInt16(buffer, offset, isBigEndian, noAssert) {
var neg;
var neg, val;

if (!noAssert) {
assert.ok(typeof (isBigEndian) === 'boolean',
Expand Down Expand Up @@ -729,7 +729,7 @@ Buffer.prototype.readInt16BE = function(offset, noAssert) {
};

function readInt32(buffer, offset, isBigEndian, noAssert) {
var neg;
var neg, val;

if (!noAssert) {
assert.ok(typeof (isBigEndian) === 'boolean',
Expand Down
2 changes: 2 additions & 0 deletions lib/net.js
Expand Up @@ -443,6 +443,8 @@ Socket.prototype.write = function(data, arg1, arg2) {
Socket.prototype._write = function(data, encoding, cb) {
timers.active(this);

if (!this._handle) throw new Error('This socket is closed.');

// `encoding` is unused right now, `data` is always a buffer.
var writeReq = this._handle.write(data);

Expand Down
13 changes: 7 additions & 6 deletions lib/timers.js
Expand Up @@ -108,8 +108,8 @@ var unenroll = exports.unenroll = function(item) {
list.close();
delete lists[item._idleTimeout];
}
//if active is called later, then we want to make sure not to insert again
delete item._idleTimeout;
// if active is called later, then we want to make sure not to insert again
item._idleTimeout = -1;
};


Expand Down Expand Up @@ -151,17 +151,18 @@ exports.setTimeout = function(callback, after) {
if (after <= 0) {
// Use the slow case for after == 0
timer = new Timer();
timer._callback = callback;

if (arguments.length <= 2) {
timer._onTimeout = function() {
callback();
timer.close();
this._callback();
this.close();
}
} else {
var args = Array.prototype.slice.call(arguments, 2);
timer._onTimeout = function() {
callback.apply(timer, args);
timer.close();
this._callback.apply(timer, args);
this.close();
}
}

Expand Down
49 changes: 49 additions & 0 deletions test/simple/test-net-write-after-close.js
@@ -0,0 +1,49 @@
// Copyright Joyent, Inc. and other Node contributors.
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to permit
// persons to whom the Software is furnished to do so, subject to the
// following conditions:
//
// The above copyright notice and this permission notice shall be included
// in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
// USE OR OTHER DEALINGS IN THE SOFTWARE.

var common = require('../common');
var assert = require('assert');
var net = require('net');

var gotError = false;

process.on('exit', function() {
assert(gotError);
});

var server = net.createServer(function(socket) {
setTimeout(function() {
assert.throws(
function() {
socket.write('test');
},
/This socket is closed/
);
server.close();
gotError = true;
}, 250);
});

server.listen(common.PORT, function() {
var client = net.connect(common.PORT, function() {
client.end();
});
});

0 comments on commit c2d9e62

Please sign in to comment.