Skip to content

Commit 493d3b9

Browse files
committed
Merge remote branch 'origin/v0.4'
Conflicts: ChangeLog Makefile deps/libev/wscript doc/index.html doc/template.html lib/net.js src/node_version.h src/platform_cygwin.cc test/pummel/test-net-write-callbacks.js test/simple/test-buffer.js
2 parents 8498ee0 + ff942c6 commit 493d3b9

File tree

7 files changed

+162
-11
lines changed

7 files changed

+162
-11
lines changed

ChangeLog

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,30 @@
370370
* DTrace probes: support X-Forwarded-For (Dave Pacheco)
371371

372372

373-
2011.08.17, Version 0.4.11 (stable)
373+
2011.09.15, Version 0.4.12 (stable)
374+
375+
* Improve docs
376+
377+
* #1563 overflow in ChildProcess custom_fd.
378+
379+
* #1569, parse error on multi-line HTTP headers. (Ben Noordhuis)
380+
381+
* #1586 net: Socket write encoding case sensitivity (koichik)
382+
383+
* #1610 Remove DigiNotar CA from trusted list (isaacs)
384+
385+
* #1624 buffer: Avoid overrun with 'binary' encoding. (koichik)
386+
387+
* #1633 buffer: write() should always set _charsWritten. (koichik)
388+
389+
* #1707 hasOwnProperty usage security hole in querystring (isaacs)
390+
391+
* #1719 Drain OpenSSL error queue
392+
393+
* Fix error reporting in net.Server.listen
394+
395+
396+
2011.08.17, Version 0.4.11 (stable), a745d19ce7d1c0e3778371af4f0346be70cf2c8e
374397

375398
* #738 Fix crypto encryption/decryption with Base64. (SAWADA Tadashi)
376399

doc/api/child_processes.markdown

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,10 @@ Example of checking for failed exec:
141141
}
142142
});
143143

144+
Note that if spawn receives an empty options object, it will result in
145+
spawning the process with an empty environment rather than using
146+
`process.env`. This due to backwards compatibility issues with a deprecated
147+
API.
144148

145149
See also: `child_process.exec()`
146150

doc/api/fs.markdown

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -485,7 +485,7 @@ be found in the [MDN JavaScript Reference][MDN-Date] page.
485485

486486
## fs.ReadStream
487487

