8000 addons, bugfix: fibjs api crashed in addons callback. · fibjs/fibjs@d797c0f · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Commit d797c0f

Browse files
committed
addons, bugfix: fibjs api crashed in addons callback.
1 parent 356bd77 commit d797c0f

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

fibjs/include/addons/node_api_internal.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
#include "object.h"
44
#include "Buffer.h"
5+
#include "Fiber.h"
56
#include "node_version.h"
67

78
#ifdef __GNUC__
@@ -572,6 +573,7 @@ class ThreadPoolWork : private fibjs::AsyncEvent {
572573

573574
virtual fibjs::result_t js_invoke()
574575
{
576+
fibjs::JSFiber::EnterJsScope s;
575577
AfterThreadPoolWork(status_);
576578
return 0;
577579
}
@@ -583,7 +585,7 @@ class ThreadPoolWork : private fibjs::AsyncEvent {
583585

584586
private:
585587
Environment* env_;
586-
const char* type_;
588+
const char* type_ = NULL;
587589
int status_ = 0;
588590
std::atomic_bool not_running_ = false;
589591
};

test/addons_test.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
var test = require("test");
2+
var fs = require("fs");
23
test.setup();
34

45
const path = require('path');
@@ -187,6 +188,7 @@ describe('addons api', () => {
187188
const test_async = module.exports;
188189

189190
test_async.Test(5, {}, test.mustCall(function (err, val) {
191+
fs.readFileSync(__filename);
190192
assert.strictEqual(err, null);
191193
assert.strictEqual(val, 10);
192194
}));

0 commit comments

Comments
 (0)
0