The test is supposed to measure the performance of the base64 encoder
so move the Buffer#write() calls out of the benchmark section.
The overhead of the calls isn't terrible (about 1-3%) but having
unrelated activity in a micro-benchmark is never a good idea.
Signed-off-by: Trevor Norris <trev.norris@gmail.com>
Replace the CONTAINER_OF macro with a template function that is as
type-safe as a reinterpret_cast<> of an arbitrary pointer can be made.
Signed-off-by: Fedor Indutny <fedor@indutny.com>
Currently, if fstat() fails in readFile(), the callback
is invoked without closing the file. This commit closes
the file before calling back.
Closes#7697
Currently, if fstat() fails in readFile(), the callback
is invoked without closing the file. This commit closes
the file before calling back.
Closes#7697
See https://github.com/joyent/node/issues/7675
net.server.listen() behaves inconsistently depending on whether the port
number is provided.
1. port === 0 && host == '' (i.e. false-y), node creates an AF_INET
socket but does not call bind().
2. port > 0 && host == '', node creates an AF_INET6 socket and calls
bind().
The fix makes 1 consistent with 2.
Signed-off-by: Fedor Indutny <fedor@indutny.com>
Rework the fix from commit 6810132 in a way that removes ~60 lines of
code.
The bug was introduced in commit e87ceb2 (mea culpa) and is at its core
a pointer aliasing bug where sometimes two independent pointers existed
that pointed to the same chunk of heap memory.
Signed-off-by: Trevor Norris <trev.norris@gmail.com>
Otherwise it's not possible to check from inside a destructor if V8 is
still alive with v8::V8::IsDead(). In V8 3.25, that function returns
true until the last isolate is destroyed.
This used to work in v0.10 and is a standard trick to dispose persistent
handles conditionally.
Signed-off-by: Fedor Indutny <fedor@indutny.com>
dispose() free's the memory when executed and sets the external array
data to NULL and length to zero.
To prevent the same memory from being free'd twice when the object is
garbage collected we first check if the object's external array data
length == 0. Since alloc() passes NULL to
SetIndexedPropertiesToExternalArrayData() if length == 0 there's no
opportunity for memory leak.
Fix up a bad assumption in pummel/test-net-pingpong, namely that binding
to 'localhost' or '' means that incoming connections will have an IPv4
address.
Signed-off-by: Timothy J Fontaine <tjfontaine@gmail.com>
EMFILE and ENFILE mean 'out of file descriptors'. It's a run-time error
and as such should emit an error on the child process object, not throw
an exception.
Fixes#7453.
Signed-off-by: Timothy J Fontaine <tjfontaine@gmail.com>
Avoid sending unsent data and destroying otherwise legitimate sockets
for requests that are aborted while still in the agent queue. This
reduces stress on upstream systems who will likely respond to the
request but client app already knows that it will be dropped on the
floor and also helps avoid killing keep-alive connections.
See also commit e7bfbaf. Don't depend on deps/v8/build/features.gypi
to disable handle zapping, be explicit about it.
Signed-off-by: Timothy J Fontaine <tjfontaine@gmail.com>
Slashes should be documented, because 3rd-party protocols -- those
postfixed with `://` -- would incorrectly `format` and `parse` if they
didn't set/get the `slashes` option.
Signed-off-by: Timothy J Fontaine <tjfontaine@gmail.com>
Not all querystring are utf-8 encoding, make querystring can be used
to encode / decode `non-utf8` encoding string if necessary.
Signed-off-by: Timothy J Fontaine <tjfontaine@gmail.com>
Do not ever call `Delete()` on `proxy_global_`, it will invoke
`GlobalPropertyDeleteCallback` and cause crash because of the infinite
recursion.
fix#7529
Adds a section to the transform stream docs to clarify the
difference between the `end` event and the `finish` events.
Also clarifies the wording on the `end` event.
64bit constants are keyed for x64 platforms only, add PowerPC based
platform constants.
Node's "ucs2" encoding wants LE character data stored in the Buffer, so
we need to reorder on BE platforms. See
http://nodejs.org/api/buffer.html regarding Node's "ucs2" encoding
specification
Signed-off-by: Timothy J Fontaine <tjfontaine@gmail.com>
Storing it in SSL_CTX is incorrect as it may go away and get destructed
earlier, also it'll yield invalid results in SelectSNIContextCallback.
Use `SSL_get_app_data()` instead.
fix#7484
Signed-off-by: Timothy J Fontaine <tjfontaine@gmail.com>
The spawnsync test was written wrong, the timeout can never fire before
the sync process has returned, the delta is immaterial and times when
it was succeeding are not reliable cases.
Instead verify that the timeout doesn't fire while the sync process is
happening.
When close() is called on a non-listening server, a synchronous
error is thrown. This commit causes the error to be passed to
the asynchronous callback function instead.
Signed-off-by: Fedor Indutny <fedor@indutny.com>
ClientHelloParser used to contain an 18k buffer that was kept around
for the life of the connection, even though it was not needed in many
situations. I changed it to be deallocated when it's determined to
be no longer needed.
Signed-off-by: Fedor Indutny <fedor@indutny.com>
Fix the following compiler warning on systems where _XOPEN_SOURCE is
defined by default:
../src/node_constants.cc:35:0: warning: "_XOPEN_SOURCE" redefined
#define _XOPEN_SOURCE 500
Move the (re)definition of _XOPEN_SOURCE to the top of the file while
we're here. Commit 00890e4 adds a `#define _XOPEN_SOURCE 500` in order
to make <fcntl.h> expose O_NONBLOCK but it does so after other system
headers have been included. If those headers include <fcntl.h>, then
the #include in node_constants.cc will be a no-op and O_NONBLOCK won't
be visible.
Signed-off-by: Fedor Indutny <fedor@indutny.com>
stringToFlags() has fall throughs in a case statement.
However, they are not consistently implemented. This commit adds
consistency.
Signed-off-by: Trevor Norris <trev.norris@gmail.com>
There was an underlying assumption in readline.emitKeypressEvents (and
by extension emitKey) that the given stream (usually process.stdin)
would emit 'data' once per keypress, which is not always the case.
This commit buffers the input stream and ensures a 'keypress' event is
triggered for every keypress (including escape codes).
Signed-off-by: Fedor Indutny <fedor@indutny.com>
This test is still in test/disabled because it requires a tty, however
when executed directly this test now passes.
Signed-off-by: Fedor Indutny <fedor@indutny.com>
Ensure TypeError is thrown, fix a bug where `env` option was
assuming the option was actually an object.
This case is especially bad because it then sets `env == null`
instead of using `process.env`.
Fix#7456
Signed-off-by: Fedor Indutny <fedor@indutny.com>
A recent change to v8's API now makes it impossible to memcpy to a
v8::ArrayBuffer without causing it to be externalized. This means that
the garbage collector will not automatically free the memory when the
object is collected.
When/If the necessary API is included to allow the above
Buffer#toArrayBuffer() will be reintroduced.
Signed-off-by: Timothy J Fontaine <tjfontaine@gmail.com>
Not removing 'end' listeners for input and output on the 'close' event
resulted in an EventEmitter related memory leak.
This issue also might be reproduced at:
https://github.com/npm/npm/issues/5203
Signed-off-by: Trevor Norris <trev.norris@gmail.com>