Closed Bug 599200 Opened 14 years ago Closed 14 years ago

Too much space can be allocated for cache block files

Categories

(Core :: Networking: Cache, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla2.0b7
Tracking Status
blocking2.0 --- betaN+

People

(Reporter: michal, Assigned: michal)

Details

Attachments

(1 file, 1 obsolete file)

Fix in bug 592520 doesn't take into account maximal size of the cache block file.
Attached patch fix (obsolete) — Splinter Review
Attachment #478129 - Flags: review?(tglek)
blocking2.0: --- → ?
Attachment #478129 - Flags: review?(tglek) → review+
Keywords: checkin-needed
blocking2.0: ? → betaN+
Comment on attachment 478129 [details] [diff] [review]
fix

>diff --git a/netwerk/cache/nsDiskCacheBlockFile.cpp b/netwerk/cache/nsDiskCacheBlockFile.cpp

>+    // maximal file size
>+    const PRInt32 maxFileSize = kBitMapBytes * (mBlockSize * 8 + 1);
>     if (mFileSize < upTo) {
>         if (upTo > maxPreallocate) {
>             // grow the file as a multiple of minPreallocate
>             mFileSize = ((upTo + minPreallocate - 1) / minPreallocate) * minPreallocate;
>         } else {
>             // Grow quickly between 1MB to 20MB
>             if (mFileSize)
>                 while(mFileSize < upTo)
>                     mFileSize *= 2;
>             mFileSize = PR_MIN(maxPreallocate, PR_MAX(mFileSize, minPreallocate));
>         }
>-        mozilla::fallocate(mFD, mFileSize);
>+        mozilla::fallocate(mFD, PR_MIN(mFileSize, maxFileSize));

Nice catch.

Nit:  might as well put maxFileSize declaration/init within the if block so we don't calculate it when we don't use it.
Attached patch patch v2Splinter Review
(In reply to comment #2)
> Nit:  might as well put maxFileSize declaration/init within the if block so we
> don't calculate it when we don't use it.

Fixed. I've also changed it so that mFileSize now contains correct value.
Attachment #478129 - Attachment is obsolete: true
Checked in.

http://hg.mozilla.org/mozilla-central/rev/699b0f8d60e4
Status: NEW → RESOLVED
Closed: 14 years ago
Resolution: --- → FIXED
Keywords: checkin-needed
Target Milestone: --- → mozilla2.0b8
Target Milestone: mozilla2.0b8 → mozilla2.0b7
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: