0
0
mirror of https://github.com/nodejs/node.git synced 2024-12-01 16:10:02 +01:00
Commit Graph

2443 Commits

Author SHA1 Message Date
isaacs
2c9a38d059 Merge remote-tracking branch 'ry/v0.10'
Conflicts:
	AUTHORS
	ChangeLog
	deps/v8/src/json-parser.h
	lib/crypto.js
	src/node_version.h
2013-04-05 09:02:48 -07:00
isaacs
88686aa410 http: Remove legacy ECONNRESET workaround code
Fix #5179
2013-04-03 10:18:42 -07:00
Fedor Indutny
5902bc45c5 child_process: acknowledge sent handles
Fix race-condition when multiple handles are sent and SCM_RIGHTS
messages are gets merged by OS by avoiding sending multiple handles at
once!

fix #4885
2013-04-03 09:56:48 -07:00
isaacs
4716dc662d assert: Simplify AssertError creation 2013-04-03 09:52:56 -07:00
isaacs
234fb122bb http client: Ensure socket cleanup on response end
If an http response has an 'end' handler that throws, then the socket
will never be released back into the pool.

Granted, we do NOT guarantee that throwing will never have adverse
effects on Node internal state.  Such a guarantee cannot be reasonably
made in a shared-global mutable-state side-effecty language like
JavaScript.  However, in this case, it's a rather trivial patch to
increase our resilience a little bit, so it seems like a win.

There is no semantic change in this case, except that some event
listeners are removed, and the `'free'` event is emitted on nextTick, so
that you can schedule another request which will re-use the same socket.
From the user's point of view, there should be no detectable difference.

Closes #5107
2013-04-02 20:34:08 +04:00
isaacs
164d5b3465 tls: Destroy socket when encrypted side closes
The v0.8 Stream.pipe() method automatically destroyed the destination
stream whenever the src stream closed.  However, this caused a lot of
problems, and was removed by popular demand.  (Many userland modules
still have a no-op destroy() method just because of this.) It was also
very hazardous because this would be done even if { end: false } was
passed in the pipe options.

In v0.10, we decided that the 'close' event and destroy() method are
application-specific, and pipe() doesn't automatically call destroy().
However, TLS actually depended (silently) on this behavior.  So, in this
case, we should just go ahead and destroy the thing when close happens.

Closes #5145
2013-04-01 10:53:49 -07:00
Mitar
e5b90a14b8 querystring: Removing unnecessary binding
Binding of `http_parser` in querystring isn't used anywhere and should
be removed.
2013-04-01 14:30:34 +04:00
David Braun
840a29fc0f buffer: change output of Buffer.prototype.toJSON()
Expand the JSON representation of Buffer to include type information
so that it can be deserialized in JSON.parse() without context.

Fixes #5110.
Fixes #5143.
2013-03-30 13:52:22 -07:00
Nathan Rajlich
55ea7ccf70 repl: use more readable RegExp syntax for spaces
This is just a cosmetic change really, nothing major.
2013-03-30 13:35:36 -07:00
Nathan Rajlich
085f9d636b repl: isSyntaxError() catches "strict mode" errors
Closes #5178.
2013-03-30 13:10:30 -07:00
isaacs
7af075ee30 crypto: Pass options to ctor calls 2013-03-29 09:39:51 -07:00
Kyle Robinson Young
74ef949072 zlib: allow passing options to convenience methods 2013-03-29 14:53:34 +01:00
isaacs
9100dd4b0f lint
Fixes lint errors introduced in 120e5a24df
2013-03-28 13:19:08 -07:00
isaacs
97c70a6628 Merge remote-tracking branch 'ry/v0.10'
Conflicts:
	src/node.cc
	src/node_version.h
