Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFedor Indutny <fedor@indutny.com>2015-03-06 22:58:24 +0300
committerFedor Indutny <fedor@indutny.com>2015-03-09 02:07:46 +0300
commit8670613d2d5dbfc191678caffe4c2bd228147046 (patch)
tree70f26051e5f669197f49560adbfa4d5bbd0c0fc4 /src/node_crypto_bio.h
parentf8c893dd39d2dc03bddd4a7a036484df027c94d6 (diff)
node_crypto_bio: adjust external memory size
Adjust V8's external memory size when allocating buffers for TLS data to ensure that V8 has enough information to trigger the GC at right time. PR-URL: https://github.com/iojs/io.js/pull/1085 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Diffstat (limited to 'src/node_crypto_bio.h')
-rw-r--r--src/node_crypto_bio.h23
1 files changed, 18 insertions, 5 deletions
diff --git a/src/node_crypto_bio.h b/src/node_crypto_bio.h
index 4d19d467efc..5c38f1baac7 100644
--- a/src/node_crypto_bio.h
+++ b/src/node_crypto_bio.h
@@ -2,14 +2,18 @@
#define SRC_NODE_CRYPTO_BIO_H_
#include "openssl/bio.h"
+#include "env.h"
+#include "env-inl.h"
#include "util.h"
#include "util-inl.h"
+#include "v8.h"
namespace node {
class NodeBIO {
public:
- NodeBIO() : initial_(kInitialBufferLength),
+ NodeBIO() : env_(nullptr),
+ initial_(kInitialBufferLength),
length_(0),
read_head_(nullptr),
write_head_(nullptr) {
@@ -19,6 +23,8 @@ class NodeBIO {
static BIO* New();
+ void AssignEnvironment(Environment* env);
+
// Move read head to next buffer if needed
void TryMoveReadHead();
@@ -89,17 +95,23 @@ class NodeBIO {
class Buffer {
public:
- explicit Buffer(size_t len) : read_pos_(0),
- write_pos_(0),
- len_(len),
- next_(nullptr) {
+ Buffer(Environment* env, size_t len) : env_(env),
+ read_pos_(0),
+ write_pos_(0),
+ len_(len),
+ next_(nullptr) {
data_ = new char[len];
+ if (env_ != nullptr)
+ env_->isolate()->AdjustAmountOfExternalAllocatedMemory(len);
}
~Buffer() {
delete[] data_;
+ if (env_ != nullptr)
+ env_->isolate()->AdjustAmountOfExternalAllocatedMemory(-len_);
}
+ Environment* env_;
size_t read_pos_;
size_t write_pos_;
size_t len_;
@@ -107,6 +119,7 @@ class NodeBIO {
char* data_;
};
+ Environment* env_;
size_t initial_;
size_t length_;
Buffer* read_head_;