Browse Source

Merge remote-tracking branch 'origin/v0.10' into master

Conflicts:
	doc/api/buffer.markdown
	lib/_stream_readable.js
	lib/assert.js
	lib/buffer.js
	lib/child_process.js
	lib/http.js
	lib/string_decoder.js
	lib/zlib.js
	node.gyp
	test/simple/test-buffer.js
	test/simple/test-https-foafssl.js
	test/simple/test-stream2-compatibility.js
	test/simple/test-tls-server-verify.js
archived-io.js-v0.10
Fedor Indutny 11 years ago
parent
commit
f310c0f16b
  1. 2
      configure
  2. 16
      doc/api/buffer.markdown
  3. 11
      doc/api/console.markdown
  4. 4
      doc/api/crypto.markdown
  5. 3
      doc/api/modules.markdown
  6. 5
      lib/_stream_readable.js
  7. 2
      lib/assert.js
  8. 2
      lib/buffer.js
  9. 2
      lib/net.js
  10. 4
      lib/string_decoder.js
  11. 7
      lib/zlib.js
  12. 2
      node.gyp
  13. 11
      src/node_constants.cc
  14. 1
      test/simple/test-https-foafssl.js
  15. 58
      test/simple/test-stream2-base64-single-char-read-end.js
  16. 25
      test/simple/test-zlib-write-after-close.js

2
configure

@ -473,6 +473,8 @@ def configure_node(o):
if target_arch != host_arch and not options.without_snapshot: if target_arch != host_arch and not options.without_snapshot:
o['variables']['want_separate_host_toolset'] = 1 o['variables']['want_separate_host_toolset'] = 1
else:
o['variables']['want_separate_host_toolset'] = 0
if target_arch == 'arm': if target_arch == 'arm':
configure_arm(o) configure_arm(o)

16
doc/api/buffer.markdown

@ -37,6 +37,22 @@ encoding method. Here are the different string encodings.
* `'hex'` - Encode each byte as two hexadecimal characters. * `'hex'` - Encode each byte as two hexadecimal characters.
Creating a typed array from a `Buffer` works with the following caveats:
1. The buffer's memory is copied, not shared.
2. The buffer's memory is interpreted as an array, not a byte array. That is,
`new Uint32Array(new Buffer([1,2,3,4]))` creates a 4-element `Uint32Array`
with elements `[1,2,3,4]`, not an `Uint32Array` with a single element
`[0x1020304]` or `[0x4030201]`.
NOTE: Node.js v0.8 simply retained a reference to the buffer in `array.buffer`
instead of cloning it.
While more efficient, it introduces subtle incompatibilities with the typed
arrays specification. `ArrayBuffer#slice()` makes a copy of the slice while
`Buffer#slice()` creates a view.
## Class: Buffer ## Class: Buffer
The Buffer class is a global type for dealing with binary data directly. The Buffer class is a global type for dealing with binary data directly.

11
doc/api/console.markdown

@ -74,14 +74,15 @@ Finish timer, record output. Example:
} }
console.timeEnd('100-elements'); console.timeEnd('100-elements');
## console.trace(label) ## console.trace(message, [...])
Print a stack trace to stderr of the current position. Print to stderr `'Trace :'`, followed by the formatted message and stack trace
to the current position.
## console.assert(expression, [message]) ## console.assert(value, [message], [...])
Same as [assert.ok()][] where if the `expression` evaluates as `false` throw an Similar to [assert.ok()][], but the error message is formatted as
AssertionError with `message`. `util.format(message...)`.
[assert.ok()]: assert.html#assert_assert_value_message_assert_ok_value_message [assert.ok()]: assert.html#assert_assert_value_message_assert_ok_value_message
[util.format()]: util.html#util_util_format_format [util.format()]: util.html#util_util_format_format

4
doc/api/crypto.markdown

@ -188,8 +188,8 @@ which must be a `'binary'` encoded string or a [buffer](buffer.html).
It is a [stream](stream.html) that is both readable and writable. The It is a [stream](stream.html) that is both readable and writable. The
written data is used to compute the hash. Once the writable side of written data is used to compute the hash. Once the writable side of
the stream is ended, use the `read()` method to get the computed hash the stream is ended, use the `read()` method to get the enciphered
digest. The legacy `update` and `digest` methods are also supported. contents. The legacy `update` and `final` methods are also supported.
## crypto.createCipheriv(algorithm, key, iv) ## crypto.createCipheriv(algorithm, key, iv)

3
doc/api/modules.markdown

