Back to home page

Nginx displayed by LXR

Source navigation ]
Diff markup ]
Identifier search ]
general search ]
 
 
Version: nginx-1.15.12 ]​[ nginx-1.16.0 ]​

0001 
0002 /*
0003  * Copyright (C) Igor Sysoev
0004  * Copyright (C) Nginx, Inc.
0005  */
0006 
0007 
0008 #include <ngx_config.h>
0009 #include <ngx_core.h>
0010 
0011 
0012 #ifndef _NGX_OPEN_FILE_CACHE_H_INCLUDED_
0013 #define _NGX_OPEN_FILE_CACHE_H_INCLUDED_
0014 
0015 
0016 #define NGX_OPEN_FILE_DIRECTIO_OFF  NGX_MAX_OFF_T_VALUE
0017 
0018 
0019 typedef struct {
0020     ngx_fd_t                 fd;
0021     ngx_file_uniq_t          uniq;
0022     time_t                   mtime;
0023     off_t                    size;
0024     off_t                    fs_size;
0025     off_t                    directio;
0026     size_t                   read_ahead;
0027 
0028     ngx_err_t                err;
0029     char                    *failed;
0030 
0031     time_t                   valid;
0032 
0033     ngx_uint_t               min_uses;
0034 
0035 #if (NGX_HAVE_OPENAT)
0036     size_t                   disable_symlinks_from;
0037     unsigned                 disable_symlinks:2;
0038 #endif
0039 
0040     unsigned                 test_dir:1;
0041     unsigned                 test_only:1;
0042     unsigned                 log:1;
0043     unsigned                 errors:1;
0044     unsigned                 events:1;
0045 
0046     unsigned                 is_dir:1;
0047     unsigned                 is_file:1;
0048     unsigned                 is_link:1;
0049     unsigned                 is_exec:1;
0050     unsigned                 is_directio:1;
0051 } ngx_open_file_info_t;
0052 
0053 
0054 typedef struct ngx_cached_open_file_s  ngx_cached_open_file_t;
0055 
0056 struct ngx_cached_open_file_s {
0057     ngx_rbtree_node_t        node;
0058     ngx_queue_t              queue;
0059 
0060     u_char                  *name;
0061     time_t                   created;
0062     time_t                   accessed;
0063 
0064     ngx_fd_t                 fd;
0065     ngx_file_uniq_t          uniq;
0066     time_t                   mtime;
0067     off_t                    size;
0068     ngx_err_t                err;
0069 
0070     uint32_t                 uses;
0071 
0072 #if (NGX_HAVE_OPENAT)
0073     size_t                   disable_symlinks_from;
0074     unsigned                 disable_symlinks:2;
0075 #endif
0076 
0077     unsigned                 count:24;
0078     unsigned                 close:1;
0079     unsigned                 use_event:1;
0080 
0081     unsigned                 is_dir:1;
0082     unsigned                 is_file:1;
0083     unsigned                 is_link:1;
0084     unsigned                 is_exec:1;
0085     unsigned                 is_directio:1;
0086 
0087     ngx_event_t             *event;
0088 };
0089 
0090 
0091 typedef struct {
0092     ngx_rbtree_t             rbtree;
0093     ngx_rbtree_node_t        sentinel;
0094     ngx_queue_t              expire_queue;
0095 
0096     ngx_uint_t               current;
0097     ngx_uint_t               max;
0098     time_t                   inactive;
0099 } ngx_open_file_cache_t;
0100 
0101 
0102 typedef struct {
0103     ngx_open_file_cache_t   *cache;
0104     ngx_cached_open_file_t  *file;
0105     ngx_uint_t               min_uses;
0106     ngx_log_t               *log;
0107 } ngx_open_file_cache_cleanup_t;
0108 
0109 
0110 typedef struct {
0111 
0112     /* ngx_connection_t stub to allow use c->fd as event ident */
0113     void                    *data;
0114     ngx_event_t             *read;
0115     ngx_event_t             *write;
0116     ngx_fd_t                 fd;
0117 
0118     ngx_cached_open_file_t  *file;
0119     ngx_open_file_cache_t   *cache;
0120 } ngx_open_file_cache_event_t;
0121 
0122 
0123 ngx_open_file_cache_t *ngx_open_file_cache_init(ngx_pool_t *pool,
0124     ngx_uint_t max, time_t inactive);
0125 ngx_int_t ngx_open_cached_file(ngx_open_file_cache_t *cache, ngx_str_t *name,
0126     ngx_open_file_info_t *of, ngx_pool_t *pool);
0127 
0128 
0129 #endif /* _NGX_OPEN_FILE_CACHE_H_INCLUDED_ */