lib, src: don't make http parser handles weak
Weak handles put strain on the garbage collector and the parser handle doesn't need to be weak in the first place. This change should improve GC times on busy servers a little. Reviewed-by: Trevor Norris <trev.norris@gmail.com>
This commit is contained in:
parent
1e99486cc8
commit
b33a47ef47
@ -200,7 +200,8 @@ function freeParser(parser, req) {
|
||||
parser.socket.parser = null;
|
||||
parser.socket = null;
|
||||
parser.incoming = null;
|
||||
parsers.free(parser);
|
||||
if (parsers.free(parser) === false)
|
||||
parser.close();
|
||||
parser = null;
|
||||
}
|
||||
if (req) {
|
||||
|
@ -39,5 +39,7 @@ exports.FreeList.prototype.free = function(obj) {
|
||||
//debug("free " + this.name + " " + this.list.length);
|
||||
if (this.list.length < this.max) {
|
||||
this.list.push(obj);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
@ -169,12 +169,14 @@ class Parser : public BaseObject {
|
||||
: BaseObject(env, wrap),
|
||||
current_buffer_len_(0),
|
||||
current_buffer_data_(NULL) {
|
||||
MakeWeak<Parser>(this);
|
||||
Wrap(object(), this);
|
||||
Init(type);
|
||||
}
|
||||
|
||||
|
||||
~Parser() {
|
||||
ClearWrap(object());
|
||||
persistent().Reset();
|
||||
}
|
||||
|
||||
|
||||
@ -357,6 +359,13 @@ class Parser : public BaseObject {
|
||||
}
|
||||
|
||||
|
||||
static void Close(const FunctionCallbackInfo<Value>& args) {
|
||||
HandleScope handle_scope(args.GetIsolate());
|
||||
Parser* parser = Unwrap<Parser>(args.Holder());
|
||||
delete parser;
|
||||
}
|
||||
|
||||
|
||||
void Save() {
|
||||
url_.Save();
|
||||
status_message_.Save();
|
||||
@ -591,6 +600,7 @@ void InitHttpParser(Handle<Object> target,
|
||||
#undef V
|
||||
t->Set(FIXED_ONE_BYTE_STRING(env->isolate(), "methods"), methods);
|
||||
|
||||
NODE_SET_PROTOTYPE_METHOD(t, "close", Parser::Close);
|
||||
NODE_SET_PROTOTYPE_METHOD(t, "execute", Parser::Execute);
|
||||
NODE_SET_PROTOTYPE_METHOD(t, "finish", Parser::Finish);
|
||||
NODE_SET_PROTOTYPE_METHOD(t, "reinitialize", Parser::Reinitialize);
|
||||
|
Loading…
x
Reference in New Issue
Block a user