332
|
1
|
|
2 /*
|
|
3 * Copyright (C) Igor Sysoev
|
660
|
4 * Copyright (C) Nginx, Inc.
|
332
|
5 */
|
|
6
|
|
7
|
|
8 #include <ngx_config.h>
|
|
9 #include <ngx_core.h>
|
|
10
|
|
11
|
|
12 #ifndef _NGX_OPEN_FILE_CACHE_H_INCLUDED_
|
|
13 #define _NGX_OPEN_FILE_CACHE_H_INCLUDED_
|
|
14
|
|
15
|
416
|
16 #define NGX_OPEN_FILE_DIRECTIO_OFF NGX_MAX_OFF_T_VALUE
|
|
17
|
|
18
|
332
|
19 typedef struct {
|
|
20 ngx_fd_t fd;
|
|
21 ngx_file_uniq_t uniq;
|
|
22 time_t mtime;
|
|
23 off_t size;
|
622
|
24 off_t fs_size;
|
390
|
25 off_t directio;
|
532
|
26 size_t read_ahead;
|
482
|
27
|
332
|
28 ngx_err_t err;
|
482
|
29 char *failed;
|
332
|
30
|
358
|
31 time_t valid;
|
|
32
|
|
33 ngx_uint_t min_uses;
|
332
|
34
|
662
|
35 #if (NGX_HAVE_OPENAT)
|
|
36 unsigned disable_symlinks:2;
|
|
37 #endif
|
|
38
|
332
|
39 unsigned test_dir:1;
|
482
|
40 unsigned test_only:1;
|
384
|
41 unsigned log:1;
|
332
|
42 unsigned errors:1;
|
|
43 unsigned events:1;
|
|
44
|
|
45 unsigned is_dir:1;
|
|
46 unsigned is_file:1;
|
|
47 unsigned is_link:1;
|
|
48 unsigned is_exec:1;
|
406
|
49 unsigned is_directio:1;
|
332
|
50 } ngx_open_file_info_t;
|
|
51
|
|
52
|
|
53 typedef struct ngx_cached_open_file_s ngx_cached_open_file_t;
|
|
54
|
|
55 struct ngx_cached_open_file_s {
|
|
56 ngx_rbtree_node_t node;
|
358
|
57 ngx_queue_t queue;
|
332
|
58
|
|
59 u_char *name;
|
|
60 time_t created;
|
|
61 time_t accessed;
|
|
62
|
|
63 ngx_fd_t fd;
|
|
64 ngx_file_uniq_t uniq;
|
|
65 time_t mtime;
|
|
66 off_t size;
|
|
67 ngx_err_t err;
|
|
68
|
358
|
69 uint32_t uses;
|
|
70
|
662
|
71 #if (NGX_HAVE_OPENAT)
|
|
72 unsigned disable_symlinks:2;
|
|
73 #endif
|
|
74
|
332
|
75 unsigned count:24;
|
|
76 unsigned close:1;
|
358
|
77 unsigned use_event:1;
|
332
|
78
|
|
79 unsigned is_dir:1;
|
|
80 unsigned is_file:1;
|
|
81 unsigned is_link:1;
|
|
82 unsigned is_exec:1;
|
410
|
83 unsigned is_directio:1;
|
332
|
84
|
|
85 ngx_event_t *event;
|
|
86 };
|
|
87
|
|
88
|
|
89 typedef struct {
|
|
90 ngx_rbtree_t rbtree;
|
358
|
91 ngx_rbtree_node_t sentinel;
|
|
92 ngx_queue_t expire_queue;
|
332
|
93
|
|
94 ngx_uint_t current;
|
|
95 ngx_uint_t max;
|
|
96 time_t inactive;
|
|
97 } ngx_open_file_cache_t;
|
|
98
|
|
99
|
|
100 typedef struct {
|
|
101 ngx_open_file_cache_t *cache;
|
|
102 ngx_cached_open_file_t *file;
|
358
|
103 ngx_uint_t min_uses;
|
332
|
104 ngx_log_t *log;
|
|
105 } ngx_open_file_cache_cleanup_t;
|
|
106
|
|
107
|
|
108 typedef struct {
|
|
109
|
|
110 /* ngx_connection_t stub to allow use c->fd as event ident */
|
|
111 void *data;
|
|
112 ngx_event_t *read;
|
|
113 ngx_event_t *write;
|
|
114 ngx_fd_t fd;
|
|
115
|
|
116 ngx_cached_open_file_t *file;
|
|
117 ngx_open_file_cache_t *cache;
|
|
118 } ngx_open_file_cache_event_t;
|
|
119
|
|
120
|
|
121 ngx_open_file_cache_t *ngx_open_file_cache_init(ngx_pool_t *pool,
|
|
122 ngx_uint_t max, time_t inactive);
|
|
123 ngx_int_t ngx_open_cached_file(ngx_open_file_cache_t *cache, ngx_str_t *name,
|
|
124 ngx_open_file_info_t *of, ngx_pool_t *pool);
|
|
125
|
|
126
|
|
127 #endif /* _NGX_OPEN_FILE_CACHE_H_INCLUDED_ */
|