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

Commit

Permalink
Merge branch 'v0.4'
Browse files Browse the repository at this point in the history
Conflicts:
	src/node_version.h
  • Loading branch information
ry committed Apr 19, 2011
2 parents da9b334 + d3d35ec commit 9e6498d
Show file tree
Hide file tree
Showing 13 changed files with 171 additions and 29 deletions.
3 changes: 3 additions & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -167,4 +167,7 @@ Dean McNamee <dean@gmail.com>
Trevor Burnham <trevor@databraid.com>
Zachary Scott <zachary.s.scott@gmail.com>
Arnout Kazemier <info@3rd-Eden.com>
George Stagas <gstagas@gmail.com>
Scott McWhirter <scott.mcwhirter@joyent.com>
Jakub Lekstan <jakub.lekstan@dreamlab.pl>

30 changes: 30 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,33 @@
2011.04.13, Version 0.4.6 (stable)

* Don't error on ENOTCONN from shutdown() #670

* Auto completion of built-in debugger suggests prefix match rather than
partial match. (koichik)

* circular reference in vm modules. #822 (Jakub Lekstan)

* http response.readable should be false after 'end' #867 (Abe Fettig)

* Implemenet os.cpus() and os.uptime() on Solaris (Scott McWhirter)

* fs.ReadStream: Allow omission of end option for range reads #801
(Felix Geisendörfer)

* Buffer.write() with UCS-2 should not be write partial char
#916 (koichik)

* Pass secureProtocol through on tls.Server creation (Theo Schlossnagle)

* TLS use RC4-SHA by default

* Don't strangely drop out of event loop on HTTPS client uploads #892

* Doc improvements

* Upgrade v8 to 3.1.8.10


2011.04.01, Version 0.4.5 (stable)

* Fix listener leak in stream.pipe() (Mikeal Rogers)
Expand Down
1 change: 1 addition & 0 deletions doc/api/_toc.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

* [Synopsis](synopsis.html)
* [Globals](globals.html)
* [STDIO](stdio.html)
* [Timers](timers.html)
* [Modules](modules.html)
* [C/C++ Addons](addons.html)
Expand Down
1 change: 1 addition & 0 deletions doc/api/all.markdown
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@

@include synopsis
@include globals
@include stdio
@include timers
@include modules
@include addons
Expand Down
8 changes: 6 additions & 2 deletions doc/api/globals.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ scope; `var something` inside a Node module will be local to that module.

