| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 97d0817 commit ae19617
4 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -227,6 +227,7 @@ namespace node { | |||
| 227 | 227 | V(zero_return_string, "ZERO_RETURN") \ | |
| 228 | 228 | ||
| 229 | 229 | #define ENVIRONMENT_STRONG_PERSISTENT_PROPERTIES(V) \ | |
| 230 | + V(add_properties_by_index_function, v8::Function) \ | ||
| 230 | 231 | V(as_external, v8::External) \ | |
| 231 | 232 | V(async_hooks_init_function, v8::Function) \ | |
| 232 | 233 | V(async_hooks_pre_function, v8::Function) \ | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1009,6 +1009,17 @@ void RunMicrotasks(const FunctionCallbackInfo<Value>& args) { | |||
| 1009 | 1009 | } | |
| 1010 | 1010 | ||
| 1011 | 1011 | ||
| 1012 | + void SetupProcessObject(const FunctionCallbackInfo<Value>& args) { | ||
| 1013 | + Environment* env = Environment::GetCurrent(args); | ||
| 1014 | + | ||
| 1015 | + CHECK(args[0]->IsFunction()); | ||
| 1016 | + | ||
| 1017 | + env->set_add_properties_by_index_function(args[0].As<Function>()); | ||
| 1018 | + env->process_object()->Delete( | ||
| 1019 | + FIXED_ONE_BYTE_STRING(env->isolate(), "_setupProcessObject")); | ||
| 1020 | + } | ||
| 1021 | + | ||
| 1022 | + | ||
| 1012 | 1023 | void SetupNextTick(const FunctionCallbackInfo<Value>& args) { | |
| 1013 | 1024 | Environment* env = Environment::GetCurrent(args); | |
| 1014 | 1025 | ||
@@ -1546,11 +1557,30 @@ static void GetActiveRequests(const FunctionCallbackInfo<Value>& args) { | |||
| 1546 | 1557 | Environment* env = Environment::GetCurrent(args); | |
| 1547 | 1558 | ||
| 1548 | 1559 | Local<Array> ary = Array::New(args.GetIsolate()); | |
| 1549 | - int i = 0; | ||
| 1560 | + Local<Context> ctx = env->context(); | ||
| 1561 | + Local<Function> fn = env->add_properties_by_index_function(); | ||
| 1562 | + static const size_t argc = 8; | ||
| 1563 | + Local<Value> argv[argc]; | ||
| 1564 | + size_t i = 0; | ||
| 1565 | + | ||
| 1566 | + for (auto w : *env->req_wrap_queue()) { | ||
| 1567 | + if (w->persistent().IsEmpty() == false) { | ||
| 1568 | + argv[i++ % argc] = w->object(); | ||
| 1569 | + if ((i % argc) == 0) { | ||
| 1570 | + HandleScope scope(env->isolate()); | ||
| 1571 | + fn->Call(ctx, ary, argc, argv).ToLocalChecked(); | ||
| 1572 | + for (auto&& arg : argv) { | ||
| 1573 | + arg = Local<Value>(); | ||
| 1574 | + } | ||
| 1575 | + } | ||
| 1576 | + } | ||
| 1577 | + } | ||
| 1550 | 1578 | ||
| 1551 | - for (auto w : *env->req_wrap_queue()) | ||
| 1552 | - if (w->persistent().IsEmpty() == false) | ||
| 1553 | - ary->Set(i++, w->object()); | ||
| 1579 | + const size_t remainder = i % argc; | ||
| 1580 | + if (remainder > 0) { | ||
| 1581 | + HandleScope scope(env->isolate()); | ||
| 1582 | + fn->Call(ctx, ary, remainder, argv).ToLocalChecked(); | ||
| 1583 | + } | ||
| 1554 | 1584 | ||
| 1555 | 1585 | args.GetReturnValue().Set(ary); | |
| 1556 | 1586 | } | |
@@ -2979,6 +3009,7 @@ void SetupProcessObject(Environment* env, | |||
| 2979 | 3009 | env->SetMethod(process, "binding", Binding); | |
| 2980 | 3010 | env->SetMethod(process, "_linkedBinding", LinkedBinding); | |
| 2981 | 3011 | ||
| 3012 | + env->SetMethod(process, "_setupProcessObject", SetupProcessObject); | ||
| 2982 | 3013 | env->SetMethod(process, "_setupNextTick", SetupNextTick); | |
| 2983 | 3014 | env->SetMethod(process, "_setupPromises", SetupPromises); | |
| 2984 | 3015 | env->SetMethod(process, "_setupDomainUse", SetupDomainUse); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -22,6 +22,8 @@ | |||
| 22 | 22 | ||
| 23 | 23 | process.EventEmitter = EventEmitter; // process.EventEmitter is deprecated | |
| 24 | 24 | ||
| 25 | + startup.setupProcessObject(); | ||
| 26 | + | ||
| 25 | 27 | // do this good and early, since it handles errors. | |
| 26 | 28 | startup.processFatal(); | |
| 27 | 29 | ||
@@ -173,6 +175,15 @@ | |||
| 173 | 175 | } | |
| 174 | 176 | } | |
| 175 | 177 | ||
| 178 | + startup.setupProcessObject = function() { | ||
| 179 | + process._setupProcessObject(setPropByIndex); | ||
| 180 | + | ||
| 181 | + function setPropByIndex() { | ||
| 182 | + for (var i = 0; i < arguments.length; i++) | ||
| 183 | + this.push(arguments[i]); | ||
| 184 | + } | ||
| 185 | + }; | ||
| 186 | + | ||
| 176 | 187 | startup.globalVariables = function() { | |
| 177 | 188 | global.process = process; | |
| 178 | 189 | global.global = global; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,10 @@ | |||
| 1 | + 'use strict'; | ||
| 2 | + | ||
| 3 | + const common = require('../common'); | ||
| 4 | + const assert = require('assert'); | ||
| 5 | + const fs = require('fs'); | ||
| 6 | + | ||
| 7 | + for (let i = 0; i < 12; i++) | ||
| 8 | + fs.open(__filename, 'r', function() { }); | ||
| 9 | + | ||
| 10 | + assert.equal(12, process._getActiveRequests().length); | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments