summaryrefslogtreecommitdiff
path: root/src/req_wrap.h
AgeCommit message (Collapse)Author
2019-11-30src: clean up node_file.hAnna Henningsen
- Move inline functions into an `-inl.h` file - Move override function definitions into `.cc` files - Remove `using` statements from header files - Make data fields of classes private - Mark classes at the end of hierarchies as `final` This is also partially being done in an attempt to avoid a particular internal compiler error, see https://github.com/nodejs/node/pull/30475#issuecomment-554740850 for details. PR-URL: https://github.com/nodejs/node/pull/30530 Reviewed-By: Jiawen Geng <technicalcute@gmail.com> Reviewed-By: David Carlier <devnexen@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
2019-10-31src: change env.h includes for forward declarationsAlexandre Ferrando
Due to how the Environment class is used through the codebase, there are a lot of includes referencing either env.h or env-inl.h. This can cause that when any development touches those libraries, a lot of files have to be recompiled. This commit attempts to change those includes by forward declarations when possible to mitigate the issue. Refs: https://github.com/nodejs/node/issues/27531 PR-URL: https://github.com/nodejs/node/pull/30133 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: David Carlier <devnexen@gmail.com> Reviewed-By: Franziska Hinkelmann <franziska.hinkelmann@gmail.com>
2019-04-24src: apply clang-tidy rule modernize-use-equals-defaultgengjiawen
PR-URL: https://github.com/nodejs/node/pull/27264 Reviewed-By: Refael Ackermann <refack@gmail.com>
2019-02-20src: move req_wrap_queue to base class of ReqWrapAnna Henningsen
Introduce a second base class for `ReqWrap` that does not depend on a template parameter and move the `req_wrap_queue_` field to it. This addresses undefined behaviour that occurs when casting to `ReqWrap<uv_req_t>` in the `ReqWrap` constructor. Refs: https://github.com/nodejs/node/issues/26131 PR-URL: https://github.com/nodejs/node/pull/26148 Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
2018-05-10src: keep track of open requestsAnna Henningsen
Workers cannot shut down while requests are open, so keep a counter that is increased whenever libuv requests are made and decreased whenever their callback is called. This also applies to other embedders, who may want to shut down an `Environment` instance early. Many thanks for Stephen Belanger for reviewing the original version of this commit in the Ayo.js project. Fixes: https://github.com/nodejs/node/issues/20517 Refs: https://github.com/ayojs/ayo/pull/85 PR-URL: https://github.com/nodejs/node/pull/19377 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: James M Snell <jasnell@gmail.com>
2018-05-10src: unify ReqWrap libuv callingAnna Henningsen
This allows easier tracking of whether there are active `ReqWrap`s. Many thanks for Stephen Belanger for reviewing the original version of this commit in the Ayo.js project. Refs: https://github.com/ayojs/ayo/pull/85 PR-URL: https://github.com/nodejs/node/pull/19377 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: James M Snell <jasnell@gmail.com>
2018-05-10src: make CleanupHandles() tear down handles/reqsAnna Henningsen
Previously, handles would not be closed when the current `Environment` stopped, which is acceptable in a single-`Environment`-per-process situation, but would otherwise create memory and file descriptor leaks. Also, introduce a generic way to close handles via the `Environment::CloseHandle()` function, which automatically keeps track of whether a close callback has been called yet or not. Many thanks for Stephen Belanger for reviewing the original version of this commit in the Ayo.js project. Refs: https://github.com/ayojs/ayo/pull/85 PR-URL: https://github.com/nodejs/node/pull/19377 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: James M Snell <jasnell@gmail.com>
2018-02-14src: refactor WriteWrap and ShutdownWrapsAnna Henningsen
Encapsulate stream requests more: - `WriteWrap` and `ShutdownWrap` classes are now tailored to the streams on which they are used. In particular, for most streams these are now plain `AsyncWrap`s and do not carry the overhead of unused libuv request data. - Provide generic `Write()` and `Shutdown()` methods that wrap around the actual implementations, and make *usage* of streams easier, rather than implementing; for example, wrap objects don’t need to be provided by callers anymore. - Use `EmitAfterWrite()` and `EmitAfterShutdown()` handlers to call the corresponding JS handlers, rather than always trying to call them. This makes usage of streams by other C++ code easier and leaner. Also fix up some tests that were previously not actually testing asynchronicity when the comments indicated that they would. PR-URL: https://github.com/nodejs/node/pull/18676 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Anatoli Papirovski <apapirovski@mac.com> Reviewed-By: James M Snell <jasnell@gmail.com>
2018-02-14src: do not redefine private for GenDebugSymbolsJoyee Cheung
Redefining private breaks any private inheritance in the included files. We can simply declare GenDebugSymbols() as friends in related classes to gain the access that we need. PR-URL: https://github.com/nodejs/node/pull/18653 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
2018-01-26src, test: node internals' postmortem metadataMatheus Marchini
Before these changes, only V8 added postmortem metadata to Node's binary, limiting the possibilities for debugger's developers to add some features that rely on investigating Node's internal structures. These changes are first steps towards empowering debug tools to navigate Node's internal structures. One example of what can be achieved with this is shown at nodejs/llnode#122 (a command which prints information about handles and requests on the queue for a core dump file). Node postmortem metadata are prefixed with nodedbg_. This also adds tests to validate if all postmortem metadata are calculated correctly, plus some documentation on what is postmortem metadata and a few care to be taken to avoid breaking it. Ref: https://github.com/nodejs/llnode/pull/122 Ref: https://github.com/nodejs/post-mortem/issues/46 PR-URL: https://github.com/nodejs/node/pull/14901 Refs: https://github.com/nodejs/post-mortem/issues/46 Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
2017-11-17src: rename req-wrap -> req_wrapDaniel Bevenius
This commit renames req-wrap to req_wrap consitency with other c++ source files. PR-URL: https://github.com/nodejs/node/pull/17022 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Anatoli Papirovski <apapirovski@mac.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.
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: mark more destructors with override keywordBen Noordhuis
The previous commits fixed oversights in destructors that should have been marked virtual but weren't. This commit marks destructors from derived classes with the override keyword.
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-08deps: re-implement debugger-agentFedor Indutny
Reviewed-By: Trevor Norris <trevnorris@gmail.com> PR-URL: https://github.com/joyent/node/pull/8476
2014-03-13src: update to v8 3.24 APIsFedor Indutny
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-09src: revert domain using AsyncListenersTrevor Norris
This is a slightly modified revert of bc39bdd. Getting domains to use AsyncListeners became too much of a challenge with many edge cases. While this is still a goal, it will have to be deferred for now until more test coverage can be provided.
2013-10-31domain: use AsyncListener APITrevor Norris
The domain module has been switched over to use the domain module API as much as currently possible. There are still some hooks in the EventEmitter, but hopefully we can remove those in the future.
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-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-13src: move ReqWrap::data_ to FSReqWrapBen Noordhuis
FSReqWrap is the only ReqWrap child class that uses the data_ field so move it out of ReqWrap and into FSReqWrap.
2013-08-09domain: share object and state with native landTrevor Norris
Change process.domain to use a getter/setter and access that property via an array index. These are much faster to get from c++, and it can be passed to _setupDomainUse and stored as a Persistent<Array>. InDomain() and GetDomain() as trivial ways to access the domain information in the native layer. Important because we'll be able to quickly access if a domain is active. Instead of just whether the domain module has been loaded.
2013-08-06domains: properly check if domains are being usedTrevor Norris
process.domain is almost never just undefined, so it was setting the object property unnecessarily.
2013-08-03src: use PersistentToLocal() in a few more placesBen Noordhuis
Update a few more `Local<T>::New(isolate, persistent)` call sites to `PersistentToLocal(isolate, persistent)` - the latter has a fast path for non-weak persistent references.
2013-07-31src: lint c++ codeFedor Indutny
2013-07-19src: ReqWrap now optionally accepts a wrap objectBen Noordhuis
2013-07-11build: fix windows buildBen Noordhuis
Be very careful with forward declarations, MSVC is quite picky and rather stupid about it. Fixes #5810.
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-04src: replace ngx-queue.h with queue.hBen Noordhuis
No functional changes, just one less entry in the LICENSE file.
2013-04-10req_wrap: only grab domain object if in useTrevor Norris
2013-04-10src: add node_isolate to remaining scopesTrevor Norris
2013-03-20bindings: update apiTrevor Norris
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.
2012-05-15process: add _getActiveHandles(), _getActiveRequests()Ben Noordhuis
* process._getActiveHandles() returns a list containing all active handles (timers, sockets, etc.) that have not been unref'd. * process._getActiveRequests() returns a list of active requests (in-flight actions like connecting to a remote host, writing data to a socket, etc.).
2012-05-15req_wrap: share process_symbol, domain_symbolBen Noordhuis
Share persistent strings process_symbol and domain_symbol across compilation units. Avoids redefinition errors when src/node.cc includes src/req_wrap.h.
2012-04-17Domain hooks in ReqWrap<T> and MakeCallbackisaacs
2011-11-02Add missing copyright headersRyan Dahl
2011-09-04Return ReqWrap from internal fs functionsRyan Dahl
2011-07-18Abstract StreamWrap from TCPWrapRyan Dahl