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

2385 Commits

Author SHA1 Message Date
Jeff Barczewski
26ca7d73ca stream: objectMode transform should allow falsey values
If a transform stream has objectMode = true, it should
allow falsey values other than (null) like 0, false, ''.

null is reserved to indicate stream eof but other falsey
values should flow through properly.
2013-07-03 15:07:01 -07:00
Trevor Norris
278183a902 {stream,udp,tls}_wrap: remove unused offset/length
The function arguments offset and length are now no longer used since
all I/O requests now use discretely allocated memory.
2013-07-03 15:03:41 -07:00
Timothy J Fontaine
4c38742dd8 test: fix tls-hello-parser-failure on smartos
Assert that when the client closes it has seen an error, this prevents
the test from timing out.

Also queue a second write in the case that we were able to send the
buffer before the other side closed the connection.
2013-07-01 17:41:38 -07:00
Peter Rust
16b59cbc74 http: use an unref'd timer to fix delay in exit
There was previously up to a second exit delay when exiting node
right after an http request/response, due to the utcDate() function
doing a setTimeout to update the cached date/time.

Fixing this should increase the performance of our http tests.
2013-07-01 16:02:25 -07:00
Timothy J Fontaine
6f8ddf3759 test: fix tls-hello-parser-failure on smartos
Assert that when the client closes it has seen an error, this prevents
the test from timing out.

Also queue a second write in the case that we were able to send the
buffer before the other side closed the connection.
2013-07-01 15:04:56 -07:00
Brian White
9b09c9eedd zlib: allow changing of level and strategy 2013-07-01 13:08:09 +02:00
Brian White
086d4ccace zlib: allow custom flush type for flush() 2013-07-01 13:08:09 +02:00
Miroslav Bajtos
c16963b977 src: break on uncaught exception
Most TryCatch blocks have SetVerbose flag on, this tells V8 to report
uncaught exceptions to debugger.

FatalException handler is called from V8 Message listener instead from
the place where TryCatch was used. Otherwise uncaught exceptions are
logged twice.

See comment in `deps/v8/include/v8.h` for explanation of SetVerbose
flag:

>  By default, exceptions that are caught by an external exception
>  handler are not reported.  Call SetVerbose with true on an
>  external exception handler to have exceptions caught by the
>  handler reported as if they were not caught.

The flag is used by `Isolate::ShouldReportException()`, which is called
by `Isolate::DoThrow()` to decide whether an exception is considered
uncaught.
2013-06-26 19:54:31 +02:00
isaacs
adf9b67e59 Merge remote-tracking branch 'ry/v0.10' into master
Conflicts:
	ChangeLog
	deps/uv/ChangeLog
	deps/uv/src/unix/stream.c
	deps/uv/src/version.c
	deps/v8/build/common.gypi
	deps/v8/src/frames.h
	deps/v8/src/runtime.cc
	deps/v8/test/mjsunit/debug-set-variable-value.js
	lib/http.js
	src/node_version.h
2013-06-25 11:12:33 -07:00
Ben Noordhuis
b255f4c10a child_process: emit 'disconnect' asynchronously
Deferring I/O-triggered events to the next event loop tick is not just
a good idea, IT'S THE LAW!
2013-06-20 23:24:55 +02:00
Trevor Norris
4b40358841 buffer: implement new fill behavior
Old fill would take the char code of the first character and wrap around
the int to fit in the 127 range. Now fill will duplicate whatever string
is given through the entirety of the buffer.

Note: There is one bug around ending on a partial fill of any character
outside the ASCII range.
2013-06-18 15:41:03 -07:00
Trevor Norris
fb40da822f buffer: expose class methods alloc and dispose
Expose the ability for users to allocate and manually dispose data on
any object. These are user-safe versions of internal smalloc functions.
2013-06-18 15:39:32 -07:00
Trevor Norris
3a2f273bd7 buffer: use smalloc as backing data store
Memory allocations are now done through smalloc. The Buffer cc class has
been removed completely, but for backwards compatibility have left the
namespace as Buffer.

The .parent attribute is only set if the Buffer is a slice of an
allocation. Which is then set to the alloc object (not a Buffer).

The .offset attribute is now a ReadOnly set to 0, for backwards
compatibility. I'd like to remove it in the future (pre v1.0).

