What does open_file_cache_events do?

Costello nginx-forum at nginx.us
Wed May 12 14:57:24 MSD 2010


Hello,

I'm looking to document directives that are missing from the Wiki.
I found loads in the source code, especially thanks to Manlio Perillo.

I've stumbled upon "open_file_cache_events" declared in ngx_http_core_module.c.
I investigated what this does, here is what I found:
- it's a on/off directive
- it's off by default
- its main purpose is from 1 file, ngx_open_file_cache.c

That's where it's mostly used:
[code]
/*
 * we ignore any possible event setting error and
 * fallback to usual periodic file retests
 */

static void
ngx_open_file_add_event(ngx_open_file_cache_t *cache,
    ngx_cached_open_file_t *file, ngx_open_file_info_t *of, ngx_log_t *log)
{
    ngx_open_file_cache_event_t  *fev;

    if (!(ngx_event_flags & NGX_USE_VNODE_EVENT)
        || !of->events
        || file->event
        || of->fd == NGX_INVALID_FILE
        || file->uses < of->min_uses)
    {
        return;
    }
[/code]

basically of->events takes the value of open_file_cache_events before this function is called.
When called, if of->events is false, the flow returns immediately and the function is not processed.
So it prevents Nginx from "adding an event", I presume for the specified file.

Now I understand what the open file cache does, but I don't understand what exactly what this directive does.
When the directive is enabled, does Nginx process some kind of event-based cache invalidation?
Eg. Nginx would subscribe to events for this file, when the file is deleted, Nginx gets notified with an event, and then updates the cache entry?

Thanks a lot in advance for helping me clear it out!

Best regards,
Costello

Posted at Nginx Forum: http://forum.nginx.org/read.php?2,85785,85785#msg-85785




More information about the nginx mailing list