488-
`ReadStream` is a `Readable Stream`.
488+
`ReadStream` is a [Readable Stream](streams.html#readable_Stream).
489489

490490
### Event: 'open'
491491

@@ -517,7 +517,7 @@ An example to read the last 10 bytes of a file which is 100 bytes long:
517517

518518
## fs.WriteStream
519519

520-
`WriteStream` is a `Writable Stream`.
520+
`WriteStream` is a [Writable Stream](streams.html#writable_Stream).
521521

522522
### Event: 'open'
523523

doc/api_assets/style.css

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,15 @@ h4 + h4 {
126126
margin: 0 0 0.5em;
127127
}
128128

129+
h3 a,
130+
h4 a {
131+
font-size: 0.8em;
132+
float: right;
133+
color: #000;
134+
text-decoration: none;
135+
opacity: 0.3;
136+
}
137+
129138
h5 {
130139
font-size: 1.125em;
131140
line-height: 1.4em;
@@ -232,4 +241,4 @@ a.octothorpe {
232241
h5:hover > a.octothorpe,
233242
h6:hover > a.octothorpe {
234243
opacity: 1;
235-
}
244+
}

lib/tls.js

Lines changed: 41 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ function CryptoStream(pair) {
7777
this.readable = this.writable = true;
7878

7979
this._paused = false;
80+
this._needDrain = false;
8081
this._pending = [];
8182
this._pendingCallbacks = [];
8283
this._pendingBytes = 0;
@@ -111,7 +112,7 @@ CryptoStream.prototype.write = function(data /* , encoding, cb */) {
111112
data = new Buffer(data, encoding);
112113
}
113114

114-
debug('clearIn data');
115+
debug((this === this.pair.cleartext ? 'clear' : 'encrypted') + 'In data');
115116

116117
this._pending.push(data);
117118
this._pendingCallbacks.push(cb);
@@ -120,7 +121,26 @@ CryptoStream.prototype.write = function(data /* , encoding, cb */) {
120121
this.pair._writeCalled = true;
121122
this.pair.cycle();
122123

123-
return this._pendingBytes < 128 * 1024;
124+
// In the following cases, write() should return a false,
125+
// then this stream should eventually emit 'drain' event.
126+
//
127+
// 1. There are pending data more than 128k bytes.
128+
// 2. A forward stream shown below is paused.
129+
// A) EncryptedStream for CleartextStream.write().
130+
// B) CleartextStream for EncryptedStream.write().
131+
//
132+
if (!this._needDrain) {
133+
if (this._pendingBytes >= 128 * 1024) {
134+
this._needDrain = true;
135+
} else {
136+
if (this === this.pair.cleartext) {
137+
this._needDrain = this.pair.encrypted._paused;
138+
} else {
139+
this._needDrain = this.pair.cleartext._paused;
140+
}
141+
}
142+
}
143+
return !this._needDrain;
124144
};
125145

126146

@@ -420,11 +440,25 @@ CryptoStream.prototype._pull = function() {
420440
assert(rv === tmp.length);
421441
}
422442

423-
// If we've cleared all of incoming encrypted data, emit drain.
424-
if (havePending && this._pending.length === 0) {
425-
debug('drain');
426-
this.emit('drain');
427-
if (this.__destroyOnDrain) this.end();
443+
// If pending data has cleared, 'drain' event should be emitted
444+
// after write() returns a false.
445+
// Except when a forward stream shown below is paused.
446+
// A) EncryptedStream for CleartextStream._pull().
447+
// B) CleartextStream for EncryptedStream._pull().
448+
//
449+
if (this._needDrain && this._pending.length === 0) {
450+
var paused;
451+
if (this === this.pair.cleartext) {
452+
paused = this.pair.encrypted._paused;
453+
} else {
454+
paused = this.pair.cleartext._paused;
455+
}
456+
if (!paused) {
457+
debug('drain');
458+
process.nextTick(this.emit.bind(this, 'drain'));
459+
this._needDrain = false;
460+
if (this.__destroyOnDrain) this.end();
461+
}
428462
}
429463
};
430464

test/simple/test-tls-pause.js

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
// Copyright Joyent, Inc. and other Node contributors.
2+
//
3+
// Permission is hereby granted, free of charge, to any person obtaining a
4+
// copy of this software and associated documentation files (the
5+
// "Software"), to deal in the Software without restriction, including
6+
// without limitation the rights to use, copy, modify, merge, publish,
7+
// distribute, sublicense, and/or sell copies of the Software, and to permit
8+
// persons to whom the Software is furnished to do so, subject to the
9+
// following conditions:
10+
//
11+
// The above copyright notice and this permission notice shall be included
12+
// in all copies or substantial portions of the Software.
13+
//
14+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
15+
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16+
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
17+
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
18+
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
19+
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
20+
// USE OR OTHER DEALINGS IN THE SOFTWARE.
21+
22+
if (!process.versions.openssl) {
23+
console.error('Skipping because node compiled without OpenSSL.');
24+
process.exit(0);
25+
}
26+
27+
var common = require('../common');
28+
var assert = require('assert');
29+
var tls = require('tls');
30+
var fs = require('fs');
31+
var path = require('path');
32+
33+
var options = {
34+
key: fs.readFileSync(path.join(common.fixturesDir, 'test_key.pem')),
35+
cert: fs.readFileSync(path.join(common.fixturesDir, 'test_cert.pem'))
36+
};
37+
38+
var bufSize = 1024 * 1024;
39+
var sent = 0;
40+
var received = 0;
41+
42+
var server = tls.Server(options, function(socket) {
43+
socket.pipe(socket);
44+
});
45+
46+
server.listen(common.PORT, function() {
47+
var resumed = false;
48+
var client = tls.connect(common.PORT, function() {
49+
client.pause();
50+
common.debug('paused');
51+
send();
52+
function send() {
53+
if (client.write(new Buffer(bufSize))) {
54+
sent += bufSize;
55+
assert.ok(sent < 100 * 1024 * 1024); // max 100MB
56+
return process.nextTick(send);
57+
}
58+
sent += bufSize;
59+
common.debug('sent: ' + sent);
60+
resumed = true;
61+
client.resume();
62+
common.debug('resumed');
63+
}
64+
});
65+
client.on('data', function(data) {
66+
assert.ok(resumed);
67+
received += data.length;
68+
if (received >= sent) {
69+
common.debug('received: ' + received);
70+
client.end();
71+
server.close();
72+
}
73+
});
74+
});
75+
76+
process.on('exit', function() {
77+
assert.equal(sent, received);
78+
});

tools/doctool/doctool.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,9 @@ function convertData(data) {
8888
.replace(/<hr><\/hr>/g, "<hr />")
8989
.replace(/(\<h[2-6])\>([^<]+)(\<\/h[1-6]\>)/gmi, function(o, ts, c, te) {
9090
return ts+' id="'+formatIdString(c)+'">'+c+te;
91+
})
92+
.replace(/(\<h[3-4][^>]+\>)([^<]+)(\<\/h[3-4]\>)/gmi, function(o, ts, c, te) {
93+
return ts+c+' <a href="#'+formatIdString(c)+'">#</a>'+te;
9194
});
9295

9396
return html;

0 commit comments

Comments
 (0)