2013-03-28 13:11:04 -07:00
Fedor Indutny
4580be0882 tls: handle SSL_ERROR_ZERO_RETURN
see #5004
2013-03-28 21:59:19 +04:00
wicked
39058bef07 setTimeout: do not calculate Timeout._when property
Dramatically improves Timer performance.
2013-03-28 10:40:15 -07:00
isaacs
929e4d9c9a stream: Emit readable on ended streams via read(0)
cc: @mjijackson
2013-03-28 10:27:18 -07:00
isaacs
eafa902632 stream: Handle late 'readable' event listeners
In cases where a stream may have data added to the read queue before the
user adds a 'readable' event, there is never any indication that it's
time to start reading.

True, there's already data there, which the user would get if they
checked However, as we use 'readable' event listening as the signal to
start the flow of data with a read(0) call internally, we ought to
trigger the same effect (ie, emitting a 'readable' event) even if the
'readable' listener is added after the first emission.

To avoid confusing weirdness, only the *first* 'readable' event listener
is granted this privileged status.  After we've started the flow (or,
alerted the consumer that the flow has started) we don't need to start
it again.  At that point, it's the consumer's responsibility to consume
the stream.

Closes #5141
2013-03-28 10:27:18 -07:00
Suwon Chae
120e5a24df os: use %SystemRoot% or %windir% in os.tmpdir()
On Windows, respect the SystemRoot and windir environment variables,
don't default to c:\windows\temp.
2013-03-28 16:44:51 +01:00
Marcin Kostrzewa
1f55704718 util: fix util.inspect() line width calculation
Have the formatter filter out vt100 color codes when calculating the
line width. Stops it from unnecessarily splitting strings over multiple
lines.

Fixes #5039.
2013-03-28 13:50:52 +01:00
Fedor Indutny
ae86fa84fe tls: handle errors before calling C++ methods
Calling `this.pair.encrypted._internallyPendingBytes()` before
handling/resetting error will result in assertion failure:

