Skip to content

Commit

Permalink
src: pass node_isolate to True() and False()
Browse files Browse the repository at this point in the history
  • Loading branch information
bnoordhuis committed Jan 7, 2013
1 parent 01c3d0a commit 109f73b
Show file tree
Hide file tree
Showing 7 changed files with 75 additions and 59 deletions.
26 changes: 13 additions & 13 deletions src/node.cc
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ static void Tick(void) {
TryCatch try_catch;

// Let the tick callback know that this is coming from the spinner
Handle<Value> argv[] = { True() };
Handle<Value> argv[] = { True(node_isolate) };
cb->Call(process, ARRAY_SIZE(argv), argv);

if (try_catch.HasCaught()) {
Expand Down Expand Up @@ -2078,9 +2078,9 @@ static Handle<Boolean> EnvDeleter(Local<String> property,
HandleScope scope;
#ifdef __POSIX__
String::Utf8Value key(property);
if (!getenv(*key)) return False();
if (!getenv(*key)) return False(node_isolate);
unsetenv(*key); // can't check return value, it's void on some platforms
return True();
return True(node_isolate);
#else
String::Value key(property);
WCHAR* key_ptr = reinterpret_cast<WCHAR*>(*key);
Expand All @@ -2091,7 +2091,7 @@ static Handle<Boolean> EnvDeleter(Local<String> property,
GetLastError() != ERROR_SUCCESS;
return scope.Close(Boolean::New(rv));
}
return True();
return True(node_isolate);
#endif
}

Expand Down Expand Up @@ -2146,14 +2146,14 @@ static Handle<Object> GetFeatures() {
Local<Object> obj = Object::New();
obj->Set(String::NewSymbol("debug"),
#if defined(DEBUG) && DEBUG
True()
True(node_isolate)
#else
False()
False(node_isolate)
#endif
);

obj->Set(String::NewSymbol("uv"), True());
obj->Set(String::NewSymbol("ipv6"), True()); // TODO ping libuv
obj->Set(String::NewSymbol("uv"), True(node_isolate));
obj->Set(String::NewSymbol("ipv6"), True(node_isolate)); // TODO ping libuv
obj->Set(String::NewSymbol("tls_npn"), Boolean::New(use_npn));
obj->Set(String::NewSymbol("tls_sni"), Boolean::New(use_sni));
obj->Set(String::NewSymbol("tls"),
Expand Down Expand Up @@ -2283,22 +2283,22 @@ Handle<Object> SetupProcessObject(int argc, char *argv[]) {

// -p, --print
if (print_eval) {
process->Set(String::NewSymbol("_print_eval"), True());
process->Set(String::NewSymbol("_print_eval"), True(node_isolate));
}

// -i, --interactive
if (force_repl) {
process->Set(String::NewSymbol("_forceRepl"), True());
process->Set(String::NewSymbol("_forceRepl"), True(node_isolate));
}

// --no-deprecation
if (no_deprecation) {
process->Set(String::NewSymbol("noDeprecation"), True());
process->Set(String::NewSymbol("noDeprecation"), True(node_isolate));
}

// --trace-deprecation
if (trace_deprecation) {
process->Set(String::NewSymbol("traceDeprecation"), True());
process->Set(String::NewSymbol("traceDeprecation"), True(node_isolate));
}

size_t size = 2*PATH_MAX;
Expand Down Expand Up @@ -2911,7 +2911,7 @@ void AtExit(void (*cb)(void* arg), void* arg) {

void EmitExit(v8::Handle<v8::Object> process_l) {
// process.emit('exit')
process_l->Set(String::NewSymbol("_exiting"), True());
process_l->Set(String::NewSymbol("_exiting"), True(node_isolate));
Local<Value> emit_v = process_l->Get(String::New("emit"));
assert(emit_v->IsFunction());
Local<Function> emit = Local<Function>::Cast(emit_v);
Expand Down
80 changes: 43 additions & 37 deletions src/node_crypto.cc
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ Handle<Value> SecureContext::Init(const Arguments& args) {
SSL_CTX_sess_set_new_cb(sc->ctx_, NewSessionCallback);

sc->ca_store_ = NULL;
return True();
return True(node_isolate);
}


Expand Down Expand Up @@ -333,7 +333,7 @@ Handle<Value> SecureContext::SetKey(const Arguments& args) {
}

BIO *bio = LoadBIO(args[0]);
if (!bio) return False();
if (!bio) return False(node_isolate);

String::Utf8Value passphrase(args[1]);

Expand All @@ -356,7 +356,7 @@ Handle<Value> SecureContext::SetKey(const Arguments& args) {
EVP_PKEY_free(key);
BIO_free(bio);

return True();
return True(node_isolate);
}


Expand Down Expand Up @@ -437,7 +437,7 @@ Handle<Value> SecureContext::SetCert(const Arguments& args) {
}

BIO* bio = LoadBIO(args[0]);
if (!bio) return False();
if (!bio) return False(node_isolate);

int rv = SSL_CTX_use_certificate_chain(sc->ctx_, bio);

Expand All @@ -454,7 +454,7 @@ Handle<Value> SecureContext::SetCert(const Arguments& args) {
return ThrowException(Exception::Error(String::New(string)));
}

return True();
return True(node_isolate);
}


Expand All @@ -474,7 +474,7 @@ Handle<Value> SecureContext::AddCACert(const Arguments& args) {
}

X509* x509 = LoadX509(args[0]);
if (!x509) return False();
if (!x509) return False(node_isolate);

X509_STORE_add_cert(sc->ca_store_, x509);
SSL_CTX_add_client_CA(sc->ctx_, x509);
Expand All @@ -485,7 +485,7 @@ Handle<Value> SecureContext::AddCACert(const Arguments& args) {
SSL_CTX_set_cert_store(sc->ctx_, sc->ca_store_);
}

return True();
return True(node_isolate);
}


Expand All @@ -499,13 +499,13 @@ Handle<Value> SecureContext::AddCRL(const Arguments& args) {
}

BIO *bio = LoadBIO(args[0]);
if (!bio) return False();
if (!bio) return False(node_isolate);

X509_CRL *x509 = PEM_read_bio_X509_CRL(bio, NULL, NULL, NULL);

if (x509 == NULL) {
BIO_free(bio);
return False();
return False(node_isolate);
}

X509_STORE_add_crl(sc->ca_store_, x509);
Expand All @@ -516,7 +516,7 @@ Handle<Value> SecureContext::AddCRL(const Arguments& args) {
BIO_free(bio);
X509_CRL_free(x509);

return True();
return True(node_isolate);
}


Expand All @@ -536,14 +536,14 @@ Handle<Value> SecureContext::AddRootCerts(const Arguments& args) {

if (!BIO_write(bp, root_certs[i], strlen(root_certs[i]))) {
BIO_free(bp);
return False();
return False(node_isolate);
}

X509 *x509 = PEM_read_bio_X509(bp, NULL, NULL, NULL);

if (x509 == NULL) {
BIO_free(bp);
return False();
return False(node_isolate);
}

X509_STORE_add_cert(root_cert_store, x509);
Expand All @@ -556,7 +556,7 @@ Handle<Value> SecureContext::AddRootCerts(const Arguments& args) {
sc->ca_store_ = root_cert_store;
SSL_CTX_set_cert_store(sc->ctx_, sc->ca_store_);

return True();
return True(node_isolate);
}


Expand All @@ -572,7 +572,7 @@ Handle<Value> SecureContext::SetCiphers(const Arguments& args) {
String::Utf8Value ciphers(args[0]);
SSL_CTX_set_cipher_list(sc->ctx_, *ciphers);

return True();
return True(node_isolate);
}

Handle<Value> SecureContext::SetOptions(const Arguments& args) {
Expand All @@ -586,7 +586,7 @@ Handle<Value> SecureContext::SetOptions(const Arguments& args) {

SSL_CTX_set_options(sc->ctx_, args[0]->IntegerValue());

return True();
return True(node_isolate);
}

Handle<Value> SecureContext::SetSessionIdContext(const Arguments& args) {
Expand Down Expand Up @@ -618,14 +618,14 @@ Handle<Value> SecureContext::SetSessionIdContext(const Arguments& args) {
return ThrowException(Exception::TypeError(message));
}

return True();
return True(node_isolate);
}

Handle<Value> SecureContext::Close(const Arguments& args) {
HandleScope scope;
SecureContext *sc = ObjectWrap::Unwrap<SecureContext>(args.Holder());
sc->FreeCTXMem();
return False();
return False(node_isolate);
}

//Takes .pfx or .p12 and password in string or buffer format
Expand Down Expand Up @@ -702,7 +702,7 @@ Handle<Value> SecureContext::LoadPKCS12(const Arguments& args) {
return ThrowException(Exception::Error(String::New(str)));
}

return True();
return True(node_isolate);
}


Expand Down Expand Up @@ -948,11 +948,11 @@ void Connection::SetShutdownFlags() {
int flags = SSL_get_shutdown(ssl_);

if (flags & SSL_SENT_SHUTDOWN) {
handle_->Set(String::New("sentShutdown"), True());
handle_->Set(String::New("sentShutdown"), True(node_isolate));
}

if (flags & SSL_RECEIVED_SHUTDOWN) {
handle_->Set(String::New("receivedShutdown"), True());
handle_->Set(String::New("receivedShutdown"), True(node_isolate));
}
}

Expand Down Expand Up @@ -1082,7 +1082,7 @@ int Connection::SelectNextProtoCallback_(SSL *s,
*outlen = 8;

// set status unsupported
p->selectedNPNProto_ = Persistent<Value>::New(False());
p->selectedNPNProto_ = Persistent<Value>::New(False(node_isolate));

return SSL_TLSEXT_ERR_OK;
}
Expand All @@ -1103,7 +1103,7 @@ int Connection::SelectNextProtoCallback_(SSL *s,
));
break;
case OPENSSL_NPN_NO_OVERLAP:
p->selectedNPNProto_ = Persistent<Value>::New(False());
p->selectedNPNProto_ = Persistent<Value>::New(False(node_isolate));
break;
default:
break;
Expand Down Expand Up @@ -1660,7 +1660,7 @@ Handle<Value> Connection::SetSession(const Arguments& args) {
return ThrowException(Exception::Error(eStr));
}

return True();
return True(node_isolate);
}

Handle<Value> Connection::LoadSession(const Arguments& args) {
Expand All @@ -1684,16 +1684,19 @@ Handle<Value> Connection::LoadSession(const Arguments& args) {

ss->hello_parser_.Finish();

return True();
return True(node_isolate);
}

Handle<Value> Connection::IsSessionReused(const Arguments& args) {
HandleScope scope;

Connection *ss = Connection::Unwrap(args);

if (ss->ssl_ == NULL) return False();
return SSL_session_reused(ss->ssl_) ? True() : False();
if (ss->ssl_ == NULL || SSL_session_reused(ss->ssl_) == false) {
return False(node_isolate);
}

return True(node_isolate);
}


Expand Down Expand Up @@ -1724,7 +1727,7 @@ Handle<Value> Connection::Shutdown(const Arguments& args) {

Connection *ss = Connection::Unwrap(args);

if (ss->ssl_ == NULL) return False();
if (ss->ssl_ == NULL) return False(node_isolate);
int rv = SSL_shutdown(ss->ssl_);
ss->HandleSSLError("SSL_shutdown", rv, kZeroIsNotAnError);
ss->SetShutdownFlags();
Expand All @@ -1738,12 +1741,12 @@ Handle<Value> Connection::ReceivedShutdown(const Arguments& args) {

Connection *ss = Connection::Unwrap(args);

if (ss->ssl_ == NULL) return False();
if (ss->ssl_ == NULL) return False(node_isolate);
int r = SSL_get_shutdown(ss->ssl_);

if (r & SSL_RECEIVED_SHUTDOWN) return True();
if (r & SSL_RECEIVED_SHUTDOWN) return True(node_isolate);

return False();
return False(node_isolate);
}


Expand All @@ -1752,8 +1755,11 @@ Handle<Value> Connection::IsInitFinished(const Arguments& args) {

Connection *ss = Connection::Unwrap(args);

if (ss->ssl_ == NULL) return False();
return SSL_is_init_finished(ss->ssl_) ? True() : False();
if (ss->ssl_ == NULL || SSL_is_init_finished(ss->ssl_) == false) {
return False(node_isolate);
}

return True(node_isolate);
}


Expand Down Expand Up @@ -1929,7 +1935,7 @@ Handle<Value> Connection::Close(const Arguments& args) {
SSL_free(ss->ssl_);
ss->ssl_ = NULL;
}
return True();
return True(node_isolate);
}

#ifdef OPENSSL_NPN_NEGOTIATED
Expand All @@ -1945,7 +1951,7 @@ Handle<Value> Connection::GetNegotiatedProto(const Arguments& args) {
SSL_get0_next_proto_negotiated(ss->ssl_, &npn_proto, &npn_proto_len);

if (!npn_proto) {
return False();
return False(node_isolate);
}

return String::New((const char*) npn_proto, npn_proto_len);
Expand All @@ -1970,7 +1976,7 @@ Handle<Value> Connection::SetNPNProtocols(const Arguments& args) {
}
ss->npnProtos_ = Persistent<Object>::New(args[0]->ToObject());

return True();
return True(node_isolate);
};
#endif

Expand All @@ -1983,7 +1989,7 @@ Handle<Value> Connection::GetServername(const Arguments& args) {
if (ss->is_server_ && !ss->servername_.IsEmpty()) {
return ss->servername_;
} else {
return False();
return False(node_isolate);
}
}

Expand All @@ -2004,7 +2010,7 @@ Handle<Value> Connection::SetSNICallback(const Arguments& args) {
ss->sniObject_ = Persistent<Object>::New(Object::New());
ss->sniObject_->Set(String::New("onselect"), args[0]);

return True();
return True(node_isolate);
}
#endif

Expand Down
Loading

0 comments on commit 109f73b

Please sign in to comment.