summaryrefslogtreecommitdiff
path: root/src/stream_wrap.h
Commit message (Collapse)AuthorAgeFilesLines
* src: add include guards to internal headersBen Noordhuis2016-05-251-0/+3
| | | | | | | | | | | For consistency with the newly added src/base64.h header, check that NODE_WANT_INTERNALS is defined and set in internal headers. PR-URL: https://github.com/nodejs/node/pull/6948 Refs: https://github.com/nodejs/node/pull/6910 Reviewed-By: Fedor Indutny <fedor.indutny@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Trevor Norris <trev.norris@gmail.com>
* src: replace usage of v8::Handle with v8::LocalMichaƫl Zasso2015-09-061-4/+4
| | | | | | | 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>
* stream_base: `.writev()` has limited supportFedor Indutny2015-02-281-1/+2
| | | | | | | | | | Only TCP and JSStream do support `.writev()` on all platforms at the moment. Ensure that it won't be enabled everywhere. Fix: https://github.com/iojs/io.js/issues/995 PR-URL: https://github.com/iojs/io.js/pull/1008 Reviewed-by: Bert Belder <bertbelder@gmail.com> Reviewed-By: Rod Vagg <rod@vagg.org>
* streams: introduce StreamWrap and JSStreamFedor Indutny2015-02-241-6/+4
| | | | | | | | | | Introduce a way to wrap plain-js `stream.Duplex` streams into C++ StreamBase's child class. With such method at hand it is now possible to pass `stream.Duplex` instance as a `socket` parameter to `tls.connect()`. PR-URL: https://github.com/iojs/io.js/pull/926 Reviewed-By: Chris Dickinson <christopher.s.dickinson@gmail.com>
* stream_base: introduce StreamBaseFedor Indutny2015-02-221-131/+35
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* src: switch from QUEUE to intrusive listBen Noordhuis2015-02-111-1/+2
| | | | | | | | | 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>
* Remove excessive copyright/license boilerplateisaacs2015-01-121-21/+0
| | | | | | | 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.
* async-wrap: explicitly pass parentTrevor Norris2014-12-091-1/+2
| | | | | | | | | | | | | | | | | | | | | | | 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>
* src: remove unnecessary template parameterTrevor Norris2014-12-091-2/+2
| | | | | | | | | | | 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>
* src: all wraps now use actual FunctionTemplateTrevor Norris2014-12-091-2/+21
| | | | | | | | | | | | | | | 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>
* src: remove static variables from tls_wrapBen Noordhuis2014-11-181-1/+2
| | | | | | | | Remove the error message globals. More prep work for multi-isolate support. Reviewed-By: Fedor Indutny <fedor@indutny.com> PR-URL: https://github.com/node-forward/node/pull/58
* src: mark empty destructors as defaultBen Noordhuis2014-10-231-2/+1
| | | | | Mark empty destructors as having a default no-op implementation. Remove a few unused constructors and destructors while we are here.
* src: replace NULL with nullptrBen Noordhuis2014-10-231-1/+1
| | | | | | | | | | 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`.
* src: replace assert() with CHECK()Ben Noordhuis2014-10-121-3/+3
| | | | | | | | | | | 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>
* tls_wrap: fix use after freeFedor Indutny2014-09-031-3/+5
| | | | | Do not free TLSCallbacks from StreamWrap. TLSCallbacks is bound to a V8 object and should be collected by V8's GC.
* stream_wrap: Add support to write binary stringsTrevor Norris2014-09-031-0/+2
| | | | | | | | 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>
* src: update from uv_read2_start removalTimothy J Fontaine2014-03-101-4/+0
| | | | | | Previously if you wanted to be notified of pending handles for pipes you needed to use uv_read2_start, however in v0.11.22 you can query for pending handles independently.
* src: make stdout/sterr pipes blockingAlexis Campailla2014-02-261-0/+2
| | | | | | | | | 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
* async_wrap: add provider types/pass to constructorTrevor Norris2014-02-051-1/+4
| | | | | | | 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>
* stream_wrap: use `uv_try_write` where possibleFedor Indutny2014-01-291-0/+3
| | | | | Use `uv_try_write` for string and buffer writes, thus avoiding to do allocations and copying in some of the cases.
* tls_wrap: propagate errors to write callbacksFedor Indutny2014-01-241-0/+1
| | | | fix #6903
* async-wrap: integrate with WeakObjectTrevor Norris2013-10-311-2/+0
| | | | | Making WeakObject inherit from AsyncWrap allows us to peak into almost all the MakeCallback calls in Node internals.
* cpplint: disallow comma-first in C++Fedor Indutny2013-10-171-2/+2
|
* src: add multi-context supportBen Noordhuis2013-09-061-7/+7
| | | | | | | | | | | | | | | | | | | | | | | 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.
* uv: upgrade to v0.11.12Ben Noordhuis2013-09-031-8/+18
| | | | | * upgrade deps/uv/ to v0.11.12. * update files in src/ after a libuv API change.
* stream_wrap: add handle type checkersBen Noordhuis2013-08-071-0/+13
| | | | | | Add is_named_pipe(), is_named_pipe_ipc() and is_tcp() and update the code base to use those rather than `stream->type == UV_FOO` and `reinterpret_cast<uv_pipe_t*>(handle)->ipc` style checks.
* stream_wrap: use getters, not direct field accessBen Noordhuis2013-08-071-17/+28
| | | | | | | | Hide member fields behind getters. Make the fields themselves const in the sense that the pointer is non-assignable - the pointed to object remains mutable. Makes reasoning about lifecycle and mutability a little easier.
* src: lint c++ codeFedor Indutny2013-07-311-5/+5
|
* src, lib: update after internal api changeBen Noordhuis2013-07-201-1/+2
| | | | | | | | 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().
* lib, src: upgrade after v8 api changeBen Noordhuis2013-07-061-11/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.)
* slab_allocator: remove SlabAllocatorTrevor Norris2013-07-031-3/+0
| | | | | | | | | Now that Buffer instantiation has improved, the SlabAllocator is an unnecessary layer of complexity preventing further performance optimizations. Currently there is a small performance loss with very small stream requests, but this will soon be addressed.
* stream_wrap: introduce StreamWrapCallbacksFedor Indutny2013-06-151-1/+78
| | | | | StreamWrapCallbacks is a helper class for incepting into uv_stream_t* management process.
* src: simplify HandleWrap initializationBen Noordhuis2013-05-301-1/+0
|
* Merge remote-tracking branch 'ry/v0.10' into masterisaacs2013-05-171-17/+2
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
| * src: Use StringBytes in StreamWrapisaacs2013-05-141-9/+2
| |
* | stream_wrap: remove unused arg from WriteBufferTrevor Norris2013-05-071-3/+1
| | | | | | | | | | WriteBuffer was changed in the cork/uncork implementation (60ed2c54). The unused argument has been removed.
* | net: implement ._writev for .cork/uncork() supportFedor Indutny2013-04-271-3/+20
|/ | | | | Add Writev method to StreamWrap class for writing mixed array of strings and buffers. Expose this method for TCP class.
* stream_wrap, udp_wrap: add read-only fd propertyBen Noordhuis2013-02-131-0/+3
| | | | | | | | Expose the file descriptor as a read-only property on the internal handle objects. Intended for debugging purposes, not part of the API proper. The property is always null on Windows. Fixes #4754.
* deps: upgrade libuv to a478847Ben Noordhuis2012-05-221-1/+0
| | | | | The event loop's reference counting scheme in this version of libuv has changed. Update the libuv bindings to reflect that fact.
* stream_wrap: fix compilation errorsBen Noordhuis2012-05-091-0/+8
|
* Optimize writing strings with Socket.writeBert Belder2012-05-091-1/+8
|
* core: use proper #include directivesBen Noordhuis2012-03-101-3/+3
|
* Add missing copyright headersRyan Dahl2011-11-021-0/+21
|
* uv_write2 uv_read2_start bindingRyan Dahl2011-10-061-1/+6
|
* stream_wrap: update after libuv API changeBen Noordhuis2011-08-241-1/+1
|
* stdio binding + javascript to enable process.stdin.listen()Igor Zinkovsky2011-07-271-0/+3
|
* net_uv: properly initialize writeQueueSizeRyan Dahl2011-07-191-1/+1
| | | | Fixes simple/test-tcp-wrap-listen.js
* Abstract out HandleWrap classRyan Dahl2011-07-181-6/+7
|
* Abstract StreamWrap from TCPWrapRyan Dahl2011-07-181-0/+42