| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 2b55b60 commit 66ee1f1
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -452,6 +452,10 @@ void StreamBase::AddMethods(Environment* env, Local<FunctionTemplate> t) { | |||
| 452 | 452 | ||
| 453 | 453 | void StreamBase::RegisterExternalReferences( | |
| 454 | 454 | ExternalReferenceRegistry* registry) { | |
| 455 | + // This function is called by a single thread during start up, so it is safe | ||
| 456 | + // to use a local static variable here. | ||
| 457 | + static bool is_registered = false; | ||
| 458 | + if (is_registered) return; | ||
| 455 | 459 | registry->Register(GetFD); | |
| 456 | 460 | registry->Register(GetExternal); | |
| 457 | 461 | registry->Register(GetBytesRead); | |
@@ -471,6 +475,7 @@ void StreamBase::RegisterExternalReferences( | |||
| 471 | 475 | registry->Register( | |
| 472 | 476 | BaseObject::InternalFieldSet<StreamBase::kOnReadFunctionField, | |
| 473 | 477 | &Value::IsFunction>); | |
| 478 | + is_registered = true; | ||
| 474 | 479 | } | |
| 475 | 480 | ||
| 476 | 481 | void StreamBase::GetFD(const FunctionCallbackInfo<Value>& args) { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -108,8 +108,7 @@ void LibuvStreamWrap::RegisterExternalReferences( | |||
| 108 | 108 | registry->Register(IsConstructCallCallback); | |
| 109 | 109 | registry->Register(GetWriteQueueSize); | |
| 110 | 110 | registry->Register(SetBlocking); | |
| 111 | - // TODO(joyee): StreamBase::RegisterExternalReferences() is called somewhere | ||
| 112 | - // else but we may want to do it here too and guard it with a static flag. | ||
| 111 | + StreamBase::RegisterExternalReferences(registry); | ||
| 113 | 112 | } | |
| 114 | 113 | ||
| 115 | 114 | LibuvStreamWrap::LibuvStreamWrap(Environment* env, | |
| Back | FazBrowse Home | New Git URL |
0 commit comments