A few alterations have been made to how arguments are either coerced or
thrown. All primitives will now be coerced to their respective values,
and (most) all out of range index requests will throw.

The indexes that are coerced were left for backwards compatibility. For
example: Buffer slice operates more like Array slice, and coerces
instead of throwing out of range indexes. This may change in the future.

The reason for wanting to throw for out of range indexes is because
giving js access to raw memory has high potential risk. To mitigate that
it's easier to make sure the developer is always quickly alerted to the
fact that their code is attempting to access beyond memory bounds.

Because SlowBuffer will be deprecated, and simply returns a new Buffer
instance, all tests on SlowBuffer have been removed.

Heapdumps will now show usage under "smalloc" instead of "Buffer".

ParseArrayIndex was added to node_internals to support proper uint
argument checking/coercion for external array data indexes.

SlabAllocator had to be updated since handle_ no longer exists.
2013-06-18 15:39:13 -07:00
Trevor Norris
252cdfa43b smalloc: add api to manually dispose Persistent
If the user knows the allocation is no longer needed then the memory can
be manually released.

Currently this will not ClearWeak the Persistent, so the callback will
still run.

If the user passed a ClearWeak callback, and then disposed the object,
the buffer callback argument will == NULL.
2013-06-18 15:38:06 -07:00
Trevor Norris
8f3f9f7830 smalloc: initial implementation
smalloc is a simple utility for quickly allocating external memory onto
js objects. This will be used to centralize how memory is managed in
node, and will become the backer for Buffers. So in the future crypto's
SlabBuffer, stream's SlabAllocator will be removed.

Note on the js API: because no arguments are optional the order of
arguments have been placed to match their cc counterparts as closely as
possible.
2013-06-18 15:37:51 -07:00
Krzysztof Chrapka
ffcd8b94c2 readline: strip ctrl chars for prompt width calc
Use regular expression to strip vt ansi escape codes from display when
calulating prompt display width and cursor position

Fixes #3860 and #5628.
2013-06-17 16:19:12 +02:00
Fedor Indutny
212e9cd8c9 tls: session API returns 2013-06-17 14:00:26 +02:00
isaacs
3c7945bda1 net: Do not destroy socket mid-write
The fix in e0519ace31 is overly zealous,
and can destroy a socket while there are still outstanding writes in
progress.

Closes GH-5688
2013-06-16 19:06:27 -07:00
Fedor Indutny
af80e7bc6e tls: introduce TLSSocket based on tls_wrap binding
Split `tls.js` into `_tls_legacy.js`, containing legacy
`createSecurePair` API, and `_tls_wrap.js` containing new code based on
`tls_wrap` binding.

Remove tests that are no longer useful/valid.
2013-06-16 09:30:15 +02:00
Ben Noordhuis
10133aaa46 test: add https tls session reuse test
Check that TLS session resumptions work with HTTPS servers.

Regression test for #3901.
2013-06-15 20:35:59 +02:00
Veres Lajos
9a4e5937ee test: minor typo fixes 2013-06-13 13:33:06 +02:00
isaacs
e8500274e0 Revert "http: remove bodyHead from 'upgrade' events"
This reverts commit a40133d10c.

Unfortunately, this breaks socket.io.  Even though it's not strictly an
API change, it is too subtle and in too brittle an area of node, to be
done in a stable branch.

Conflicts:
	doc/api/http.markdown
2013-06-12 17:45:30 -07:00
Trevor Norris
e92f4879eb string_bytes: write strings using new API
StringBytes::Write now uses new v8 API and also does preliminary check
if the string is external, then will use external memory instead.
2013-06-12 14:43:37 -07:00
Ben Noordhuis
3b0a759b6b test: fix up weakref.cc after v8 api change 2013-06-12 00:24:41 +02:00
Ben Noordhuis
82b3524bce crypto: fix utf8/utf-8 encoding check
Normalize the encoding in getEncoding() before using it. Fixes a
"AssertionError: Cannot change encoding" exception when the caller
mixes "utf8" and "utf-8".

Fixes #5655.
2013-06-11 13:07:24 +02:00
isaacs
0882a75063 Merge remote-tracking branch 'ry/v0.10'
Conflicts:
	ChangeLog
	deps/uv/AUTHORS
	deps/uv/ChangeLog
	deps/uv/src/unix/linux-core.c
	deps/uv/src/version.c
	deps/uv/src/win/timer.c
	lib/url.js
	src/node_version.h
	test/simple/test-url.js
