diff --git a/lib/_tls_legacy.js b/lib/_tls_legacy.js
index 2f7559d09d..be3c8aff55 100644
--- a/lib/_tls_legacy.js
+++ b/lib/_tls_legacy.js
@@ -314,16 +314,21 @@ CryptoStream.prototype._read = function read(size) {
if (bytesRead === 0) {
// EOF when cleartext has finished and we have nothing to read
- if (this._opposite._finished && this._internallyPendingBytes() === 0) {
+ if (this._opposite._finished && this._internallyPendingBytes() === 0 ||
+ this.pair.ssl && this.pair.ssl.receivedShutdown) {
// Perform graceful shutdown
this._done();
// No half-open, sorry!
- if (this === this.pair.cleartext)
+ if (this === this.pair.cleartext) {
this._opposite._done();
- // EOF
- this.push(null);
+ // EOF
+ this.push(null);
+ } else if (!this.pair.ssl || !this.pair.ssl.receivedShutdown) {
+ // EOF
+ this.push(null);
+ }
} else {
// Bail out
this.push('');
diff --git a/node.gyp b/node.gyp
index a0a1774a43..f8f4a9ac8e 100644
--- a/node.gyp
+++ b/node.gyp
@@ -320,7 +320,7 @@
],
}],
[
- 'OS=="linux"', {
+ 'OS=="linux" and node_shared_v8=="false"', {
'ldflags': [
'-Wl,--whole-archive <(PRODUCT_DIR)/obj.target/deps/v8/tools/gyp/libv8_base.<(target_arch).a -Wl,--no-whole-archive',
],
diff --git a/src/node_crypto.cc b/src/node_crypto.cc
index 1e7bf368af..d1467527e4 100644
--- a/src/node_crypto.cc
+++ b/src/node_crypto.cc
@@ -852,9 +852,9 @@ void SSLWrap::AddMethods(Handle t) {
NODE_SET_PROTOTYPE_METHOD(t, "isInitFinished", IsInitFinished);
NODE_SET_PROTOTYPE_METHOD(t, "verifyError", VerifyError);
NODE_SET_PROTOTYPE_METHOD(t, "getCurrentCipher", GetCurrentCipher);
- NODE_SET_PROTOTYPE_METHOD(t, "receivedShutdown", ReceivedShutdown);
NODE_SET_PROTOTYPE_METHOD(t, "endParser", EndParser);
NODE_SET_PROTOTYPE_METHOD(t, "renegotiate", Renegotiate);
+ NODE_SET_PROTOTYPE_METHOD(t, "shutdown", Shutdown);
#ifdef OPENSSL_NPN_NEGOTIATED
NODE_SET_PROTOTYPE_METHOD(t, "getNegotiatedProtocol", GetNegotiatedProto);
@@ -1206,15 +1206,6 @@ void SSLWrap::IsSessionReused(const FunctionCallbackInfo& args) {
}
-template
-void SSLWrap::ReceivedShutdown(const FunctionCallbackInfo& args) {
- HandleScope scope(node_isolate);
- Base* w = Unwrap(args.This());
- bool yes = SSL_get_shutdown(w->ssl_) == SSL_RECEIVED_SHUTDOWN;
- args.GetReturnValue().Set(yes);
-}
-
-
template
void SSLWrap::EndParser(const FunctionCallbackInfo& args) {
HandleScope scope(node_isolate);
@@ -1237,6 +1228,17 @@ void SSLWrap::Renegotiate(const FunctionCallbackInfo& args) {
}
+template
+void SSLWrap::Shutdown(const FunctionCallbackInfo& args) {
+ HandleScope scope(node_isolate);
+
+ Base* w = Unwrap(args.This());
+
+ int rv = SSL_shutdown(w->ssl_);
+ args.GetReturnValue().Set(rv);
+}
+
+
template
void SSLWrap::IsInitFinished(const FunctionCallbackInfo& args) {
HandleScope scope(node_isolate);
@@ -1619,7 +1621,6 @@ void Connection::Initialize(Environment* env, Handle