@@ -375,11 +375,10 @@ inline FSReqWrap* AsyncCall(Environment* env,
375
375
// the error number and the syscall in the context instead of
376
376
// creating an error in the C++ land.
377
377
template <typename Func, typename ... Args>
378
- inline void SyncCall (Environment* env, Local<Value> ctx,
378
+ inline int SyncCall (Environment* env, Local<Value> ctx, fs_req_wrap* req_wrap ,
379
379
const char * syscall, Func fn, Args... args) {
380
- fs_req_wrap req_wrap;
381
380
env->PrintSyncTrace ();
382
- int err = fn (env->event_loop (), &req_wrap. req , args..., nullptr );
381
+ int err = fn (env->event_loop (), &( req_wrap-> req ) , args..., nullptr );
383
382
if (err < 0 ) {
384
383
Local<Context> context = env->context ();
385
384
Local<Object> ctx_obj = ctx->ToObject (context).ToLocalChecked ();
@@ -391,6 +390,7 @@ inline void SyncCall(Environment* env, Local<Value> ctx,
391
390
env->syscall_string (),
392
391
OneByteString (isolate, syscall)).FromJust ();
393
392
}
393
+ return err;
394
394
}
395
395
396
396
#define SYNC_DEST_CALL (func, path, dest, ...) \
@@ -426,7 +426,8 @@ void Access(const FunctionCallbackInfo<Value>& args) {
426
426
AsyncCall (env, args, " access" , UTF8, AfterNoArgs,
427
427
uv_fs_access, *path, mode);
428
428
} else { // access(path, mode, undefined, ctx)
429
- SyncCall (env, args[3 ], " access" , uv_fs_access, *path, mode);
429
+ fs_req_wrap req_wrap;
430
+ SyncCall (env, args[3 ], &req_wrap, " access" , uv_fs_access, *path, mode);
430
431
}
431
432
}
432
433
@@ -446,7 +447,8 @@ void Close(const FunctionCallbackInfo<Value>& args) {
446
447
AsyncCall (env, args, " close" , UTF8, AfterNoArgs,
447
448
uv_fs_close, fd);
448
449
} else { // close(fd, undefined, ctx)
449
- SyncCall (env, args[2 ], " close" , uv_fs_close, fd);
450
+ fs_req_wrap req_wrap;
451
+ SyncCall (env, args[2 ], &req_wrap, " close" , uv_fs_close, fd);
450
452
}
451
453
}
452
454
0 commit comments