@ -385,7 +385,8 @@ in pseudocode of what require.resolve does:
LOAD_AS_FILE(X) LOAD_AS_FILE(X)
1. If X is a file, load X as JavaScript text. STOP 1. If X is a file, load X as JavaScript text. STOP
2. If X.js is a file, load X.js as JavaScript text. STOP 2. If X.js is a file, load X.js as JavaScript text. STOP
3. If X.node is a file, load X.node as binary addon. STOP 3. If X.json is a file, parse X.json to a JavaScript Object. STOP
4. If X.node is a file, load X.node as binary addon. STOP
LOAD_AS_DIRECTORY(X) LOAD_AS_DIRECTORY(X)
1. If X/package.json is a file, 1. If X/package.json is a file,

5
lib/_stream_readable.js

@ -85,9 +85,6 @@ function ReadableState(options, stream) {
// if true, a maybeReadMore has been scheduled // if true, a maybeReadMore has been scheduled
this.readingMore = false; this.readingMore = false;
// if true, stream is in old mode
this.oldMode = false;
this.decoder = null; this.decoder = null;
this.encoding = null; this.encoding = null;
if (options.encoding) { if (options.encoding) {
@ -227,7 +224,7 @@ function howMuchToRead(n, state) {
if (state.objectMode) if (state.objectMode)
return n === 0 ? 0 : 1; return n === 0 ? 0 : 1;
if (isNaN(n) || util.isNull(n)) { if (util.isNull(n) || isNaN(n)) {
// only flow one buffer at a time // only flow one buffer at a time
if (state.flowing && state.buffer.length) if (state.flowing && state.buffer.length)
return state.buffer[0].length; return state.buffer[0].length;

2
lib/assert.js

@ -60,7 +60,7 @@ function replacer(key, value) {
if (util.isUndefined(value)) { if (util.isUndefined(value)) {
return '' + value; return '' + value;
} }
if (util.isNumber(value) && (isNaN(value) || !isFinite(value))) { if (util.isNumber(value) && !isFinite(value)) {
return value.toString(); return value.toString();
} }
if (util.isFunction(value) || util.isRegExp(value)) { if (util.isFunction(value) || util.isRegExp(value)) {

2
lib/buffer.js

@ -505,7 +505,7 @@ Buffer.prototype.readUInt32BE = function(offset, noAssert) {
return (this[offset] * 0x1000000) + return (this[offset] * 0x1000000) +
((this[offset + 1] << 16) | ((this[offset + 1] << 16) |
(this[offset + 2] << 8) | (this[offset + 2] << 8) |
(this[offset + 3]) >>> 0); this[offset + 3]);
}; };

2
lib/net.js

@ -305,7 +305,7 @@ Socket.prototype.listen = function() {
Socket.prototype.setTimeout = function(msecs, callback) { Socket.prototype.setTimeout = function(msecs, callback) {
if (msecs > 0 && !isNaN(msecs) && isFinite(msecs)) { if (msecs > 0 && isFinite(msecs)) {
timers.enroll(this, msecs); timers.enroll(this, msecs);
timers._unrefActive(this); timers._unrefActive(this);
if (callback) { if (callback) {

4
lib/string_decoder.js

@ -82,8 +82,8 @@ StringDecoder.prototype.write = function(buffer) {
while (this.charLength) { while (this.charLength) {
// determine how many remaining bytes this buffer has to offer for this char // determine how many remaining bytes this buffer has to offer for this char
var available = (buffer.length >= this.charLength - this.charReceived) ? var available = (buffer.length >= this.charLength - this.charReceived) ?
this.charLength - this.charReceived : this.charLength - this.charReceived :
buffer.length; buffer.length;
// add the new bytes to the char buffer // add the new bytes to the char buffer
buffer.copy(this.charBuffer, this.charReceived, 0, available); buffer.copy(this.charBuffer, this.charReceived, 0, available);

7
lib/zlib.js

@ -403,6 +403,7 @@ Zlib.prototype.params = function(level, strategy, callback) {
if (this._level !== level || this._strategy !== strategy) { if (this._level !== level || this._strategy !== strategy) {
var self = this; var self = this;
this.flush(binding.Z_SYNC_FLUSH, function() { this.flush(binding.Z_SYNC_FLUSH, function() {
assert(!self._closed, 'zlib binding closed');
self._handle.params(level, strategy); self._handle.params(level, strategy);
if (!self._hadError) { if (!self._hadError) {
self._level = level; self._level = level;
@ -416,6 +417,7 @@ Zlib.prototype.params = function(level, strategy, callback) {
}; };
Zlib.prototype.reset = function() { Zlib.prototype.reset = function() {
assert(!this._closed, 'zlib binding closed');
return this._handle.reset(); return this._handle.reset();
}; };
@ -476,6 +478,9 @@ Zlib.prototype._transform = function(chunk, encoding, cb) {
if (!util.isNull(chunk) && !util.isBuffer(chunk)) if (!util.isNull(chunk) && !util.isBuffer(chunk))
return cb(new Error('invalid input')); return cb(new Error('invalid input'));
if (this._closed)
return cb(new Error('zlib binding closed'));
// If it's the last chunk, or a final flush, we use the Z_FINISH flush flag. // If it's the last chunk, or a final flush, we use the Z_FINISH flush flag.
// If it's explicitly flushing at some other time, then we use // If it's explicitly flushing at some other time, then we use
// Z_FULL_FLUSH. Otherwise, use Z_NO_FLUSH for maximum compression // Z_FULL_FLUSH. Otherwise, use Z_NO_FLUSH for maximum compression
@ -512,6 +517,7 @@ Zlib.prototype._processChunk = function(chunk, flushFlag, cb) {
error = er; error = er;
}); });
assert(!this._closed, 'zlib binding closed');
do { do {
var res = this._handle.writeSync(flushFlag, var res = this._handle.writeSync(flushFlag,
chunk, // in chunk, // in
@ -532,6 +538,7 @@ Zlib.prototype._processChunk = function(chunk, flushFlag, cb) {
return buf; return buf;
} }
assert(!this._closed, 'zlib binding closed');
var req = this._handle.write(flushFlag, var req = this._handle.write(flushFlag,
chunk, // in chunk, // in
inOff, // in_off inOff, // in_off

2
node.gyp

@ -182,7 +182,7 @@
'./deps/openssl/openssl.gyp:openssl', './deps/openssl/openssl.gyp:openssl',
# For tests # For tests
'./deps/openssl/openssl.gyp:openssl-cli' './deps/openssl/openssl.gyp:openssl-cli',
], ],
}]] }]]
}, { }, {

11
src/node_constants.cc

@ -19,24 +19,15 @@
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
// USE OR OTHER DEALINGS IN THE SOFTWARE. // USE OR OTHER DEALINGS IN THE SOFTWARE.
// O_NONBLOCK is not exported unless _XOPEN_SOURCE >= 500.
#if defined(_XOPEN_SOURCE) && _XOPEN_SOURCE < 500
#undef _XOPEN_SOURCE
#endif
#if !defined(_XOPEN_SOURCE)
#define _XOPEN_SOURCE 500
#endif
#include "node_constants.h" #include "node_constants.h"
#include "uv.h" #include "uv.h"
#include <errno.h> #include <errno.h>
#include <fcntl.h>
#if !defined(_MSC_VER) #if !defined(_MSC_VER)
#include <unistd.h> #include <unistd.h>
#endif #endif
#include <fcntl.h>
#include <signal.h> #include <signal.h>
#include <sys/types.h> #include <sys/types.h>
#include <sys/stat.h> #include <sys/stat.h>

1
test/simple/test-https-foafssl.js

@ -31,6 +31,7 @@ var join = require('path').join;
var fs = require('fs'); var fs = require('fs');
var spawn = require('child_process').spawn; var spawn = require('child_process').spawn;
var https = require('https'); var https = require('https');
var options = { var options = {

58
test/simple/test-stream2-base64-single-char-read-end.js

@ -0,0 +1,58 @@
// 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.js');
var R = require('_stream_readable');
var W = require('_stream_writable');
var assert = require('assert');
var src = new R({encoding: 'base64'});
var dst = new W();
var hasRead = false;
var accum = [];
var timeout;
src._read = function(n) {
if(!hasRead) {
hasRead = true;
process.nextTick(function() {
src.push(new Buffer('1'));
src.push(null);
});
};
};
dst._write = function(chunk, enc, cb) {
accum.push(chunk);
cb();
};
src.on('end', function() {
assert.equal(Buffer.concat(accum) + '', 'MQ==');
clearTimeout(timeout);
})
src.pipe(dst);
timeout = setTimeout(function() {
assert.fail('timed out waiting for _write');
}, 100);

25
test/simple/test-stream-readable-data-sync-race.js → test/simple/test-zlib-write-after-close.js

@ -19,23 +19,22 @@
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
// USE OR OTHER DEALINGS IN THE SOFTWARE. // USE OR OTHER DEALINGS IN THE SOFTWARE.
var common = require('../common'); var common = require('../common.js');
var assert = require('assert'); var assert = require('assert');
var zlib = require('zlib');
var Readable = require('stream').Readable; var closed = false;
var r = new Readable(); zlib.gzip('hello', function(err, out) {
var errors = 0; var unzip = zlib.createGunzip();
unzip.close(function() {
// Setting `data` listener should not trigger `_read()` calls before we will closed = true;
// set the `error` listener below });
r.on('data', function() { assert.throws(function() {
}); unzip.write(out);
});
r.on('error', function() {
errors++;
}); });
process.on('exit', function() { process.on('exit', function() {
assert.equal(errors, 1); assert(closed);
}); });
Loading…
Cancel
Save