The process object. See the [process object](process.html#process) section.

### console

Used to print to stdout and stderr. See the [stdio](stdio.html) section.


### require()

To require modules. See the [Modules](modules.html#modules) section.
Expand Down Expand Up @@ -66,12 +71,11 @@ Example: running `node example.js` from `/Users/mjr`
A reference to the current module. In particular
`module.exports` is the same as the `exports` object. See `src/node.js`
for more information.
`module` isn't actually a global but rather local to each module.

### setTimeout(cb, ms)
### clearTimeout(t)
### setInterval(cb, ms)
### clearInterval(t)

The timer functions are global variables. See the [timers](timers.html) section.

`module` isn't actually a global but rather local to each module.
5 changes: 5 additions & 0 deletions doc/api/http.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,11 @@ be called before `response.end()` is called.
If you call `response.write()` or `response.end()` before calling this, the
implicit/mutable headers will be calculated and call this function for you.

Note: that Content-Length is given in bytes not characters. The above example
works because the string `'hello world'` contains only single byte characters.
If the body contains higher coded characters then `Buffer.byteLength()`
should be used to determine the number of bytes in a given encoding.

### response.statusCode

When using implicit headers (not calling `response.writeHead()` explicitly), this property
Expand Down
51 changes: 51 additions & 0 deletions doc/api/stdio.markdown
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
## console

Browser-like object for printing to stdout and stderr.

### console.log()

Prints to stdout with newline. This function can take multiple arguments in a
`printf()`-like way. Example:

console.log('count: %d', count);

If formating elements are not found in the first string then `util.inspect`
is used on each argument.

### console.info()

Same as `console.log`.

### console.warn()
### console.error()

Same as `console.log` but prints to stderr.

### console.dir(obj)

Uses `util.inspect` on `obj` and prints resulting string to stderr.

### console.time(label)

Mark a time.


### console.timeEnd(label)

Finish timer, record output. Example

console.time('100-elements');
while (var i = 0; i < 100; i++) {
;
}
console.timeEnd('100-elements');


### console.trace()

Print a stack trace to stderr of the current position.

### console.assert()

Same as `assert.ok()`.

17 changes: 8 additions & 9 deletions doc/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,12 @@
<li><a href="#download">Download</a></li>
<li><a href="https://github.com/joyent/node/raw/master/ChangeLog">ChangeLog</a></li>
<li><a href="#about">About</a></li>
<li><a href="http://nodejs.org/docs/v0.4.5/api">v0.4.5 docs</a></li>
<br/>
<li><B><a href="https://github.com/joyent/node/wiki">Wiki</a></B></li>
<li><B><a href="http://blog.nodejs.org/">Blog</a></B></li>
<br/>
<li><B><a href="http://jobs.nodejs.org/">Jobs</a></B></li>
<li><a href="http://nodejs.org/docs/v0.4.6/api">v0.4.6 docs</a></li>
<br/>
<li><a href="https://github.com/joyent/node/wiki">Wiki</a></li>
<li><a href="http://blog.nodejs.org/">Blog</a></li>
<li><a href="http://jobs.nodejs.org/">Jobs</a></li>
<li><a href="https://github.com/joyent/node/wiki/Community">Community</a></li>
<li><a href="http://chat.nodejs.org/">Demo</a></li>
</ol>
</div>
Expand Down Expand Up @@ -108,9 +107,9 @@ <h2 id="download">Download</h2>
</p>

<p>
2011.04.01
<a href="http://nodejs.org/dist/node-v0.4.5.tar.gz">node-v0.4.5.tar.gz</a>
(<a href="http://nodejs.org/docs/v0.4.5/api/index.html">Documentation</a>)
2011.04.13
<a href="http://nodejs.org/dist/node-v0.4.6.tar.gz">node-v0.4.6.tar.gz</a>
(<a href="http://nodejs.org/docs/v0.4.6/api/index.html">Documentation</a>)
</p>

<p>Historical: <a href="http://nodejs.org/dist">versions</a>, <a href="http://nodejs.org/docs">docs</a></p>
Expand Down
6 changes: 5 additions & 1 deletion lib/net.js
Original file line number Diff line number Diff line change
Expand Up @@ -636,7 +636,11 @@ Socket.prototype._onReadable = function() {
pool.length - pool.used);
DTRACE_NET_SOCKET_READ(this, bytesRead);
} catch (e) {
self.destroy(e);
if (e.code == 'ECONNRESET') {
self.destroy();
} else {
self.destroy(e);
}
return;
}

Expand Down
29 changes: 21 additions & 8 deletions lib/stream.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,13 @@ function Stream() {
util.inherits(Stream, events.EventEmitter);
exports.Stream = Stream;

var pipes = [];

Stream.prototype.pipe = function(dest, options) {
var source = this;

pipes.push(dest);

function ondata(chunk) {
if (dest.writable) {
if (false === dest.write(chunk)) source.pause();
Expand All @@ -52,10 +56,18 @@ Stream.prototype.pipe = function(dest, options) {

if (!options || options.end !== false) {
function onend() {
var index = pipes.indexOf(dest);
pipes.splice(index, 1);

if (pipes.indexOf(dest) > -1) {
return;
}

dest.end();
}

source.on('end', onend);
source.on('close', onend);
}

/*
Expand All @@ -73,34 +85,35 @@ Stream.prototype.pipe = function(dest, options) {
source.emit('resume');
};
}

var onpause = function() {
source.pause();
}

dest.on('pause', onpause);

var onresume = function() {
if (source.readable) source.resume();
};

dest.on('resume', onresume);

var cleanup = function () {
source.removeListener('data', ondata);
dest.removeListener('drain', ondrain);
source.removeListener('end', onend);

source.removeListener('close', onend);

dest.removeListener('pause', onpause);
dest.removeListener('resume', onresume);

source.removeListener('end', cleanup);
source.removeListener('close', cleanup);

dest.removeListener('end', cleanup);
dest.removeListener('close', cleanup);
}

source.on('end', cleanup);
source.on('close', cleanup);

Expand Down
26 changes: 19 additions & 7 deletions lib/tls.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,14 @@ function CryptoStream(pair) {
this._writeState = true;
this._pending = [];
this._pendingCallbacks = [];
this._pendingBytes = 0;
}
util.inherits(CryptoStream, stream.Stream);


CryptoStream.prototype.write = function(data /* , encoding, cb */) {
if (this == this.pair.cleartext) {
debug('cleartext.write called with (((' + data.toString() + ')))');
debug('cleartext.write called with ' + data.length + ' bytes');
} else {
debug('encrypted.write called with ' + data.length + ' bytes');
}
Expand Down Expand Up @@ -90,10 +91,12 @@ CryptoStream.prototype.write = function(data /* , encoding, cb */) {
this._pending.push(data);
this._pendingCallbacks.push(cb);

this._pendingBytes += data.length;

this.pair._writeCalled = true;
this.pair._cycle();

return this._writeState;
return this._pendingBytes < 128 * 1024;
};


Expand Down Expand Up @@ -263,7 +266,7 @@ CryptoStream.prototype._push = function() {

// Bail out if we didn't read any data.
if (bytesRead == 0) {
if (this._pendingBytes() == 0 && this._destroyAfterPush) {
if (this._internallyPendingBytes() == 0 && this._destroyAfterPush) {
this._done();
}
return;
Expand All @@ -272,7 +275,7 @@ CryptoStream.prototype._push = function() {
var chunk = pool.slice(0, bytesRead);

if (this === this.pair.cleartext) {
debug('cleartext emit "data" called with (((' + chunk.toString() + ')))');
debug('cleartext emit "data" with ' + bytesRead + ' bytes');
} else {
debug('encrypted emit "data" with ' + bytesRead + ' bytes');
}
Expand Down Expand Up @@ -307,6 +310,8 @@ CryptoStream.prototype._push = function() {
CryptoStream.prototype._pull = function() {
var havePending = this._pending.length > 0;

assert(havePending || this._pendingBytes == 0);

while (this._pending.length > 0) {
if (!this.pair._ssl) break;

Expand Down Expand Up @@ -355,6 +360,9 @@ CryptoStream.prototype._pull = function() {
break;
}

this._pendingBytes -= tmp.length;
assert(this._pendingBytes >= 0);

if (cb) cb();

assert(rv === tmp.length);
Expand All @@ -375,7 +383,7 @@ function CleartextStream(pair) {
util.inherits(CleartextStream, CryptoStream);


CleartextStream.prototype._pendingBytes = function() {
CleartextStream.prototype._internallyPendingBytes = function() {
if (this.pair._ssl) {
return this.pair._ssl.clearPending();
} else {
Expand Down Expand Up @@ -403,7 +411,7 @@ function EncryptedStream(pair) {
util.inherits(EncryptedStream, CryptoStream);


EncryptedStream.prototype._pendingBytes = function() {
EncryptedStream.prototype._internallyPendingBytes = function() {
if (this.pair._ssl) {
return this.pair._ssl.encPending();
} else {
Expand Down Expand Up @@ -539,24 +547,28 @@ SecurePair.prototype._cycle = function(depth) {

if (!this._cycleEncryptedPullLock) {
this._cycleEncryptedPullLock = true;
debug("encrypted._pull");
this.encrypted._pull();
this._cycleEncryptedPullLock = false;
}

if (!this._cycleCleartextPullLock) {
this._cycleCleartextPullLock = true;
debug("cleartext._pull");
this.cleartext._pull();
this._cycleCleartextPullLock = false;
}

if (!this._cycleCleartextPushLock) {
this._cycleCleartextPushLock = true;
debug("cleartext._push");
this.cleartext._push();
this._cycleCleartextPushLock = false;
}

if (!this._cycleEncryptedPushLock) {
this._cycleEncryptedPushLock = true;
debug("encrypted._push");
this.encrypted._push();
this._cycleEncryptedPushLock = false;
}
Expand Down Expand Up @@ -728,7 +740,7 @@ function Server(/* [options], listener */) {
secureOptions: self.secureOptions,
crl: self.crl
});
//creds.context.setCiphers('RC4-SHA:AES128-SHA:AES256-SHA');
creds.context.setCiphers('RC4-SHA:AES128-SHA:AES256-SHA');

var pair = new SecurePair(creds,
true,
Expand Down
Loading

0 comments on commit 9e6498d

Please sign in to comment.