summaryrefslogtreecommitdiff
path: root/src/pipe_wrap.cc
AgeCommit message (Collapse)Author
2016-03-03src: fix NewInstance deprecation warningsMichaël Zasso
PR-URL: https://github.com/nodejs/node/pull/4722 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Ali Ijaz Sheikh <ofrobots@google.com>
2015-10-01async_wrap: update providers and add testTrevor Norris
Several provider ids have been removed that are no longer in use. Others have been updated to match their class constructors. Add test to ensure all internally listed providers are used. PR-URL: https://github.com/nodejs/node/pull/3139 Reviewed-By: Fedor Indutny <fedor.indutny@gmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-by: Stephen Belanger <admin@stephenbelanger.com>
2015-09-06src: replace usage of v8::Handle with v8::LocalMichaël Zasso
v8::Handle is deprecated: https://codereview.chromium.org/1224623004 PR-URL: https://github.com/nodejs/io.js/pull/2202 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2015-08-28Revert "lib,src: add unix socket getsockname/getpeername"Ben Noordhuis
This reverts commit 6cd0e2664b1ce944e5e461457d160be83f70d379. This reverts commit 7a999a13766ac68049812fedbdfd15a0250f0f07. This reverts commit f337595441641ad36f6ab8ae770e56c1673ef692. It turns out that on Windows, uv_pipe_getsockname() is a no-op for client sockets. It slipped through testing because of a CI snafu. PR-URL: https://github.com/nodejs/node/pull/2584 Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
2015-08-27lib,src: add unix socket getsockname/getpeernameBen Noordhuis
The implementation is a minor API change in that socket.address() now returns a `{ address: '/path/to/socket' }` object, like it does for TCP and UDP sockets. Before this commit, it returned `socket._pipeName`, which is a string when present. Change common.PIPE on Windows from '\\\\.\\pipe\\libuv-test' to '\\\\?\\pipe\\libuv-test'. Windows converts the '.' to a '?' when creating a named pipe, meaning that common.PIPE didn't match the result from NtQueryInformationFile(). Fixes: https://github.com/nodejs/node/issues/954 PR-URL: https://github.com/nodejs/node/pull/956 Reviewed-By: Sam Roberts <vieuxtech@gmail.com> Reviewed-By: Trevor Norris <trev.norris@gmail.com>
2015-06-17async-wrap: add provider id and object info cbTrevor Norris
Re-add the wrapper class id to AsyncWrap instances so they can be tracked directly in a heapdump. Previously the class id was given without setting the heap dump wrapper class info provider. Causing a segfault when a heapdump was taken. This has been added, and the label_ set to the given provider name so each instance can be identified. The id will not be set of the passed object has no internal field count. As the class pointer cannot be retrieved from the object. In order to properly report the allocated size of each class, the new pure virtual method self_size() has been introduces. PR-URL: https://github.com/nodejs/io.js/pull/1896 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2015-02-22stream_base: introduce StreamBaseFedor Indutny
StreamBase is an improved way to write C++ streams. The class itself is for separting `StreamWrap` (with the methods like `.writeAsciiString`, `.writeBuffer`, `.writev`, etc) from the `HandleWrap` class, making possible to write abstract C++ streams that are not bound to any uv socket. The following methods are important part of the abstraction (which mimics libuv's stream API): * Events: * `OnAlloc(size_t size, uv_buf_t*)` * `OnRead(ssize_t nread, const uv_buf_t*, uv_handle_type pending)` * `OnAfterWrite(WriteWrap*)` * Wrappers: * `DoShutdown(ShutdownWrap*)` * `DoTryWrite(uv_buf_t** bufs, size_t* count)` * `DoWrite(WriteWrap*, uv_buf_t*, size_t count, uv_stream_t* handle)` * `Error()` * `ClearError()` The implementation should provide all of these methods, thus providing the access to the underlying resource (be it uv handle, TLS socket, or anything else). A C++ stream may consume the input of another stream by replacing the event callbacks and proxying the writes. This kind of API is actually used now for the TLSWrap implementation, making it possible to wrap TLS stream into another TLS stream. Thus legacy API calls are no longer required in `_tls_wrap.js`. PR-URL: https://github.com/iojs/io.js/pull/840 Reviewed-By: Trevor Norris <trev.norris@gmail.com> Reviewed-By: Chris Dickinson <christopher.s.dickinson@gmail.com>
2015-02-11src: switch from QUEUE to intrusive listBen Noordhuis
This commit also breaks up req_wrap.h into req-wrap.h and req-wrap-inl.h to work around a circular dependency issue in env.h. PR-URL: https://github.com/iojs/io.js/pull/667 Reviewed-By: Fedor Indutny <fedor.indutny@gmail.com> Reviewed-By: Trevor Norris <trev.norris@gmail.com>
2015-01-12Remove excessive copyright/license boilerplateisaacs
The copyright and license notice is already in the LICENSE file. There is no justifiable reason to also require that it be included in every file, since the individual files are not individually distributed except as part of the entire package.
2015-01-07src: pass Isolate to node::Utf8Value constructorTrevor Norris
Initial attempt to remove all uses of Isolate::GetCurrent(). Still exists a few locations, but this works out a heavy usage. PR-URL: https://github.com/iojs/io.js/pull/244 Reviewed-by: Ben Noordhuis <info@bnoordhuis.nl>
2014-12-09async-wrap: explicitly pass parentTrevor Norris
When instantiating a new AsyncWrap allow the parent AsyncWrap to be passed. This is useful for cases like TCP incoming connections, so the connection can be tied to the server receiving the connection. Because the current architecture instantiates the *Wrap inside a v8::FunctionCallback, the parent pointer is currently wrapped inside a new v8::External every time and passed as an argument. This adds ~80ns to instantiation time. A future optimization would be to add the v8::External as the data field when creating the v8::FunctionTemplate, change the pointer just before making the call then NULL'ing it out afterwards. This adds enough code complexity that it will not be attempted until the current approach demonstrates it is a bottle neck. PR-URL: https://github.com/joyent/node/pull/8110 Signed-off-by: Trevor Norris <trev.norris@gmail.com> Reviewed-by: Fedor Indutny <fedor@indutny.com> Reviewed-by: Alexis Campailla <alexis@janeasystems.com> Reviewed-by: Julien Gilli <julien.gilli@joyent.com>
2014-12-09src: remove unnecessary template parameterTrevor Norris
The template class information is received via the type of the first argument. So there is no need to use Wrap<T>(handle). PR-URL: https://github.com/joyent/node/pull/8110 Signed-off-by: Trevor Norris <trev.norris@gmail.com> Reviewed-by: Fedor Indutny <fedor@indutny.com> Reviewed-by: Alexis Campailla <alexis@janeasystems.com> Reviewed-by: Julien Gilli <julien.gilli@joyent.com>
2014-12-09src: all wraps now use actual FunctionTemplateTrevor Norris
Instead of simply creating a new v8::Object to contain the connection information, instantiate a new instance of a FunctionTemplate. This will allow future improvements for debugging and performance probes. Additionally, the "provider" argument in the ReqWrap constructor is no longer optional. PR-URL: https://github.com/joyent/node/pull/8110 Signed-off-by: Trevor Norris <trev.norris@gmail.com> Reviewed-by: Fedor Indutny <fedor@indutny.com> Reviewed-by: Alexis Campailla <alexis@janeasystems.com> Reviewed-by: Julien Gilli <julien.gilli@joyent.com>
2014-10-23src: replace NULL with nullptrBen Noordhuis
Now that we are building with C++11 features enabled, replace use of NULL with nullptr. The benefit of using nullptr is that it can never be confused for an integral type because it does not support implicit conversions to integral types except boolean - unlike NULL, which is defined as a literal `0`.
2014-10-13src: attach env directly to api functionsBen Noordhuis
Attach the per-context execution environment directly to API functions. Rationale: * Gets node one step closer to multi-isolate readiness. * Avoids multi-context confusion, e.g. when the caller and callee live in different contexts. * Avoids expensive calls to pthread_getspecific() on platforms where V8 does not know how to use the thread-local storage directly. (Linux, the BSDs.) PR-URL: https://github.com/node-forward/node/pull/18 Reviewed-By: Fedor Indutny <fedor@indutny.com>
2014-10-12src: replace assert() with CHECK()Ben Noordhuis
Mechanically replace assert() statements with UNREACHABLE(), CHECK(), or CHECK_{EQ,NE,LT,GT,LE,GE}() statements. The exceptions are src/node.h and src/node_object_wrap.h because they are public headers. PR-URL: https://github.com/node-forward/node/pull/16 Reviewed-By: Fedor Indutny <fedor@indutny.com>
2014-10-12src: remove unnecessary HandleScopesBen Noordhuis
API callback functions don't need to create a v8::HandleScope instance because V8 already creates one in the JS->C++ adapter frame. PR-URL: https://github.com/node-forward/node/pull/16 Reviewed-By: Fedor Indutny <fedor@indutny.com>
2014-09-03stream_wrap: Add support to write binary stringsTrevor Norris
node::StringBytes::Write() has appropriate support to write strings with 'binary' encoding. So expose that API through StreamWrap and allow inheriting classes to use it. Signed-off-by: Trevor Norris <trev.norris@gmail.com>
2014-06-10Merge remote-tracking branch 'upstream/v0.10'Timothy J Fontaine
Conflicts: AUTHORS ChangeLog deps/v8/src/api.cc deps/v8/src/unicode-inl.h deps/v8/src/unicode.h lib/_stream_readable.js lib/http.js src/cares_wrap.cc src/node.cc src/node_crypto.cc src/node_dtrace.cc src/node_file.cc src/node_stat_watcher.cc src/node_version.h src/process_wrap.cc src/string_bytes.cc src/string_bytes.h src/udp_wrap.cc src/util.h test/simple/test-buffer.js test/simple/test-stream2-compatibility.js
2014-04-02node: add signature to SET_PROTOTYPE_METHODC. Scott Ananian
This prevents segfaults when a native method is reassigned to a different object (which corrupts args.This()). When unwrapping, clients should use args.Holder() instead of args.This(). Closes #6690. Signed-off-by: Trevor Norris <trev.norris@gmail.com>
2014-03-17pipe_wrap: use Instantiate() methodTrevor Norris
Retrieve a new client object via PipeWrap::Instantiate(). This method performs appropriate checks to make sure everything is as it should be.
2014-03-13src: update to v8 3.24 APIsFedor Indutny
2014-02-26src: make stdout/sterr pipes blockingAlexis Campailla
Expose `setBlocking` on Pipe's and if a pipe is being created for stdio on windows then make the pipes blocking. This fixes test-stream2-stderr-sync.js on Windows. Fixes #3584
2014-02-22src: remove `node_isolate` from sourceFedor Indutny
fix #6899
2014-02-05async_wrap: add provider types/pass to constructorTrevor Norris
These will be used to allow users to filter for which types of calls they wish their callbacks to run. Signed-off-by: Timothy J Fontaine <tjfontaine@gmail.com>
2014-01-27node: register modules from DSO constructorsKeith M Wesolowski
Built-in modules should be automatically registered, replacing the static module list. Add-on modules should also be automatically registered via DSO constructors. This improves flexibility in adding built-in modules and is also a prerequisite to pure-C addon modules.
2014-01-21async_wrap/timers: remove Add/RemoveAsyncListenerTrevor Norris
The ability to add/remove an AsyncListener to an object after its creation was an artifact of trying to get AL working with the domain module. Now that is no longer necessary and other features are going to be implemented that would be affected by this functionality. So the code will be removed for now to simplify the implementation process. In the future this code will likely be reintroduced, but after some other more important matters have been addressed. None of this functionality was documented, as is was meant specifically for domain specific implementation work arounds. Signed-off-by: Timothy J Fontaine <tjfontaine@gmail.com>
2013-11-12src: fix Context::Scope usageBen Noordhuis
env->context() may or may not create a new Local. It currently does not but don't depend on that behavior, create a HandleScope first.
2013-11-11src: fix Environment::GetCurrent() usageBen Noordhuis
Create a HandleScope before calling the Environment::GetCurrent() that takes a v8::Isolate* as an argument because it creates a handle with the call to v8::Isolate::CurrentContext().
2013-10-31async-wrap: add methods to udp/tcp/pipe/timersTrevor Norris
Now it's possible to add/remove an async listener to an individual handle created by UDP, TCP, Pipe or Timer.
2013-10-31node: add AsyncListener supportTrevor Norris
AsyncListener is a JS API that works in tandem with the AsyncWrap class to allow the user to be alerted to key events in the life cycle of an asynchronous event. The AsyncWrap class has its own MakeCallback implementation that core will be migrated to use, and uses state sharing techniques to allow quicker communication between JS and C++ whether the async event callbacks need to be called.
2013-10-29src: shorten Object{Wrap,Unwrap}Trevor Norris
Going back to the original names of Wrap/Unwrap now that most all the class members that duplicate the name and functionality have been removed.
2013-10-29src: don't use class specific Unwrap methodsTrevor Norris
Instead use the template functions in util.h.
2013-10-29src: use function to get internal pointerTrevor Norris
Remove the NODE_{WRAP,UNWRAP} macros and instead use template functions.
2013-10-25Merge remote-tracking branch 'upstream/v0.10'Timothy J Fontaine
Conflicts: ChangeLog deps/uv/ChangeLog deps/uv/include/uv-darwin.h deps/uv/src/unix/fsevents.c deps/uv/src/unix/process.c deps/uv/src/version.c doc/api/addons.markdown doc/api/cluster.markdown doc/api/http.markdown lib/http.js lib/tls.js src/node_crypto.cc src/node_http_parser.cc src/node_version.h src/pipe_wrap.cc src/v8abbr.h src/v8ustack.d test/simple/test-http-pipeline-flood.js
2013-09-28src: turn uv_pipe_open() failures into exceptionsBen Noordhuis
uv_pipe_open() is unlikely to fail but when it does, the failure should not be quietly ignored. Raise the error as an exception. See joyent/libuv#941.
2013-09-06src: add multi-context supportBen Noordhuis
This commit makes it possible to use multiple V8 execution contexts within a single event loop. Put another way, handle and request wrap objects now "remember" the context they belong to and switch back to that context when the time comes to call into JS land. This could have been done in a quick and hacky way by calling v8::Object::GetCreationContext() on the wrap object right before making a callback but that leaves a fairly wide margin for bugs. Instead, we make the context explicit through a new Environment class that encapsulates everything (or almost everything) that belongs to the context. Variables that used to be a static or a global are now members of the aforementioned class. An additional benefit is that this approach should make it relatively straightforward to add full isolate support in due course. There is no JavaScript API yet but that will be added in the near future. This work was graciously sponsored by GitHub, Inc.
2013-08-28pipe_wrap: squelch integer type conversion warningBert Belder
2013-08-12src: fix build break from generic macro nameTrevor Norris
WRAP is too generic a macro name and causes the build to fail from conflicts. They have been prepended with NODE_.
2013-08-12src: centralize class wrap/unwrapTrevor Norris
While almost all cases were handled by simple WRAP/UNWRAP macros, this extends those to cover all known occurrences.
2013-08-09src: use v8::String::NewFrom*() functionsBen Noordhuis
* Change calls to String::New() and String::NewSymbol() to their respective one-byte, two-byte and UTF-8 counterparts. * Add a FIXED_ONE_BYTE_STRING macro that takes a string literal and turns it into a v8::Local<v8::String>. * Add helper functions that make v8::String::NewFromOneByte() easier to work with. Said function expects a `const uint8_t*` but almost every call site deals with `const char*` or `const unsigned char*`. Helps us avoid doing reinterpret_casts all over the place. * Code that handles file system paths keeps using UTF-8 for backwards compatibility reasons. At least now the use of UTF-8 is explicit. * Remove v8::String::NewSymbol() entirely. Almost all call sites were effectively minor de-optimizations. If you create a string only once, there is no point in making it a symbol. If you are create the same string repeatedly, it should probably be cached in a persistent handle.
2013-08-03src: use static_cast for void-to-T castsBen Noordhuis
Code cleanup, replace a few uses of reinterpret_cast<T*>(void_ptr) with static_cast<T*>(void_ptr).
2013-07-31src: more lint after cpplint tighteningBen Noordhuis
Commit 847c6d9 adds a 'project headers before system headers' check to cpplint. Update the files in src/ to make the linter pass again.
2013-07-31src: lint c++ codeFedor Indutny
2013-07-20src, lib: update after internal api changeBen Noordhuis
Libuv now returns errors directly. Make everything in src/ and lib/ follow suit. The changes to lib/ are not strictly necessary but they remove the need for the abominations that are process._errno and node::SetErrno().
2013-07-07src: remove unnecessary calls to Local<T>::New()Ben Noordhuis
2013-07-06lib, src: upgrade after v8 api changeBen Noordhuis
This is a big commit that touches just about every file in the src/ directory. The V8 API has changed in significant ways. The most important changes are: * Binding functions take a const v8::FunctionCallbackInfo<T>& argument rather than a const v8::Arguments& argument. * Binding functions return void rather than v8::Handle<v8::Value>. The return value is returned with the args.GetReturnValue().Set() family of functions. * v8::Persistent<T> no longer derives from v8::Handle<T> and no longer allows you to directly dereference the object that the persistent handle points to. This means that the common pattern of caching oft-used JS values in a persistent handle no longer quite works, you first need to reconstruct a v8::Local<T> from the persistent handle with the Local<T>::New(isolate, persistent) factory method. A handful of (internal) convenience classes and functions have been added to make dealing with the new API a little easier. The most visible one is node::Cached<T>, which wraps a v8::Persistent<T> with some template sugar. It can hold arbitrary types but so far it's exclusively used for v8::Strings (which was by far the most commonly cached handle type.)
2013-06-17src: clean up `using` directivesBen Noordhuis
Remove the unused ones and alphabetically sort the ones that remain.
2013-06-15process: abstract out HandleToStreamFedor Indutny
Originally contributed by @tjfontaine, but modified to be faster and more generic.
2013-05-30src: simplify HandleWrap initializationBen Noordhuis