Bug 227017

Summary: [GLib] Rewrite NetworkCache::Data::adoptMap without FileSystem::MappedFileData::leakHandle and munmap
Product: WebKit Reporter: Fujii Hironori <Hironori.Fujii>
Component: WebKit2Assignee: Fujii Hironori <Hironori.Fujii>
Status: RESOLVED FIXED    
Severity: Normal CC: benjamin, cdumez, cgarcia, cmarcelo, ews-watchlist, kkinnunen, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
Bug Depends on:    
Bug Blocks: 227011    
Attachments:
Description Flags
WIP patch
none
Patch none

Description Fujii Hironori 2021-06-15 00:44:02 PDT
Rewrite NetworkCache::Data::adoptMap not to use FileSystem::MappedFileData::leakHandle

Bug 227011 is going to add a file mapping handle to
FileSystem::MappedFileData for Windows port create a SharedMemory
from a MappedFileData. Destruction of MappedFileData should be
done only by MappedFileData dtor.
Comment 1 Fujii Hironori 2021-06-15 00:52:03 PDT
Created attachment 431411 [details]
WIP patch
Comment 2 Chris Dumez 2021-06-15 08:32:06 PDT
Comment on attachment 431411 [details]
WIP patch

View in context: https://bugs.webkit.org/attachment.cgi?id=431411&action=review

> Source/WebKit/NetworkProcess/cache/NetworkCacheDataCocoa.mm:98
> +    const void* map = mappedFile.data();

Which do you need to change Cocoa code? The new code is less efficient.
Comment 3 Fujii Hironori 2021-06-15 12:58:30 PDT
Comment on attachment 431411 [details]
WIP patch

View in context: https://bugs.webkit.org/attachment.cgi?id=431411&action=review

>> Source/WebKit/NetworkProcess/cache/NetworkCacheDataCocoa.mm:98
>> +    const void* map = mappedFile.data();
> 
> Which do you need to change Cocoa code? The new code is less efficient.

This change isn't technically a mandatory for Bug 227017.
I can keep FileSystem::MappedFileData::leakHande just for this.

Because Bug 227017 is going to add HANDLE of a file mapping to
MappedFileData, the combination of
FileSystem::MappedFileData::leakHande and
FileSystem::unmapViewOfFile is too problematic.
That's the reason I want to remove.

But, I can keep MappedFileData::leakHande by adding #if !OS(WINDOWS) if you like.
Comment 4 Chris Dumez 2021-06-15 12:59:33 PDT
(In reply to Fujii Hironori from comment #3)
> Comment on attachment 431411 [details]
> WIP patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=431411&action=review
> 
> >> Source/WebKit/NetworkProcess/cache/NetworkCacheDataCocoa.mm:98
> >> +    const void* map = mappedFile.data();
> > 
> > Which do you need to change Cocoa code? The new code is less efficient.
> 
> This change isn't technically a mandatory for Bug 227017.
> I can keep FileSystem::MappedFileData::leakHande just for this.
> 
> Because Bug 227017 is going to add HANDLE of a file mapping to
> MappedFileData, the combination of
> FileSystem::MappedFileData::leakHande and
> FileSystem::unmapViewOfFile is too problematic.
> That's the reason I want to remove.
> 
> But, I can keep MappedFileData::leakHande by adding #if !OS(WINDOWS) if you
> like.

I think that would be good, since the replacement Cocoa code wouldn't be as efficient otherwise.
Comment 5 Fujii Hironori 2021-06-15 13:01:17 PDT
OK. Thank you.
Comment 6 Fujii Hironori 2021-06-21 14:58:19 PDT
Reopened. I'm going to fix only NetworkCacheDataGLib.cpp.
Comment 7 Fujii Hironori 2021-06-21 17:57:45 PDT
Created attachment 431935 [details]
Patch
Comment 8 Fujii Hironori 2021-06-22 12:48:13 PDT
Comment on attachment 431935 [details]
Patch

Clearing flags on attachment: 431935

Committed r279137 (239049@main): <https://commits.webkit.org/239049@main>
Comment 9 Fujii Hironori 2021-06-22 12:48:17 PDT
All reviewed patches have been landed.  Closing bug.
Comment 10 Radar WebKit Bug Importer 2021-06-22 12:49:17 PDT
<rdar://problem/79628816>