From 0a683fdd9313b9796bf39442fd117beaa63a7157 Mon Sep 17 00:00:00 2001 From: Maxim Dounin Date: Mon, 22 Jun 2020 18:03:00 +0300 Subject: Cache: introduced min_free cache clearing. Clearing cache based on free space left on a file system is expected to allow better disk utilization in some cases, notably when disk space might be also used for something other than nginx cache (including nginx own temporary files) and while loading cache (when cache size might be inaccurate for a while, effectively disabling max_size cache clearing). Based on a patch by Adam Bambuch. --- src/os/win32/ngx_files.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'src/os/win32/ngx_files.c') diff --git a/src/os/win32/ngx_files.c b/src/os/win32/ngx_files.c index 0b131b58a..3017b45fe 100644 --- a/src/os/win32/ngx_files.c +++ b/src/os/win32/ngx_files.c @@ -658,6 +658,19 @@ ngx_fs_bsize(u_char *name) } +off_t +ngx_fs_available(u_char *name) +{ + ULARGE_INTEGER navail; + + if (GetDiskFreeSpaceEx((const char *) name, &navail, NULL, NULL) == 0) { + return NGX_MAX_OFF_T_VALUE; + } + + return (off_t) navail.QuadPart; +} + + static ngx_int_t ngx_win32_check_filename(u_char *name, u_short *u, size_t len) { -- cgit v1.2.3