Browse Source
async_wrap: use more specific providers
Instead of wrapping several providers into PROVIDER_CRYPTO, have them
all be named after their class. Rename other providers to also match
their class names. With the exception of Parser. Which is actually
HTTPParser.
Add PROVIDER_LENGTH to make better checks in WrapperInfo().
PR-URL: https://github.com/nodejs/node/pull/12892
Ref: https://github.com/nodejs/node/pull/11883
Ref: https://github.com/nodejs/node/pull/8531
Reviewed-By: Andreas Madsen <amwebdk@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Sam Roberts <vieuxtech@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
v6
Trevor Norris
8 years ago
committed by
Anna Henningsen
No known key found for this signature in database
GPG Key ID: D8B9F5AEAE84E4CF
4 changed files with
13 additions and
8 deletions
src/async-wrap.cc
src/async-wrap.h
src/node_crypto.cc
src/node_crypto.h
@ -109,7 +109,9 @@ intptr_t RetainedAsyncInfo::GetSizeInBytes() {
RetainedObjectInfo * WrapperInfo ( uint16_t class_id , Local < Value > wrapper ) {
RetainedObjectInfo * WrapperInfo ( uint16_t class_id , Local < Value > wrapper ) {
// No class_id should be the provider type of NONE.
// No class_id should be the provider type of NONE.
CHECK_NE ( NODE_ASYNC_ID_OFFSET , class_id ) ;
CHECK_GT ( class_id , NODE_ASYNC_ID_OFFSET ) ;
// And make sure the class_id doesn't extend past the last provider.
CHECK_LE ( class_id - NODE_ASYNC_ID_OFFSET , AsyncWrap : : PROVIDERS_LENGTH ) ;
CHECK ( wrapper - > IsObject ( ) ) ;
CHECK ( wrapper - > IsObject ( ) ) ;
CHECK ( ! wrapper . IsEmpty ( ) ) ;
CHECK ( ! wrapper . IsEmpty ( ) ) ;
@ -36,27 +36,29 @@ namespace node {
# define NODE_ASYNC_PROVIDER_TYPES(V) \
# define NODE_ASYNC_PROVIDER_TYPES(V) \
V ( NONE ) \
V ( NONE ) \
V ( CRYPTO ) \
V ( CONNECTION ) \
V ( FSEVENTWRAP ) \
V ( FSEVENTWRAP ) \
V ( FSREQWRAP ) \
V ( FSREQWRAP ) \
V ( GETADDRINFOREQWRAP ) \
V ( GETADDRINFOREQWRAP ) \
V ( GETNAMEINFOREQWRAP ) \
V ( GETNAMEINFOREQWRAP ) \
V ( HTTPPARSER ) \
V ( HTTPPARSER ) \
V ( JSSTREAM ) \
V ( JSSTREAM ) \
V ( PIPEWRAP ) \
V ( PBKDF2REQUEST ) \
V ( PIPECONNECTWRAP ) \
V ( PIPECONNECTWRAP ) \
V ( PIPEWRAP ) \
V ( PROCESSWRAP ) \
V ( PROCESSWRAP ) \
V ( QUERYWRAP ) \
V ( QUERYWRAP ) \
V ( RANDOMBYTESREQUEST ) \
V ( SHUTDOWNWRAP ) \
V ( SHUTDOWNWRAP ) \
V ( SIGNALWRAP ) \
V ( SIGNALWRAP ) \
V ( STATWATCHER ) \
V ( STATWATCHER ) \
V ( TCPWRAP ) \
V ( TCPCONNECTWRAP ) \
V ( TCPCONNECTWRAP ) \
V ( TCPWRAP ) \
V ( TIMERWRAP ) \
V ( TIMERWRAP ) \
V ( TLSWRAP ) \
V ( TLSWRAP ) \
V ( TTYWRAP ) \
V ( TTYWRAP ) \
V ( UDPWRAP ) \
V ( UDPSENDWRAP ) \
V ( UDPSENDWRAP ) \
V ( UDPWRAP ) \
V ( WRITEWRAP ) \
V ( WRITEWRAP ) \
V ( ZLIB )
V ( ZLIB )
@ -69,6 +71,7 @@ class AsyncWrap : public BaseObject {
PROVIDER_ # # PROVIDER ,
PROVIDER_ # # PROVIDER ,
NODE_ASYNC_PROVIDER_TYPES ( V )
NODE_ASYNC_PROVIDER_TYPES ( V )
# undef V
# undef V
PROVIDERS_LENGTH ,
} ;
} ;
AsyncWrap ( Environment * env ,
AsyncWrap ( Environment * env ,
@ -5314,7 +5314,7 @@ class PBKDF2Request : public AsyncWrap {
char * salt ,
char * salt ,
int iter ,
int iter ,
int keylen )
int keylen )
: AsyncWrap ( env , object , AsyncWrap : : PROVIDER_CRYPTO ) ,
: AsyncWrap ( env , object , AsyncWrap : : PROVIDER_PBKDF2REQUEST ) ,
digest_ ( digest ) ,
digest_ ( digest ) ,
error_ ( 0 ) ,
error_ ( 0 ) ,
passlen_ ( passlen ) ,
passlen_ ( passlen ) ,
@ -5586,7 +5586,7 @@ class RandomBytesRequest : public AsyncWrap {
size_t size ,
size_t size ,
char * data ,
char * data ,
FreeMode free_mode )
FreeMode free_mode )
: AsyncWrap ( env , object , AsyncWrap : : PROVIDER_CRYPTO ) ,
: AsyncWrap ( env , object , AsyncWrap : : PROVIDER_RANDOMBYTESREQUEST ) ,
error_ ( 0 ) ,
error_ ( 0 ) ,
size_ ( size ) ,
size_ ( size ) ,
data_ ( data ) ,
data_ ( data ) ,
@ -402,7 +402,7 @@ class Connection : public AsyncWrap, public SSLWrap<Connection> {
v8 : : Local < v8 : : Object > wrap ,
v8 : : Local < v8 : : Object > wrap ,
SecureContext * sc ,
SecureContext * sc ,
SSLWrap < Connection > : : Kind kind )
SSLWrap < Connection > : : Kind kind )
: AsyncWrap ( env , wrap , AsyncWrap : : PROVIDER_CRYPTO ) ,
: AsyncWrap ( env , wrap , AsyncWrap : : PROVIDER_CONNECTION ) ,
SSLWrap < Connection > ( env , sc , kind ) ,
SSLWrap < Connection > ( env , sc , kind ) ,
bio_read_ ( nullptr ) ,
bio_read_ ( nullptr ) ,
bio_write_ ( nullptr ) ,
bio_write_ ( nullptr ) ,