../src/node_crypto.cc:962: void node::crypto::Connection::ClearError():
Assertion `handle_->Get(String::New("error"))->BooleanValue() == false'
failed.

see #5058
2013-03-27 16:26:24 +04:00
Trevor Norris
f0b68892d4 domain: fix domain callback from MakeCallback
Since _tickCallback and _tickDomainCallback were both called from
MakeCallback, it was possible for a callback to be called that required
a domain directly to _tickCallback.

The fix was to implement process.usingDomains(). This will set all
applicable functions to their domain counterparts, and set a flag in cc
to let MakeCallback know domain callbacks always need to be checked.

Added test in own file. It's important that the test remains isolated.
2013-03-26 21:26:17 -07:00
Trevor Norris
ccda6bb3ac buffer: remove _charsWritten
_charsWritten is an internal property that was constantly written to,
but never read from. So it has been removed.

Removed documentation reference as well.
2013-03-26 17:53:34 +01:00
Manav Rathi
d20576165a tls: expose SSL_CTX_set_timeout via tls.createServer
Add the `sessionTimeout` integral value to the list of options
recognized by `tls.createServer`.

This option will be useful for applications which need frequently
establish short-lived TLS connections to the same endpoint. The TLS
tickets RFC is an ideal option to reduce the socket setup overhead
for such scenarios, but the default ticket timeout value (5
minutes) is too low to be useful.
2013-03-26 01:37:49 +01:00
Ben Noordhuis
1a65154d72 Merge remote-tracking branch 'origin/v0.10'
Conflicts:
	deps/v8/src/objects-inl.h
	deps/v8/src/objects.h
	src/node_crypto.cc
2013-03-26 00:27:23 +01:00
Ben Noordhuis
9352c19885 child_process: don't emit same handle twice
It's possible to read multiple messages off the parent/child channel.
When that happens, make sure that recvHandle is cleared after emitting
the first message so it doesn't get emitted twice.
2013-03-25 23:07:30 +01:00
Ben Noordhuis
cfd0dca9ae crypto: make getCiphers() return non-SSL ciphers
Commit f53441a added crypto.getCiphers() as a function that returns the
names of SSL ciphers.

Commit 14a6c4e then added crypto.getHashes(), which returns the names of
digest algorithms, but that creates a subtle inconsistency: the return
values of crypto.getHashes() are valid arguments to crypto.createHash()
but that is not true for crypto.getCiphers() - the returned values are
only valid for SSL/TLS functions.

Rectify that by adding tls.getCiphers() and making crypto.getCiphers()
return proper cipher names.
2013-03-25 18:42:07 +01:00
Ben Noordhuis
44843a6062 child_process: fix sending utf-8 to child process
In process#send() and child_process.ChildProcess#send(), use 'utf8' as
the encoding instead of 'ascii' because 'ascii' mutilates non-ASCII
input. Correctly handle partial character sequences by introducing
a StringDecoder.

Sending over UTF-8 no longer works in v0.10 because the high bit of
each byte is now cleared when converting a Buffer to ASCII. See
commit 96a314b for details.

Fixes #4999 and #5011.
2013-03-25 13:23:17 +01:00
isaacs
c0d500102a stream: Fix early end in Writables on zero-length writes
Doing this causes problems:

    z.write(Buffer(0));
    z.end();

Fix by not ending Writable streams while they're still in the process of
writing something.
2013-03-24 14:23:21 -07:00
Alexey Kupershtokh
9fae4dc102 timer: fix off-by-one ms error
Fix #5103
2013-03-23 18:46:14 -07:00
Gil Pedersen
c3aae9cf95 stream: Fix stall in Transform under very specific conditions
The stall is exposed in the test, though the test itself asserts before
it stalls.

The test is constructed to replicate the stalling state of a complex
Passthrough usecase since I was not able to reliable trigger the stall.

Some of the preconditions for triggering the stall are:
  * rs.length >= rs.highWaterMark
  * !rs.needReadable
  * _transform() handler that can return empty transforms
  * multiple sync write() calls

Combined this can trigger a case where rs.reading is not cleared when
further progress requires this. The fix is to always clear rs.reading.
2013-03-21 17:49:12 -07:00
Fedor Indutny
bfd16de125 timers: handle signed int32 overflow in enroll()
Before this patch calling `socket.setTimeout(0xffffffff)` will result in
signed int32 overflow in C++ which resulted in assertion error:

    Assertion failed: (timeout >= -1), function uv__io_poll, file
    ../deps/uv/src/unix/kqueue.c, line 121.

see #5101
2013-03-21 22:09:05 +04:00
isaacs
2f88272ba2 Merge remote-tracking branch 'ry/v0.10' into master
Conflicts:
	src/node.cc
	src/node_version.h
2013-03-21 10:52:01 -07:00
Fedor Indutny
855caa82aa crypto: initialize transform lazily 2013-03-20 16:49:08 -07:00
isaacs
008ab12b7f tls: Prevent hang in readStart
This is not a great fix, and it's a bug that's very tricky to reproduce.

Occasionally, while downloading a file, especially on Linux for some
reason, the pause/resume timing will be just right such that the
CryptoStream is in a 'reading' state, but actually has no data, so it
ought to pull more in.  Because there's no reads happening, it just sits
there, and the process will exit

This is, fundamentally, a factor of how the HTTP implementation sits
atop CryptoStreams and TCP Socket objects, which is utterly horrible,
and needs to be rewritten.  However, in the meantime, npm downloads are
prematurely exiting, causing hard-to-debug "cb() never called!" errors.
2013-03-20 16:14:39 -07:00
Fedor Indutny
34e22b8ee7 tls: always reset this.ssl.error after handling
Otherwise assertion may happen:

    src/node_crypto.cc:962: void node::crypto::Connection::ClearError():
    Assertion `handle_->Get(String::New("error"))->BooleanValue() == false'
    failed.

See #5058
2013-03-20 17:58:01 +04:00
Raymond Feng
25eaacad9a fs: make write/appendFileSync correctly set file mode 2013-03-20 01:37:43 +01:00
Trevor Norris
0bba590283 bindings: update api
All compile time warnings about using deprecated APIs have been
suppressed by updating node's API. Though there are still many function
calls that can accept Isolate, and still need to be updated.