2013-06-05 13:38:38 -07:00
isaacs
e0519ace31 net: Destroy when not readable and not writable
This is only relevant for CentOS 6.3 using kernel version 2.6.32.

On other linuxes and darwin, the `read` call gets an ECONNRESET in that
case.  On sunos, the `write` call fails with EPIPE.

However, old CentOS will occasionally send an EOF instead of a
ECONNRESET or EPIPE when the client has been destroyed abruptly.

Make sure we don't keep trying to write or read more in that case.

Fixes #5504

However, there is still the question of what libuv should do when it
gets an EOF.  Apparently in this case, it will continue trying to read,
which is almost certainly the wrong thing to do.

That should be fixed in libuv, even though this works around the issue.
2013-06-05 08:06:35 -07:00
isaacs
5dc51d4e21 url: Properly parse certain oddly formed urls
In cases where there are multiple @-chars in a url, Node currently
parses the hostname and auth sections differently than web browsers.

This part of the bug is serious, and should be landed in v0.10, and
also ported to v0.8, and releases made as soon as possible.

The less serious issue is that there are many other sorts of malformed
urls which Node either accepts when it should reject, or interprets
differently than web browsers.  For example, `http://a.com*foo` is
interpreted by Node like `http://a.com/*foo` when web browsers treat
this as `http://a.com%3Bfoo/`.

In general, *only* the `hostEndingChars` should be the characters that
delimit the host portion of the URL.  Most of the current `nonHostChars`
that appear in the hostname should be escaped, but some of them (such as
`;` and `%` when it does not introduce a hex pair) should raise an
error.

We need to have a broader discussion about whether it's best to throw in
these cases, and potentially break extant programs, or return an object
that has every field set to `null` so that any attempt to read the
hostname/auth/etc. will appear to be empty.
2013-06-03 15:56:16 -07:00
isaacs
df6ffc018e stream: unshift('') is a noop
In some cases, the http CONNECT/Upgrade API is unshifting an empty
bodyHead buffer onto the socket.

Normally, stream.unshift(chunk) does not set state.reading=false.
However, this check was not being done for the case when the chunk was
empty (either `''` or `Buffer(0)`), and as a result, it was causing the
socket to think that a read had completed, and to stop providing data.

This bug is not limited to http or web sockets, but rather would affect
any parser that unshifts data back onto the source stream without being
very careful to never unshift an empty chunk.  Since the intent of
unshift is to *not* change the state.reading property, this is a bug.

Fixes #5557
Fixes LearnBoost/socket.io#1242
2013-06-03 10:50:04 -07:00
isaacs
2900f0778a Merge remote-tracking branch 'ry/v0.10'
Conflicts:
	ChangeLog
	src/node_version.h
2013-05-31 11:52:57 -07:00
Trevor Norris
0761c90204 process: remove maxTickDepth from _tickCallback
Removes the check for maxTickDepth for non-domain callbacks. So a user
can starve I/O by setting a recursive nextTick.

The domain case is more complex and will be addressed in another commit.
2013-05-30 09:30:19 -07:00
Andrew Paprocki
49e3fcd058 vm: fix race condition in watchdog cleanup
Previous code was calling uv_loop_delete() directly on a running loop,
which led to race condition aborts/segfaults within libuv.  This change
changes the watchdog thread to call uv_run() with UV_RUN_ONCE so that
the call exits after either the timer times out or uv_async_send() is
called from the main thread in Watchdog::Destroy().  The timer/async
handles are then closed and uv_run() with UV_RUN_DEFAULT is called so
that libuv has a chance to cleanup before the thread exits.  The main
thread meanwhile calls uv_thread_join() and then uv_loop_delete() to
complete the cleanup.
2013-05-30 15:57:25 +02:00
Brian White
774b28fde7 repl: fix JSON.parse error check
Before this, entering something like:

> JSON.parse('066');

resulted in the "..." prompt instead of displaying the expected
"SyntaxError: Unexpected number"
2013-05-30 14:41:00 +02:00
Ben Noordhuis
28659aba37 Merge remote-tracking branch 'origin/v0.10'
Conflicts:
	deps/uv/ChangeLog
	deps/uv/src/unix/stream.c
	deps/uv/src/version.c
	lib/tls.js
