mirror of
https://github.com/lovell/sharp.git
synced 2025-07-09 18:40:16 +02:00
Wrap all async JS callbacks, help avoid possible race #3569
This commit is contained in:
parent
0063df4d4f
commit
4ec883eaa0
@ -53,6 +53,9 @@ Requires libvips v8.14.0
|
|||||||
[#3556](https://github.com/lovell/sharp/pull/3556)
|
[#3556](https://github.com/lovell/sharp/pull/3556)
|
||||||
[@janaz](https://github.com/janaz)
|
[@janaz](https://github.com/janaz)
|
||||||
|
|
||||||
|
* Ensure all async JS callbacks are wrapped to help avoid possible race condition.
|
||||||
|
[#3569](https://github.com/lovell/sharp/issues/3569)
|
||||||
|
|
||||||
## v0.31 - *eagle*
|
## v0.31 - *eagle*
|
||||||
|
|
||||||
Requires libvips v8.13.3
|
Requires libvips v8.13.3
|
||||||
|
@ -145,7 +145,7 @@ class MetadataWorker : public Napi::AsyncWorker {
|
|||||||
// Handle warnings
|
// Handle warnings
|
||||||
std::string warning = sharp::VipsWarningPop();
|
std::string warning = sharp::VipsWarningPop();
|
||||||
while (!warning.empty()) {
|
while (!warning.empty()) {
|
||||||
debuglog.Call({ Napi::String::New(env, warning) });
|
debuglog.MakeCallback(Receiver().Value(), { Napi::String::New(env, warning) });
|
||||||
warning = sharp::VipsWarningPop();
|
warning = sharp::VipsWarningPop();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1175,7 +1175,7 @@ class PipelineWorker : public Napi::AsyncWorker {
|
|||||||
// Handle warnings
|
// Handle warnings
|
||||||
std::string warning = sharp::VipsWarningPop();
|
std::string warning = sharp::VipsWarningPop();
|
||||||
while (!warning.empty()) {
|
while (!warning.empty()) {
|
||||||
debuglog.Call({ Napi::String::New(env, warning) });
|
debuglog.MakeCallback(Receiver().Value(), { Napi::String::New(env, warning) });
|
||||||
warning = sharp::VipsWarningPop();
|
warning = sharp::VipsWarningPop();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1251,7 +1251,7 @@ class PipelineWorker : public Napi::AsyncWorker {
|
|||||||
// Decrement processing task counter
|
// Decrement processing task counter
|
||||||
g_atomic_int_dec_and_test(&sharp::counterProcess);
|
g_atomic_int_dec_and_test(&sharp::counterProcess);
|
||||||
Napi::Number queueLength = Napi::Number::New(env, static_cast<double>(sharp::counterQueue));
|
Napi::Number queueLength = Napi::Number::New(env, static_cast<double>(sharp::counterQueue));
|
||||||
queueListener.Call(Receiver().Value(), { queueLength });
|
queueListener.MakeCallback(Receiver().Value(), { queueLength });
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@ -1681,7 +1681,7 @@ Napi::Value pipeline(const Napi::CallbackInfo& info) {
|
|||||||
// Increment queued task counter
|
// Increment queued task counter
|
||||||
g_atomic_int_inc(&sharp::counterQueue);
|
g_atomic_int_inc(&sharp::counterQueue);
|
||||||
Napi::Number queueLength = Napi::Number::New(info.Env(), static_cast<double>(sharp::counterQueue));
|
Napi::Number queueLength = Napi::Number::New(info.Env(), static_cast<double>(sharp::counterQueue));
|
||||||
queueListener.Call(info.This(), { queueLength });
|
queueListener.MakeCallback(info.This(), { queueLength });
|
||||||
|
|
||||||
return info.Env().Undefined();
|
return info.Env().Undefined();
|
||||||
}
|
}
|
||||||
|
@ -106,7 +106,7 @@ class StatsWorker : public Napi::AsyncWorker {
|
|||||||
// Handle warnings
|
// Handle warnings
|
||||||
std::string warning = sharp::VipsWarningPop();
|
std::string warning = sharp::VipsWarningPop();
|
||||||
while (!warning.empty()) {
|
while (!warning.empty()) {
|
||||||
debuglog.Call({ Napi::String::New(env, warning) });
|
debuglog.MakeCallback(Receiver().Value(), { Napi::String::New(env, warning) });
|
||||||
warning = sharp::VipsWarningPop();
|
warning = sharp::VipsWarningPop();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user