Mercurial > hg > nginx-quic
annotate src/core/ngx_open_file_cache.h @ 3414:cc327fa82f63
bump version
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Thu, 28 Jan 2010 08:22:45 +0000 |
parents | 975f0558aab3 |
children | e7cd13b7f759 |
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; |
3178 | 24 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
|
25 |
1453 | 26 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
|
27 char *failed; |
1453 | 28 |
1767
c42431762903
open_file_cache_retest > open_file_cache_valid
Igor Sysoev <igor@sysoev.ru>
parents:
1765
diff
changeset
|
29 time_t valid; |
1453 | 30 |
1772 | 31 ngx_uint_t min_uses; |
32 | |
1453 | 33 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
|
34 unsigned test_only:1; |
2072 | 35 unsigned log:1; |
1453 | 36 unsigned errors:1; |
1457 | 37 unsigned events:1; |
1453 | 38 |
39 unsigned is_dir:1; | |
40 unsigned is_file:1; | |
41 unsigned is_link:1; | |
42 unsigned is_exec:1; | |
2231
8564129d49b6
*) handle unaligned file part for directio
Igor Sysoev <igor@sysoev.ru>
parents:
2129
diff
changeset
|
43 unsigned is_directio:1; |
1453 | 44 } ngx_open_file_info_t; |
45 | |
46 | |
47 typedef struct ngx_cached_open_file_s ngx_cached_open_file_t; | |
48 | |
49 struct ngx_cached_open_file_s { | |
50 ngx_rbtree_node_t node; | |
1765 | 51 ngx_queue_t queue; |
1453 | 52 |
53 u_char *name; | |
54 time_t created; | |
55 time_t accessed; | |
56 | |
57 ngx_fd_t fd; | |
58 ngx_file_uniq_t uniq; | |
59 time_t mtime; | |
60 off_t size; | |
61 ngx_err_t err; | |
62 | |
1772 | 63 uint32_t uses; |
64 | |
1453 | 65 unsigned count:24; |
66 unsigned close:1; | |
1775 | 67 unsigned use_event:1; |
1453 | 68 |
69 unsigned is_dir:1; | |
70 unsigned is_file:1; | |
71 unsigned is_link:1; | |
72 unsigned is_exec:1; | |
2246
987831d73bd8
cache directio flag in open file cache
Igor Sysoev <igor@sysoev.ru>
parents:
2231
diff
changeset
|
73 unsigned is_directio:1; |
1453 | 74 |
75 ngx_event_t *event; | |
76 }; | |
77 | |
78 | |
79 typedef struct { | |
80 ngx_rbtree_t rbtree; | |
1761 | 81 ngx_rbtree_node_t sentinel; |
1765 | 82 ngx_queue_t expire_queue; |
1453 | 83 |
84 ngx_uint_t current; | |
85 ngx_uint_t max; | |
86 time_t inactive; | |
87 } ngx_open_file_cache_t; | |
88 | |
89 | |
90 typedef struct { | |
91 ngx_open_file_cache_t *cache; | |
92 ngx_cached_open_file_t *file; | |
1772 | 93 ngx_uint_t min_uses; |
1453 | 94 ngx_log_t *log; |
95 } ngx_open_file_cache_cleanup_t; | |
96 | |
97 | |
98 typedef struct { | |
99 | |
100 /* ngx_connection_t stub to allow use c->fd as event ident */ | |
101 void *data; | |
102 ngx_event_t *read; | |
103 ngx_event_t *write; | |
104 ngx_fd_t fd; | |
105 | |
106 ngx_cached_open_file_t *file; | |
107 ngx_open_file_cache_t *cache; | |
108 } ngx_open_file_cache_event_t; | |
109 | |
110 | |
111 ngx_open_file_cache_t *ngx_open_file_cache_init(ngx_pool_t *pool, | |
112 ngx_uint_t max, time_t inactive); | |
113 ngx_int_t ngx_open_cached_file(ngx_open_file_cache_t *cache, ngx_str_t *name, | |
114 ngx_open_file_info_t *of, ngx_pool_t *pool); | |
115 | |
116 | |
117 #endif /* _NGX_OPEN_FILE_CACHE_H_INCLUDED_ */ |