Skip to content

Commit 19512f7

Browse files
[DiskCache] Disable HTTP disk cache if not enouhg disk space
Hidden behind WPE_DISK_CACHE_SIZE env There is no control over available disk space for HTTP network cache. Entries are written to disk asynchronously (using file memory mapping) so lack of disk space results with SIGBUS signal and WPENetworkProcess crash.
1 parent 2f546bf commit 19512f7

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

Source/WebKit/Shared/CacheModel.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
#include "CacheModel.h"
2828

2929
#include <algorithm>
30+
#include <wtf/Assertions.h>
3031
#include <wtf/RAMSize.h>
3132
#include <wtf/Seconds.h>
3233
#include <wtf/StdLibExtras.h>
@@ -183,8 +184,12 @@ uint64_t calculateURLCacheDiskCapacity(CacheModel cacheModel, uint64_t diskFreeS
183184
if (units != 1)
184185
value = value.substring(0, value.length()-1);
185186

186-
size_t size = size_t(parseInteger<uint64_t>(value).value_or(0) * units);
187-
urlCacheDiskCapacity = (unsigned long)(size);
187+
urlCacheDiskCapacity = parseInteger<uint64_t>(value).value_or(0) * units;
188+
if (urlCacheDiskCapacity > diskFreeSize * MB) {
189+
WTFLogAlways("Disabling cache due to lack of disk space (wanted space: %ju, disk free space: %ju [bytes])",
190+
urlCacheDiskCapacity, diskFreeSize * MB);
191+
urlCacheDiskCapacity = 0;
192+
}
188193
}
189194

190195
return urlCacheDiskCapacity;

0 commit comments

Comments
 (0)