Mercurial > hg > nginx-quic
annotate src/core/ngx_open_file_cache.h @ 4427:7c718f5416eb
release-1.1.14 tag
author | Maxim Dounin <mdounin@mdounin.ru> |
---|---|
date | Mon, 30 Jan 2012 13:52:35 +0000 |
parents | d620f497c50f |
children | 7033faf6dc3c |
rev | line source |
---|---|
1453 | 1 |
2 /* | |
3 * Copyright (C) Igor Sysoev | |
4412 | 4 * Copyright (C) Nginx, Inc. |
1453 | 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 | |
2277 | 16 #define NGX_OPEN_FILE_DIRECTIO_OFF NGX_MAX_OFF_T_VALUE |
17 | |
18 | |
1453 | 19 typedef struct { |
20 ngx_fd_t fd; | |
21 ngx_file_uniq_t uniq; | |
22 time_t mtime; | |
23 off_t size; | |
3899
e7cd13b7f759
Use more precise stat.st_blocks to account cache size on Unix
Igor Sysoev <igor@sysoev.ru>
parents:
3178
diff
changeset
|
24 off_t fs_size; |
2129 | 25 off_t directio; |
3178 | 26 size_t read_ahead; |
2756
09cab3f8d92e
*) of.test_only to not open file if only stat() is enough
Igor Sysoev <igor@sysoev.ru>
parents:
2277
diff
changeset
|
27 |
1453 | 28 ngx_err_t err; |
2756
09cab3f8d92e
*) of.test_only to not open file if only stat() is enough
Igor Sysoev <igor@sysoev.ru>
parents:
2277
diff
changeset
|
29 char *failed; |
1453 | 30 |
1767
c42431762903
open_file_cache_retest > open_file_cache_valid
Igor Sysoev <igor@sysoev.ru>
parents:
1765
diff
changeset
|
31 time_t valid; |
1453 | 32 |
1772 | 33 ngx_uint_t min_uses; |
34 | |
1453 | 35 unsigned test_dir:1; |
2756
09cab3f8d92e
*) of.test_only to not open file if only stat() is enough
Igor Sysoev <igor@sysoev.ru>
parents:
2277
diff
changeset
|
36 unsigned test_only:1; |
2072 | 37 unsigned log:1; |
1453 | 38 unsigned errors:1; |
1457 | 39 unsigned events:1; |
1453 | 40 |
41 unsigned is_dir:1; | |
42 unsigned is_file:1; | |
43 unsigned is_link:1; | |
44 unsigned is_exec:1; | |
2231
8564129d49b6
*) handle unaligned file part for directio
Igor Sysoev <igor@sysoev.ru>
parents:
2129
diff
changeset
|
45 unsigned is_directio:1; |
1453 | 46 } ngx_open_file_info_t; |
47 | |
48 | |
49 typedef struct ngx_cached_open_file_s ngx_cached_open_file_t; | |
50 | |
51 struct ngx_cached_open_file_s { | |
52 ngx_rbtree_node_t node; | |
1765 | 53 ngx_queue_t queue; |
1453 | 54 |
55 u_char *name; | |
56 time_t created; | |
57 time_t accessed; | |
58 | |
59 ngx_fd_t fd; | |
60 ngx_file_uniq_t uniq; | |
61 time_t mtime; | |
62 off_t size; | |
63 ngx_err_t err; | |
64 | |
1772 | 65 uint32_t uses; |
66 | |
1453 | 67 unsigned count:24; |
68 unsigned close:1; | |
1775 | 69 unsigned use_event:1; |
1453 | 70 |
71 unsigned is_dir:1; | |
72 unsigned is_file:1; | |
73 unsigned is_link:1; | |
74 unsigned is_exec:1; | |
2246
987831d73bd8
cache directio flag in open file cache
Igor Sysoev <igor@sysoev.ru>
parents:
2231
diff
changeset
|
75 unsigned is_directio:1; |
1453 | 76 |
77 ngx_event_t *event; | |
78 }; | |
79 | |
80 | |
81 typedef struct { | |
82 ngx_rbtree_t rbtree; | |
1761 | 83 ngx_rbtree_node_t sentinel; |
1765 | 84 ngx_queue_t expire_queue; |
1453 | 85 |
86 ngx_uint_t current; | |
87 ngx_uint_t max; | |
88 time_t inactive; | |
89 } ngx_open_file_cache_t; | |
90 | |
91 | |
92 typedef struct { | |
93 ngx_open_file_cache_t *cache; | |
94 ngx_cached_open_file_t *file; | |
1772 | 95 ngx_uint_t min_uses; |
1453 | 96 ngx_log_t *log; |
97 } ngx_open_file_cache_cleanup_t; | |
98 | |
99 | |
100 typedef struct { | |
101 | |
102 /* ngx_connection_t stub to allow use c->fd as event ident */ | |
103 void *data; | |
104 ngx_event_t *read; | |
105 ngx_event_t *write; | |
106 ngx_fd_t fd; | |
107 | |
108 ngx_cached_open_file_t *file; | |
109 ngx_open_file_cache_t *cache; | |
110 } ngx_open_file_cache_event_t; | |
111 | |
112 | |
113 ngx_open_file_cache_t *ngx_open_file_cache_init(ngx_pool_t *pool, | |
114 ngx_uint_t max, time_t inactive); | |
115 ngx_int_t ngx_open_cached_file(ngx_open_file_cache_t *cache, ngx_str_t *name, | |
116 ngx_open_file_info_t *of, ngx_pool_t *pool); | |
117 | |
118 | |
119 #endif /* _NGX_OPEN_FILE_CACHE_H_INCLUDED_ */ |