2013-05-29 23:12:11 +02:00
Fedor Indutny
4f14221f03 tls: invoke write cb only after opposite read end
Stream's `._write()` callback should be invoked only after it's opposite
stream has finished processing incoming data, otherwise `finish` event
fires too early and connection might be closed while there's some data
to send to the client.

see #5544
2013-05-28 22:27:07 +04:00
isaacs
ba048e72b0 Merge remote-tracking branch 'ry/v0.10'
Conflicts:
	AUTHORS
	ChangeLog
	configure
	deps/uv/ChangeLog
	deps/uv/src/unix/darwin.c
	deps/uv/src/unix/stream.c
	deps/uv/src/version.c
	deps/v8/src/isolate.cc
	deps/v8/src/version.cc
	lib/http.js
	src/node_version.h
2013-05-27 14:46:52 -07:00
Fedor Indutny
f7ff8b4454 tls: retry writing after hello parse error
When writing bad data to EncryptedStream it'll first get to the
ClientHello parser, and, only after it will refuse it, to the OpenSSL.
But ClientHello parser has limited buffer and therefore write could
return `bytes_written` < `incoming_bytes`, which is not the case when
working with OpenSSL.

After such errors ClientHello parser disables itself and will
pass-through all data to the OpenSSL. So just trying to write data one
more time will throw the rest into OpenSSL and let it handle it.
2013-05-24 15:03:48 -07:00
Nathan Zadoks
a40133d10c http: remove bodyHead from 'upgrade' events
Streams2 makes this unnecessary.
An empty buffer is provided for compatibility.
2013-05-24 14:34:32 -07:00
Timothy J Fontaine
007e63bb13 buffer: special case empty string writes
Prior to 119354f we specifically handled passing a zero length string
to write on a buffer, restore that functionality.
2013-05-23 16:32:04 -07:00
isaacs
a2f93cf77a http: Return true on empty writes, not false
Otherwise, writing an empty string causes the whole program to grind to
a halt when piping data into http messages.

This wasn't as much of a problem (though it WAS a bug) in 0.8 and
before, because our hyperactive 'drain' behavior would mean that some
*previous* write() would probably have a pending drain event, and cause
things to start moving again.
2013-05-23 15:21:17 -07:00
isaacs
52adc0d963 test: Fix test-deprecation-flags
Test typos missed in util deprecation commit
2013-05-22 11:46:52 -07:00
Timothy J Fontaine
a846d9388c net: use timers._unrefActive for internal timeouts 2013-05-21 16:40:31 -07:00
isaacs
896b2aa707 util: Add debuglog, deprecate console lookalikes 2013-05-21 16:39:50 -07:00
Trevor Norris
2cad7a69ce buffer: throw when writing beyond buffer
Previously one could write anywhere in a buffer pool if they accidently
got their offset wrong. Mainly because the cc level checks only test
against the parent slow buffer and not against the js object properties.
So now we check to make sure values won't go beyond bounds without
letting the dev know.
2013-05-20 15:23:23 -07:00
isaacs
0fefcc1690 Merge remote-tracking branch ry/v0.10 into master
Conflicts:
	AUTHORS
	ChangeLog
	src/node_crypto.cc
	src/node_version.h
2013-05-20 14:43:14 -07:00
isaacs
3a2b5030ae crypto: Clear error after DiffieHellman key errors
Fixes #5499
2013-05-20 14:27:32 -07:00
Trevor Norris
d5d5170c35 string_bytes: strip padding from base64 strings
Because of variations in different base64 implementation, it's been
decided to strip all padding from the end of a base64 string and
calculate its size from that.
2013-05-20 13:40:58 -07:00
Ben Noordhuis
d820b64412 tls: add localAddress and localPort properties
Add localAddress and localPort properties to tls.CleartextStream.
Like remoteAddress and localPort, delegate to the backing net.Socket
object.

