summaryrefslogtreecommitdiffhomepage
path: root/src/http/ngx_http_file_cache.c (follow)
AgeCommit message (Collapse)AuthorFilesLines
2014-09-05Upstream: suppressed the file cache slab allocator error messages.Roman Arutyunyan1-0/+4
The messages "ngx_slab_alloc() failed: no memory in cache keys zone" from the file cache slab allocator are suppressed since the allocation is likely to succeed after the forced expiration of cache nodes. The second allocation failure is reported.
2014-06-26Cache: ETag now saved into cache header.Maxim Dounin1-0/+12
2014-06-26Cache: version in cache files.Maxim Dounin1-1/+10
This allows to change the structure of cache files without spamming logs with false alerts.
2014-06-04Core: added ngx_slab_calloc() and ngx_slab_calloc_locked().Ruslan Ermilov1-16/+6
These functions return zeroed memory, analogous to ngx_pcalloc().
2014-04-30Cache: added ngx_quit check to ngx_http_file_cache_expire().Maxim Dounin1-0/+5
While managing big caches it is possible that expiring old cache items in ngx_http_file_cache_expire() will take a while. Added a check for ngx_quit / ngx_terminate to make sure cache manager can be terminated while in ngx_http_file_cache_expire().
2013-11-18Upstream: cache revalidation with conditional requests.Maxim Dounin1-0/+111
The following new directives are introduced: proxy_cache_revalidate, fastcgi_cache_revalidate, scgi_cache_revalidate, uwsgi_cache_revalidate. Default is off. When set to on, they enable cache revalidation using conditional requests with If-Modified-Since for expired cache items. As of now, no attempts are made to merge headers given in a 304 response during cache revalidation with headers previously stored in a cache item. Headers in a 304 response are only used to calculate new validity time of a cache item.
2013-09-04Win32: Borland C compatibility fixes.Maxim Dounin1-1/+1
Several false positive warnings silenced, notably W8012 "Comparing signed and unsigned" (due to u_short values promoted to int), and W8072 "Suspicious pointer arithmetic" (due to large type values added to pointers). With this patch, it's now again possible to compile nginx using bcc32, with options we normally compile on win32 minus ipv6 and ssl.
2013-08-23Cache: lock timeouts are now logged at info level.Maxim Dounin1-2/+1
2013-08-20Backed out f1a91825730a and 7094bd12c1ff.Maxim Dounin1-3/+1
While ngx_get_full_name() might have a bit more descriptive arguments, the ngx_conf_full_name() is generally easier to use when parsing configuration and limits exposure of cycle->prefix / cycle->conf_prefix details.
2013-08-06Replaced ngx_conf_full_name() with ngx_get_full_name().Valentin Bartenev1-1/+3
The ngx_get_full_name() function takes more readable arguments list.
2013-06-05Valgrind: supressed complaints about uninitialized bytes.Maxim Dounin1-0/+2
Valgrind complains if we pass uninitialized memory to a syscall: ==36492== Syscall param sendmsg(msg.msg_iov[0]) points to uninitialised byte(s) ==36492== at 0x6B5E6A: sendmsg (in /usr/lib/system/libsystem_kernel.dylib) ==36492== by 0x10004288E: ngx_signal_worker_processes (ngx_process_cycle.c:527) ==36492== by 0x1000417A7: ngx_master_process_cycle (ngx_process_cycle.c:203) ==36492== by 0x100001F10: main (nginx.c:410) ==36492== Address 0x7fff5fbff71c is on thread 1's stack Even initialization of all members of the structure passed isn't enough, as there is padding which still remains uninitialized and results in Valgrind complaint. Note there is no real problem here as data from uninitialized memory isn't used.
2013-02-19Removed zero termination of shm zone names.Valentin Bartenev1-2/+0
It was added in r2717 and no longer needed since r2721, where the termination was added to ngx_shm_alloc() and ngx_init_zone_pool(). So then it only corrupts error messages about ivalid zones.
2012-02-27Fix of rbtree lookup on hash collisions.Maxim Dounin1-12/+7
Previous code incorrectly assumed that nodes with identical keys are linked together. This might not be true after tree rebalance. Patch by Lanshun Zhou.
2012-02-13Time parsing cleanup.Maxim Dounin1-7/+8
Nuke NGX_PARSE_LARGE_TIME, it's not used since 0.6.30. The only error ngx_parse_time() can currently return is NGX_ERROR, check it explicitly and make sure to cast it to appropriate type (either time_t or ngx_msec_t) to avoid signedness warnings on platforms with unsigned time_t (notably QNX).
2012-01-18Copyright updated.Maxim Konovalov1-0/+1
2011-12-26Fixed build without debug.Maxim Dounin1-2/+2
2011-12-26Cache locks initial implementation.Maxim Dounin1-14/+145
New directives: proxy_cache_lock on/off, proxy_cache_lock_timeout. With proxy_cache_lock set to on, only one request will be allowed to go to upstream for a particular cache item. Others will wait for a response to appear in cache (or cache lock released) up to proxy_cache_lock_timeout. Waiting requests will recheck if they have cached response ready (or are allowed to run) every 500ms. Note: we intentionally don't intercept NGX_DECLINED possibly returned by ngx_http_file_cache_read(). This needs more work (possibly safe, but needs further investigation). Anyway, it's exceptional situation. Note: probably there should be a way to disable caching of responses if there is already one request fetching resource to cache (without waiting at all). Two possible ways include another cache lock option ("no_cache") or using proxy_no_cache with some supplied variable. Note: probably there should be a way to lock updating requests as well. For now "proxy_cache_use_stale updating" is available.
2011-12-12Cache: only complain on long locked entries.Maxim Dounin1-3/+3
There have been multiple reports of cases where a real locked entry was removed, resulting in a segmentation fault later in a worker which locked the entry. It looks like default inactive timeout isn't enough in real life. For now just ignore such locked entries, and move them to the top of the inactive queue to allow processing of other entries.
2011-12-12Cache: handling of cache files with long headers.Maxim Dounin1-0/+7
There are two possible situations which can lead to this: response was cached with bigger proxy_buffer_size value (and nginx was restared since then, i.e. shared memory zone content was lost), or due to the race in the cache update code (see [1]) we've end up with fcn->body_start from a different response stored in shared memory zone. [1] http://mailman.nginx.org/pipermail/nginx-devel/2011-September/001287.html
2011-12-12Cache: obsolete code removed.Maxim Dounin1-66/+0
The ngx_http_cache() and ngx_http_no_cache_set_slot() functions were replaced by ngx_http_test_predicates() and ngx_http_set_predicate_slot() in 0.8.46 and no longer used since then.
2011-09-27Cache: fix for sending of empty responses.Maxim Dounin1-3/+5
Revert wrong fix for empty responses introduced in 0.8.31 and apply new one, rewritten to match things done by static module as close as possible.
2011-08-25Cache size accounting fix: actual cache size on disk was less thanIgor Sysoev1-0/+1
needed by sum of sizes of files loaded by worker processes themselves while cache loader was running. The bug has been introduced in r3900.
2011-08-22The change in adaptive loader behaviour introduced in r3975:Igor Sysoev1-40/+26
now cache loader processes either as many files as specified by loader_files or works no more than time specified by loader_threshold during each iteration. loader_threshold was previously used to decrease loader_files or to increase loader_timeout and this might eventually result in downgrading loader_files to 1 and increasing loader_timeout to large values causing loading cache for forever.
2011-07-29loader_files, loader_sleep, and loader_thresholdIgor Sysoev1-11/+67
2011-07-25set correct configuration file values while adding pathIgor Sysoev1-0/+2
patch by Maxim Dounin
2011-07-25rename ngx_http_file_cache_manager_sleep() to ngx_http_file_cache_loader_sleep()Igor Sysoev1-4/+4
and do not use it all in cache manager: this is a vestige of the times when cache manager loaded cache
2011-07-24do not close connection if cache file is too small: replace it with valid oneIgor Sysoev1-1/+1
2011-07-24elimination of reading cache files by cache loaderIgor Sysoev1-42/+9
2011-07-24fix r3968Igor Sysoev1-1/+1
2011-07-24update the previous commit:Igor Sysoev1-2/+1
removing dependencies on file uniq since WIN32_FIND_DATA has no such field
2011-07-24The cache loader performs two tasks: inserting cache objects in inactivityIgor Sysoev1-11/+6
list and evaluating total cache size. Reading just directory is enough for this purpose. Elimination of reading cache files saves at least one disk I/O operation per file. Preparation for elimination of reading cache files by cache loader: removing dependencies on the reading: *) cache node valid_sec and valid_msec are used only for caching errors; *) upstream buffer size can be used instead of cache node body_start.
2011-07-24fuse two if's in one conditionIgor Sysoev1-11/+2
2011-07-24style fixIgor Sysoev1-1/+1
2011-07-19fix r3756: release lock to allow other process to delete cache nodeIgor Sysoev1-1/+2
patch by Maxim Dounin
2011-05-13fix a broken cached response if bypass/no_cache directive values are different,Igor Sysoev1-3/+1
the bug has been introduced in r3700
2011-04-22Use more precise stat.st_blocks to account cache size on UnixIgor Sysoev1-17/+14
instead of file length rounded to a file system block size. There is no similar way on Windows, so rounding to a cache->bsize is kept.
2011-04-08fix CPU hog in cache managerIgor Sysoev1-2/+7
patch by Maxim Dounin
2010-09-02fix race condition if during reconfiguration two cache managers tryIgor Sysoev1-0/+8
to delete old inactive entries: one of them removes a entry just locked by other manager from the queue and the rbtree as long inactive entry, causes the latter manager to segfault leaving cache mutex locked, the bug has been introduced in r3727
2010-08-04zero fcn->updating after node allocationIgor Sysoev1-0/+2
2010-08-04error status codes could be cached for next request only,Igor Sysoev1-2/+5
the bug has been introduced in r3712
2010-08-03delete surplus assignmentIgor Sysoev1-2/+0
2010-08-02change logic slightlyIgor Sysoev1-2/+2
2010-08-02change orderIgor Sysoev1-27/+22
2010-08-02*) delete cache key node after a cache file removalIgor Sysoev1-41/+26
*) move fileless cache key node removal in ngx_http_file_cache_delete()
2010-07-30count cache key node usage for cached error statusesIgor Sysoev1-5/+6
2010-07-30do not free unused cache node if cache min_uses > 1,Igor Sysoev1-1/+1
the bug has been introduced in r3695, r3708, r3711
2010-07-28move debug logging inside ngx_http_file_cache_free()Igor Sysoev1-2/+2
2010-07-28several changes in cache cleanup handling:Igor Sysoev1-23/+17
*) now ngx_http_file_cache_cleanup() uses ngx_http_file_cache_free() *) ngx_http_file_cache_free() interface has been changed to accept r->cache ngx_http_file_cache_cleanup() must use r->cache, but not r, because there can be several r->cache's during request processing, r->cache may be NULL at request finalising, etc. *) test if updating request does not complete correctly
2010-07-27fix r3708 and r3695: valid_sec is set only for caching error status codesIgor Sysoev1-1/+1
2010-07-27fix r3695: this commitIgor Sysoev1-1/+1
*) freed valid keys zone node *) and did not decrease cache size, so cache manager process ete CPU time, if cache checking max_size was enabled