comparison src/core/ngx_open_file_cache.h @ 332:3a91bfeffaba NGINX_0_6_10

nginx 0.6.10 *) Feature: the "open_file_cache", "open_file_cache_retest", and "open_file_cache_errors" directives. *) Bugfix: socket leak; bug appeared in 0.6.7. *) Bugfix: a charset set by the "charset" directive was not appended to the "Content-Type" header set by $r->send_http_header(). *) Bugfix: a segmentation fault might occur in worker process if /dev/poll method was used.
author Igor Sysoev <http://sysoev.ru>
date Mon, 03 Sep 2007 00:00:00 +0400
parents
children 9121a0a91f47
comparison
equal deleted inserted replaced
331:b69d5e83bf82 332:3a91bfeffaba
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 unsigned events:1;
27
28 unsigned is_dir:1;
29 unsigned is_file:1;
30 unsigned is_link:1;
31 unsigned is_exec:1;
32 } ngx_open_file_info_t;
33
34
35 typedef struct ngx_cached_open_file_s ngx_cached_open_file_t;
36
37 struct ngx_cached_open_file_s {
38 ngx_rbtree_node_t node;
39 ngx_cached_open_file_t *prev;
40 ngx_cached_open_file_t *next;
41
42 u_char *name;
43 time_t created;
44 time_t accessed;
45
46 ngx_fd_t fd;
47 ngx_file_uniq_t uniq;
48 time_t mtime;
49 off_t size;
50 ngx_err_t err;
51
52 unsigned count:24;
53 unsigned close:1;
54
55 unsigned is_dir:1;
56 unsigned is_file:1;
57 unsigned is_link:1;
58 unsigned is_exec:1;
59
60 ngx_event_t *event;
61 };
62
63
64 typedef struct {
65 ngx_rbtree_t rbtree;
66 ngx_cached_open_file_t list_head;
67 ngx_cached_open_file_t list_tail;
68
69 ngx_uint_t current;
70 ngx_uint_t max;
71 time_t inactive;
72 } ngx_open_file_cache_t;
73
74
75 typedef struct {
76 ngx_open_file_cache_t *cache;
77 ngx_cached_open_file_t *file;
78 ngx_log_t *log;
79 } ngx_open_file_cache_cleanup_t;
80
81
82 typedef struct {
83
84 /* ngx_connection_t stub to allow use c->fd as event ident */
85 void *data;
86 ngx_event_t *read;
87 ngx_event_t *write;
88 ngx_fd_t fd;
89
90 ngx_cached_open_file_t *file;
91 ngx_open_file_cache_t *cache;
92 } ngx_open_file_cache_event_t;
93
94
95 ngx_open_file_cache_t *ngx_open_file_cache_init(ngx_pool_t *pool,
96 ngx_uint_t max, time_t inactive);
97 ngx_int_t ngx_open_cached_file(ngx_open_file_cache_t *cache, ngx_str_t *name,
98 ngx_open_file_info_t *of, ngx_pool_t *pool);
99
100
101 #endif /* _NGX_OPEN_FILE_CACHE_H_INCLUDED_ */