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