Mercurial > hg > nginx
comparison src/core/ngx_open_file_cache.h @ 1453:f2feed5bffe1
open file cache
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Sat, 01 Sep 2007 12:11:21 +0000 |
parents | |
children | 223e92651ca5 |
comparison
equal
deleted
inserted
replaced
1452:cd586e963db0 | 1453:f2feed5bffe1 |
---|---|
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 | |
15 typedef struct { | |
16 ngx_fd_t fd; | |
17 ngx_file_uniq_t uniq; | |
18 time_t mtime; | |
19 off_t size; | |
20 ngx_err_t err; | |
21 | |
22 time_t retest; | |
23 | |
24 unsigned test_dir:1; | |
25 unsigned errors:1; | |
26 | |
27 unsigned is_dir:1; | |
28 unsigned is_file:1; | |
29 unsigned is_link:1; | |
30 unsigned is_exec:1; | |
31 } ngx_open_file_info_t; | |
32 | |
33 | |
34 typedef struct ngx_cached_open_file_s ngx_cached_open_file_t; | |
35 | |
36 struct ngx_cached_open_file_s { | |
37 ngx_rbtree_node_t node; | |
38 ngx_cached_open_file_t *prev; | |
39 ngx_cached_open_file_t *next; | |
40 | |
41 u_char *name; | |
42 time_t created; | |
43 time_t accessed; | |
44 | |
45 ngx_fd_t fd; | |
46 ngx_file_uniq_t uniq; | |
47 time_t mtime; | |
48 off_t size; | |
49 ngx_err_t err; | |
50 | |
51 unsigned count:24; | |
52 unsigned close:1; | |
53 | |
54 unsigned is_dir:1; | |
55 unsigned is_file:1; | |
56 unsigned is_link:1; | |
57 unsigned is_exec:1; | |
58 | |
59 ngx_event_t *event; | |
60 }; | |
61 | |
62 | |
63 typedef struct { | |
64 ngx_rbtree_t rbtree; | |
65 ngx_cached_open_file_t list_head; | |
66 ngx_cached_open_file_t list_tail; | |
67 | |
68 ngx_uint_t current; | |
69 ngx_uint_t max; | |
70 time_t inactive; | |
71 } ngx_open_file_cache_t; | |
72 | |
73 | |
74 typedef struct { | |
75 ngx_open_file_cache_t *cache; | |
76 ngx_cached_open_file_t *file; | |
77 ngx_log_t *log; | |
78 } ngx_open_file_cache_cleanup_t; | |
79 | |
80 | |
81 typedef struct { | |
82 | |
83 /* ngx_connection_t stub to allow use c->fd as event ident */ | |
84 void *data; | |
85 ngx_event_t *read; | |
86 ngx_event_t *write; | |
87 ngx_fd_t fd; | |
88 | |
89 ngx_cached_open_file_t *file; | |
90 ngx_open_file_cache_t *cache; | |
91 } ngx_open_file_cache_event_t; | |
92 | |
93 | |
94 ngx_open_file_cache_t *ngx_open_file_cache_init(ngx_pool_t *pool, | |
95 ngx_uint_t max, time_t inactive); | |
96 ngx_int_t ngx_open_cached_file(ngx_open_file_cache_t *cache, ngx_str_t *name, | |
97 ngx_open_file_info_t *of, ngx_pool_t *pool); | |
98 | |
99 | |
100 #endif /* _NGX_OPEN_FILE_CACHE_H_INCLUDED_ */ |