fs: cancel in-flight stat on abort · nodejs/node@ea372bf · GitHub
Skip to content

Commit ea372bf

Browse files
mertcanaltinaduh95
authored andcommitted
fs: cancel in-flight stat on abort
Signed-off-by: Mert Can Altin <mertgold60@gmail.com> PR-URL: #63142 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Chemi Atlow <chemi@atlow.co.il> Reviewed-By: Gürgün Dayıoğlu <hey@gurgun.day>
1 parent ed1b629 commit ea372bf

3 files changed

Lines changed: 48 additions & 0 deletions

File tree

‎lib/fs.js‎

Lines changed: 1 addition & 0 deletions

‎src/node_file.cc‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -758,6 +758,12 @@ void NewFSReqCallback(const FunctionCallbackInfo<Value>& args) {
758758
new FSReqCallback(binding_data, args.This(), args[0]->IsTrue());
759759
}
760760

761+
void CancelFSReq(const FunctionCallbackInfo<Value>& args) {
762+
FSReqBase* req_wrap;
763+
ASSIGN_OR_RETURN_UNWRAP(&req_wrap, args.This());
764+
req_wrap->Cancel();
765+
}
766+
761767
FSReqAfterScope::FSReqAfterScope(FSReqBase* wrap, uv_fs_t* req)
762768
: wrap_(wrap),
763769
req_(req),
@@ -4618,6 +4624,7 @@ static void CreatePerIsolateProperties(IsolateData* isolate_data,
46184624
fst->InstanceTemplate()->SetInternalFieldCount(
46194625
FSReqBase::kInternalFieldCount);
46204626
fst->Inherit(AsyncWrap::GetConstructorTemplate(isolate_data));
4627+
SetProtoMethod(isolate, fst, "cancel", CancelFSReq);
46214628
SetConstructorFunction(isolate, target, "FSReqCallback", fst);
46224629

46234630
// Create FunctionTemplate for FileHandleReadWrap. There’s no need
@@ -4734,6 +4741,7 @@ void RegisterExternalReferences(ExternalReferenceRegistry* registry) {
47344741
registry->Register(HandleToFd);
47354742
#endif
47364743
registry->Register(NewFSReqCallback);
4744+
registry->Register(CancelFSReq);
47374745

47384746
registry->Register(FileHandle::New);
47394747
registry->Register(FileHandle::Close);
Lines changed: 39 additions & 0 deletions

0 commit comments

Comments
 (0)