Refs #5502.
2013-05-20 15:18:50 +02:00
Robert Kowalski
812356049d module: use path.sep instead of a custom solution
Instead of using a custom solution we can use path.sep in
Module._nodeModulePaths
2013-05-18 01:43:07 +02:00
isaacs
61c9f78c63 Merge remote-tracking branch 'ry/v0.10' into master
Conflicts:
	AUTHORS
	ChangeLog
	deps/uv/ChangeLog
	deps/uv/config-unix.mk
	deps/uv/src/unix/stream.c
	deps/uv/src/version.c
	deps/uv/uv.gyp
	src/node.cc
	src/node_buffer.cc
	src/node_crypto.cc
	src/node_version.h
	src/stream_wrap.cc
	src/stream_wrap.h
2013-05-17 14:04:54 -07:00
Ben Noordhuis
f59ab10a64 buffer, crypto: fix default encoding regression
The default encoding is 'buffer'. When the input is a string, treat it
as 'binary'. Fixes the following assertion:

  node: ../src/string_bytes.cc:309: static size_t
  node::StringBytes::StorageSize(v8::Handle<v8::Value>, node::encoding):
  Assertion `0 && "buffer encoding specified but string provided"'
  failed.

Introduced in 64fc34b2.

Fixes #5482.
2013-05-16 17:25:24 +02:00
Ben Noordhuis
22533c035d timers: fix setInterval() assert
Test case:

  var t = setInterval(function() {}, 1);
  process.nextTick(t.unref);

Output:

  Assertion failed: (args.Holder()->InternalFieldCount() > 0),
  function Unref, file ../src/handle_wrap.cc, line 78.

setInterval() returns a binding layer object. Make it stop doing that,
wrap the raw process.binding('timer_wrap').Timer object in a Timeout
object.

Fixes #4261.
2013-05-16 00:02:54 +02:00
Robert Kowalski
04ce80760e module: use path.sep instead of custom solution
Instead of using a custom solution for path delimiters we can use
path.sep in Module._initPaths
2013-05-15 23:57:58 +02:00
Ben Noordhuis
7124387b34 http: don't escape request path, reject bad chars
Commit 38149bb changes http.get() and http.request() to escape unsafe
characters. However, that creates an incompatibility with v0.10 that
is difficult to work around: if you escape the path manually, then in
v0.11 it gets escaped twice. Change lib/http.js so it no longer tries
to fix up bad request paths, simply reject them with an exception.

The actual check is rather basic right now. The full check for illegal
characters is difficult to implement efficiently because it requires a
few characters of lookahead. That's why it currently only checks for
spaces because those are guaranteed to create an invalid request.

Fixes #5474.
2013-05-15 22:53:29 +02:00
Ben Noordhuis
b3d1e504f4 net: emit dns 'lookup' event before connect
net.connect() and net.createConnection() now emit a 'lookup' event
after resolving the hostname but before connecting.

Fixes #5418.
2013-05-15 22:53:29 +02:00
Timothy J Fontaine
8886c6bf62 dns: add getServers and setServers
getServers returns an array of ips that are currently being used for
resolution

setServers takes an array of ips that are to be used for resolution,
this will throw if there's invalid input but preserve the original
configuration
2013-05-14 14:15:24 -07:00
Benoit Vallée
dbe9f8da6b test: increase workers to 8 in cluster-disconnect
Increasing the number of workers from 2 to 8 makes this test
more likely to trigger race conditions. See #5330 for background.
2013-05-14 12:37:39 +02:00
Bert Belder
bdc5881169 Merge branch 'v0.10'
Conflicts:
	tools/test.py
2013-05-13 11:13:39 -07:00
Ben Noordhuis
21bd456763 child_process: fix handle delivery
Commit 9352c19 ("child_process: don't emit same handle twice") trades
one bug for another.

Before said commit, a handle was sometimes delivered with messages it
didn't belong to.

The bug fix introduced another bug that needs some explaining. On UNIX
systems, handles are basically file descriptors that are passed around
with the sendmsg() and recvmsg() system calls, using auxiliary data
(SCM_RIGHTS) as the transport.

node.js and libuv depend on the fact that none of the supported systems
ever emit more than one SCM_RIGHTS message from a recvmsg() syscall.
That assumption is something we should probably address someday for the
sake of portability but that's a separate discussion.

So, SCM_RIGHTS messages are never coalesced. SCM_RIGHTS and normal
messages however _are_ coalesced. That is, recvmsg() might return this:

  recvmsg();  // { "message-with-fd", "message", "message" }

The operating system implicitly breaks pending messages along
SCM_RIGHTS boundaries. Most Unices break before such messages but Linux
also breaks _after_ them.  When the sender looks like this:

  sendmsg("message");
  sendmsg("message-with-fd");
  sendmsg("message");

Then on most Unices the receiver sees messages arriving like this:

  recvmsg();  // { "message" }
  recvmsg();  // { "message-with-fd", "message" }

The bug fix in commit 9352c19 assumes this behavior. On Linux however,
those messages can also come in like this:

  recvmsg();  // { "message", "message-with-fd" }
  recvmsg();  // { "message" }

In other words, it's incorrect to assume that the file descriptor is
always attached to the first message. This commit makes node wise up.

Fixes #5330.
2013-05-13 10:49:59 -07:00
Nick Sullivan
8db693a87e util: make util.log handle non strings like console.log
util.log will fail on input that does not support .toString(). Have it
use console.log() instead. Includes tests for hairy data types.

Fixes #5349.
2013-05-13 12:35:17 +02:00
Ben Noordhuis
69572a3965 test: fix up weakref.cc deprecation warnings 2013-05-13 06:46:55 +02:00
Ben Noordhuis
7bfcaa8f91 test: fix up weakref.cc after v8 api change 2013-05-13 06:45:05 +02:00
isaacs
5e9c7a92f2 test: Darwin file watcher has paths now
Even when watching subdirs.
2013-05-10 16:40:03 -07:00
isaacs
a58454226f stream: Handle multi-corking properly
This adds proper support for the following situation:

    w.cork();
    w.write(...);
    w.cork();
    w.write(...);
    w.uncork();
    w.write(...);
    w.uncork();

This is relevant when you have a function (as we do in HTTP) that wants
to use cork, but in some cases, want to have a cork/uncork *around*
that function, without losing the benefits of writev.
2013-05-09 09:35:32 -07:00
isaacs
c38ce9bc0a stream: Guarantee ordering of 'finish' event
In synchronous Writable streams (where the _write cb is called on the
current tick), the 'finish' event (and thus the end() callback) can in
some cases be called before all the write() callbacks are called.

Use a counter, and have stream.Transform rely on the 'prefinish' event
instead of the 'finish' event.

This has zero effect on most streams, but it corrects an edge case and
makes it perform more deterministically, which is a Good Thing.
2013-05-09 09:35:32 -07:00
Timothy J Fontaine
72c58158f7 test: fix pummel/test-net-many-clients.js
client sockets no longer emit 'connect' event inside the
requestListener, update test-net-many-clients to reflect that
2013-05-08 19:31:45 -07:00
Ben Kelly
8a407f58b9 os: Include netmask in os.networkInterfaces()
re #3765 and #5432
fixes #4743
2013-05-08 17:04:29 -07:00
Miroslav Bajtoš
43ec1b1c2e debugger, cluster: each worker has new debug port
Implement support for debugging cluster workers. Each worker process
is assigned a new debug port in an increasing sequence.

I.e. when master process uses port 5858, then worker 1 uses port 5859,
worker 2 uses port 5860, and so on.

Introduce new command-line parameter '--debug-port=' which sets debug_port
but does not start debugger. This option works for all node processes, it
is not specific to cluster workers.

Fixes joyent/node#5318.
2013-05-08 16:53:52 -07:00
Daniel Moore
3b6fc600e2 stream: make Readable.wrap support empty streams
This makes Readable.wrap behave properly when the wrapped stream ends
before emitting any data events.
2013-05-08 11:59:40 -07:00
Daniel Moore
1ad93a6584 stream: make Readable.wrap support objectMode
Added a check to see if the stream is in objectMode before deciding
whether to include or exclude data from an old-style wrapped stream.
2013-05-08 11:59:28 -07:00
Timothy J Fontaine
a90dc41df2 test: reap children when cluster-bind-twice fails 2013-05-06 11:31:57 -07:00
Sam Roberts
4c02282c7e test: EventEmitter#setMaxListeners() returns this
Add a regression test for commit f8d8122.
2013-05-03 02:05:26 +02:00
Miroslav Bajtoš
a32a243d5f debugger: breakpoints in scripts not loaded yet
When developer calls setBreakpoint with an unknown script name,
we convert the script name into regular expression matching all
paths ending with given name (name can be a relative path too).

To create such breakpoint in V8, we use type `scriptRegEx`
instead of `scriptId` for `setbreakpoint` request.

To restore such breakpoint, we save the original script name
send by the user. We use this original name to set (restore)
breakpoint in the new child process.

This is a back-port of commit 5db936d from the master branch.
2013-05-02 08:52:58 +02:00
Ben Noordhuis
ab518e8831 https: implement https.Server#setTimeout()
Like commit d258fb0 ("http: More useful setTimeout API on server") but
this time for the https module.

Fixes #5361.
2013-04-30 13:10:56 +02:00
Andrew Paprocki
c081809344 vm: add support for timeout argument
Add a watchdog class which executes a timer in a separate event loop in
a separate thread that will terminate v8 execution if it expires.

Add timeout argument to functions in vm module which use the watchdog
if a non-zero timeout is specified.
2013-04-29 23:38:19 +02:00
Miroslav Bajtoš
5ddf7f4200 debugger: fix bug in breakpoint regex escaping
Fix a bug in setBreakpoint() where not all regex characters are escaped
when constructing scriptRegEx for V8.
2013-04-29 14:40:00 +02:00
Ben Noordhuis
af1ed99ce2 Merge remote-tracking branch 'origin/v0.10'
Conflicts:
	AUTHORS
	ChangeLog
	deps/uv/ChangeLog
	deps/uv/src/version.c
	lib/http.js
	src/node_crypto.cc
	src/node_os.cc
	src/node_version.h
	test/simple/helper-debugger-repl.js
2013-04-29 14:08:51 +02:00
Fedor Indutny
0c72936641 test: fix timing sensitive tests 2013-04-27 21:03:40 +04:00
Miroslav Bajtoš
5db936d2ae debugger: breakpoints in scripts not loaded yet
When developer calls setBreakpoint with an unknown script name,
we convert the script name into regular expression matching all
paths ending with given name (name can be a relative path too).

To create such breakpoint in V8, we use type `scriptRegEx`
instead of `scriptId` for `setbreakpoint` request.

To restore such breakpoint, we save the original script name
send by the user. We use this original name to set (restore)
breakpoint in the new child process.
2013-04-27 12:51:22 +02:00
Miroslav Bajtoš
8c2ad47f42 debugger: restart with custom debug port
Fixed a bug in debugger repl where `restart` command did not work
when a custom debug port was specified via command-line option
--port={number}.

File test/simple/helper-debugger-repl.js was extracted
from test/simple/test-debugger-repl.js
2013-04-26 21:10:05 +02:00
Miroslav Bajtoš
74323a95a0 debugger: restart with custom debug port
Fixed a bug in debugger repl where `restart` command did not work
when a custom debug port was specified via command-line option
--port={number}.

File test/simple/helper-debugger-repl.js was extracted
from test/simple/test-debugger-repl.js
2013-04-26 21:08:01 +02:00
Ben Noordhuis
45ed546009 test: cluster: unhide child errors in bind-twice
Errors in leaf child processes weren't picked up by the test runner
because they didn't get bubbled up to the main process. Don't forcibly
kill the child processes; tell them to quit gracefully, then inspect
their exit codes.
2013-04-25 22:29:46 +02:00
Ben Noordhuis
872e720c9f test: cluster: rename bind-twice-v2 to bind-twice 2013-04-25 22:20:33 +02:00
Ben Noordhuis
5a16d258ef test: cluster: remove bind-twice-v1 test
It tests the same thing as bind-twice-v2, only not as in-depth.
2013-04-25 22:09:33 +02:00
isaacs
025f9133bb http: Don't try to destroy nonexistent sockets
Fixes #3740

In the case of pipelined requests, you can have a situation where
the socket gets destroyed via one req/res object, but then trying
to destroy *another* req/res on the same socket will cause it to
call undefined.destroy(), since it was already removed from that
message.

Add a guard to OutgoingMessage.destroy and IncomingMessage.destroy
to prevent this error.
2013-04-22 10:38:14 -07:00
isaacs
01e2920219 http: Don't try to destroy nonexistent sockets
Fixes #3740

In the case of pipelined requests, you can have a situation where
the socket gets destroyed via one req/res object, but then trying
to destroy *another* req/res on the same socket will cause it to
call undefined.destroy(), since it was already removed from that
message.

Add a guard to OutgoingMessage.destroy and IncomingMessage.destroy
to prevent this error.
2013-04-22 09:54:04 -07:00
isaacs
1d794ec43e test: fix dgram-bind-default-address on osx
Allow the IPv4-mapped-as-IPv6 style address.
2013-04-22 08:56:29 -07:00
isaacs
4bf1d1007f crypto: LazyTransform on properties, not methods
It needs to apply the Transform class when the _readableState,
_writableState, or _transformState properties are accessed,
otherwise things like setEncoding and on('data') don't work
properly.

Also, the methods wrappers are no longer needed, since they're only
problematic because they access the undefined properties.
2013-04-21 09:33:10 -04:00
Ben Noordhuis
cf0fa96db8 events: add EventEmitter.defaultMaxListeners
Class property that controls the maximum number of listeners for all
instances of EventEmitter.

Fixes #3014.

Conflicts:
	lib/events.js
2013-04-19 16:21:37 -07:00
Ryan Doenges
9026675061 path: add path.isAbsolute(path)
An absolute path will always open the same location regardless of your
current working directory. For posix, this just means path.charAt(0) ===
'/', but on Windows it's a little more complicated.

Fixes joyent/node#5299.
2013-04-19 10:15:22 -07:00
isaacs
42b8682a51 test: fix dgram-bind-default-address on osx
Allow the IPv4-mapped-as-IPv6 style address.
2013-04-19 08:32:32 -07:00
isaacs
0bccb341c4 Merge remote-tracking branch 'ry/v0.10' 2013-04-18 16:21:24 -07:00
Ryan Doenges
6101eb184d assert: put info in err.message, not err.name
4716dc6 made assert.equal() and related functions work better by
generating a better toString() from the expected, actual, and operator
values passed to fail(). Unfortunately, this was accomplished by putting
the generated message into the error's `name` property. When you passed
in a custom error message, the error would put the custom error into
`name` *and* `message`, resulting in helpful string representations like
"AssertionError: Oh no: Oh no".

This commit resolves that issue by storing the generated message in the
`message` property while leaving the error's name alone and adding
a regression test so that this doesn't pop back up later.

Closes #5292.
2013-04-18 15:08:35 -07:00
Ben Noordhuis
8e190bf6a1 Merge remote-tracking branch 'origin/v0.10'
Conflicts:
	src/node_os.cc
2013-04-18 12:14:30 +02:00
Ben Noordhuis
92023b4b37 dgram: fix no address bind()
I broke dgram.Socket#bind(port, cb) almost a year ago in 332fea5a but
it wasn't until today that someone complained and none of the tests
caught it because they all either specify the address or omit the
callback.

Anyway, now it works again and does what you expect: it binds the
socket to the "any" address ("0.0.0.0" for IPv4 and "::" for IPv6.)
2013-04-18 00:54:57 +02:00
Ben Noordhuis
2e70ddad9d test: make stdout-close-unref work in test runner
process.stdout isn't fully initialized yet by the time the test starts
when invoked with `python tools/test.py`. Use process.stdin instead and
force initialization with process.stdin.resume().
2013-04-18 00:02:51 +02:00
Ben Noordhuis
ccd37226c6 handle_wrap: fix NULL pointer dereference
Fix a NULL pointer dereference in src/handle_wrap.cc which is really a
use-after-close bug.

The test checks that unref() after close() works on process.stdout but
this bug affects everything that derives from HandleWrap. I discovered
it because child processes would sometimes quit for no reason (that is,
no reason until I turned on core dumps.)
2013-04-16 23:11:03 +02:00
Stanislav Ochotnicky
7592615aaa test: preserve process.env after test-init exec
When LD_LIBRARY_PATH is overriden for custom builds we need to preserve
it for child processes. To be sure we preserve whole environment of
parent process and just add TEST_INIT variable to it.
2013-04-16 17:05:51 +02:00
Stanislav Ochotnicky
47198af55a test: preserve process.env in forked child_process
When LD_LIBRARY_PATH is overriden for custom builds we need to preserve
it for forked process. There are possibly other environment variables
that could cause test failures so we preserve whole environment of
parent process.
2013-04-16 17:05:51 +02:00
Ben Noordhuis
31d0d5af8e test: add extra checks 2013-04-12 16:27:50 -07:00