Bug 183051 - [Curl] Cookie Database files are wrongfully getting deleted when the database is opened
Summary: [Curl] Cookie Database files are wrongfully getting deleted when the database...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Platform (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2018-02-22 12:12 PST by Christopher Reid
Modified: 2018-02-23 18:02 PST (History)
11 users (show)

See Also:


Attachments
Patch (1.86 KB, patch)
2018-02-22 12:19 PST, Christopher Reid
no flags Details | Formatted Diff | Diff
Patch (1.84 KB, patch)
2018-02-23 14:25 PST, Christopher Reid
no flags Details | Formatted Diff | Diff
Patch for landing (2.02 KB, patch)
2018-02-23 16:03 PST, Christopher Reid
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Christopher Reid 2018-02-22 12:12:25 PST
The file stat logic in CookieJarDB::checkDatabaseCorruptionAndRemoveIfNeeded is backwards causing persistence issues. The database is wrongfully deleted when opened because it thinks it's corrupted.
Comment 1 Christopher Reid 2018-02-22 12:19:40 PST
Created attachment 334465 [details]
Patch
Comment 2 Don Olmstead 2018-02-23 12:51:10 PST
Comment on attachment 334465 [details]
Patch

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

LGTM. I'm not sure how liberally we should be using auto or not.

> Source/WebCore/platform/network/curl/CookieJarDB.cpp:166
> +    FileSystem::PlatformFileHandle handle = FileSystem::openFile(getCorruptionMarkerPath(), FileSystem::FileOpenMode::Write);

Maybe auto here?
Comment 3 Christopher Reid 2018-02-23 14:01:36 PST
(In reply to Don Olmstead from comment #2)
> Comment on attachment 334465 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=334465&action=review
> 
> LGTM. I'm not sure how liberally we should be using auto or not.
> 
> > Source/WebCore/platform/network/curl/CookieJarDB.cpp:166
> > +    FileSystem::PlatformFileHandle handle = FileSystem::openFile(getCorruptionMarkerPath(), FileSystem::FileOpenMode::Write);
> 
> Maybe auto here?

It looks like auto is used quite a bit with openFile in the FileSystem implementation files so it makes sense to use it here too.
I'll update the patch.
Comment 4 Christopher Reid 2018-02-23 14:25:28 PST
Created attachment 334547 [details]
Patch
Comment 5 Per Arne Vollan 2018-02-23 15:15:10 PST
Comment on attachment 334547 [details]
Patch

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

R=me.

> Source/WebCore/platform/network/curl/CookieJarDB.cpp:167
> +    FileSystem::closeFile(handle);

Should we check whether 'handle' is valid before closing?
Comment 6 Christopher Reid 2018-02-23 15:55:02 PST
Thanks for the review!

(In reply to Per Arne Vollan from comment #5)
> Comment on attachment 334547 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=334547&action=review
> 
> R=me.
> 
> > Source/WebCore/platform/network/curl/CookieJarDB.cpp:167
> > +    FileSystem::closeFile(handle);
> 
> Should we check whether 'handle' is valid before closing?

Ah, right now all the closeFile implementations have a check but it seems safer to have a check here too in case more functionality is added to that file.
Comment 7 Christopher Reid 2018-02-23 16:03:52 PST
Created attachment 334550 [details]
Patch for landing
Comment 8 WebKit Commit Bot 2018-02-23 18:01:41 PST
Comment on attachment 334550 [details]
Patch for landing

Clearing flags on attachment: 334550

Committed r228971: <https://trac.webkit.org/changeset/228971>
Comment 9 WebKit Commit Bot 2018-02-23 18:01:42 PST
All reviewed patches have been landed.  Closing bug.
Comment 10 Radar WebKit Bug Importer 2018-02-23 18:02:59 PST
<rdar://problem/37846254>