nginx 0.7.4
[nginx-catap.git] / src / core / ngx_open_file_cache.h
blob4d8393b5d09168ae9f44e77eed52bf63d154ead7
2 /*
3 * Copyright (C) Igor Sysoev
4 */
7 #include <ngx_config.h>
8 #include <ngx_core.h>
11 #ifndef _NGX_OPEN_FILE_CACHE_H_INCLUDED_
12 #define _NGX_OPEN_FILE_CACHE_H_INCLUDED_
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;
22 time_t valid;
24 ngx_uint_t min_uses;
26 unsigned test_dir:1;
27 unsigned log:1;
28 unsigned errors:1;
29 unsigned events:1;
31 unsigned is_dir:1;
32 unsigned is_file:1;
33 unsigned is_link:1;
34 unsigned is_exec:1;
35 } ngx_open_file_info_t;
38 typedef struct ngx_cached_open_file_s ngx_cached_open_file_t;
40 struct ngx_cached_open_file_s {
41 ngx_rbtree_node_t node;
42 ngx_queue_t queue;
44 u_char *name;
45 time_t created;
46 time_t accessed;
48 ngx_fd_t fd;
49 ngx_file_uniq_t uniq;
50 time_t mtime;
51 off_t size;
52 ngx_err_t err;
54 uint32_t uses;
56 unsigned count:24;
57 unsigned close:1;
58 unsigned use_event:1;
60 unsigned is_dir:1;
61 unsigned is_file:1;
62 unsigned is_link:1;
63 unsigned is_exec:1;
65 ngx_event_t *event;
69 typedef struct {
70 ngx_rbtree_t rbtree;
71 ngx_rbtree_node_t sentinel;
72 ngx_queue_t expire_queue;
74 ngx_uint_t current;
75 ngx_uint_t max;
76 time_t inactive;
77 } ngx_open_file_cache_t;
80 typedef struct {
81 ngx_open_file_cache_t *cache;
82 ngx_cached_open_file_t *file;
83 ngx_uint_t min_uses;
84 ngx_log_t *log;
85 } ngx_open_file_cache_cleanup_t;
88 typedef struct {
90 /* ngx_connection_t stub to allow use c->fd as event ident */
91 void *data;
92 ngx_event_t *read;
93 ngx_event_t *write;
94 ngx_fd_t fd;
96 ngx_cached_open_file_t *file;
97 ngx_open_file_cache_t *cache;
98 } ngx_open_file_cache_event_t;
101 ngx_open_file_cache_t *ngx_open_file_cache_init(ngx_pool_t *pool,
102 ngx_uint_t max, time_t inactive);
103 ngx_int_t ngx_open_cached_file(ngx_open_file_cache_t *cache, ngx_str_t *name,
104 ngx_open_file_info_t *of, ngx_pool_t *pool);
107 #endif /* _NGX_OPEN_FILE_CACHE_H_INCLUDED_ */