node_isolate had to be added as an extern variable in node.h and
node_object_wrap.h

Also a couple small fixes for Error handling.

Before v8 3.16.6 the error stack message was lazily written when it was
needed, which allowed you to change the message after instantiation.
Then the stack would be written with the new message the first time it
was accessed. Though that has changed. Now it creates the stack message
on instantiation. So setting a different message afterwards won't be
displayed.

This is not a complete fix for the problem. Getting error without any
message isn't very useful.
2013-03-20 01:11:01 +01:00
Scott Blomquist
a05f973f82 test: Misc Windows unit test fixes
Fixes #5071, #5073.

* Normalize capitalization of drive letter
* Fix `exit()` typo in failure path
* Ignore symlink tests (Windows) if not elevated

The `test_relative_input_cwd()` test was failing on Windows when
`skipSymlinks` was `true`. So we won't run it if `skipSymlinks` is
`true`.

When it failed, the unhandled error caused Node to die before
having a chance to clean up, which resulted in two files missing
in subsequent unit tests:

 * `test/fixtures/nested-index/one/hello.js`
 * `test/fixtures/nested-index/one/index.js`

We should probably find a way to isolate this test from the other
test (`simple/test-module-loading`) that was failing when this test
poluted the disk state.
2013-03-19 09:38:11 -07:00
Fedor Indutny
b5ddc0cf96 tls: write pending data of opposite side
Fix stucked CryptoStream behaviour, happening when one of the sides
locks-up in queued state.

fix #5023
2013-03-17 20:19:09 +04:00
Fedor Indutny
14a8fb8bbe tls: write pending data of opposite side
Fix stucked CryptoStream behaviour, happening when one of the sides
locks-up in queued state.

fix #5023
2013-03-17 20:17:29 +04:00
Nao Iizuka
94284e7d2e readline: handle wide characters properly
Handle wide characters (such as あ, 谢, 고) as two column wide to make
cursor move properly.

Closes #555.
Closes #4994.
2013-03-15 16:18:30 -10:00
isaacs
14947b6c5e stream: Return self from readable.wrap
Also, set paused=false *before* calling resume().  Otherwise,
there's an edge case where an immediately-emitted chunk might make
it call pause() again incorrectly.
2013-03-14 16:43:19 -07:00
Gil Pedersen
e8f80bf479 stream: Never call decoder.end() multiple times
Updated version that does what it says without assigning state.decoder.
2013-03-14 16:13:10 -07:00
isaacs
c0721bcd66 repl: Use a domain to catch async errors safely
Fix #2031
2013-03-14 16:03:44 -07:00
Sami Samhuri
5eacdd4bf9 repl: emit 'reset' event when context is reset
Closes #1183.
2013-03-14 10:49:14 -10:00
isaacs
d62cf59dc1 http: Don't hot-path end() for large buffers
The benefits of the hot-path optimization below start to fall off when
the buffer size gets up near 128KB, because the cost of the copy is more
than the cost of the extra write() call.  Switch to the write/end method
at that point.

Heuristics and magic numbers are awful, but slow http responses are
worse.

Fix #4975
2013-03-14 08:04:59 -07:00
Ben Noordhuis
ca5022b8f1 net: improve arbitrary tcp socket support
Consider this example:

  // fd 3 is a bound tcp socket
  var s = net.createServer(cb);
  s.listen({ fd: 3 });
  console.log(s.address());  // prints null

This commit makes net.Server#address() print the actual address.

Ditto for non-listen sockets; properties like net.Socket#localAddress
and net.Socket#remoteAddress now return the correct value.

Fixes #5009.
2013-03-14 15:55:30 +01:00
Ben Noordhuis
e99dff4617 deps: upgrade libuv to 7b66ea1 2013-03-14 15:55:26 +01:00
isaacs
5e140b33e5 Revert "fs: Missing cb errors are deprecated, not a throw"
This reverts commits 6bd8b7e540
and fa05e8a270.
2013-03-13 15:51:32 -07:00