annotate src/http/ngx_http_copy_filter_module.c @ 518:86dad910eeb6 NGINX_0_8_11

nginx 0.8.11 *) Change: directive "gzip_disable msie6" enables gzipping for MSIE 6.0 SV1. *) Feature: file AIO support on FreeBSD and Linux. *) Feature: the "directio_alignment" directive.
author Igor Sysoev <http://sysoev.ru>
date Fri, 28 Aug 2009 00:00:00 +0400
parents e7dbea1ee115
children d41628eb4d0a
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
50
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
1
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
2 /*
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
3 * Copyright (C) Igor Sysoev
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
4 */
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
5
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
6
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
7 #include <ngx_config.h>
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
8 #include <ngx_core.h>
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
9 #include <ngx_http.h>
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
10
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
11
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
12 typedef struct {
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
13 ngx_bufs_t bufs;
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
14 } ngx_http_copy_filter_conf_t;
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
15
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
16
518
86dad910eeb6 nginx 0.8.11
Igor Sysoev <http://sysoev.ru>
parents: 426
diff changeset
17 #if (NGX_HAVE_FILE_AIO)
86dad910eeb6 nginx 0.8.11
Igor Sysoev <http://sysoev.ru>
parents: 426
diff changeset
18 static void ngx_http_copy_aio_handler(ngx_output_chain_ctx_t *ctx,
86dad910eeb6 nginx 0.8.11
Igor Sysoev <http://sysoev.ru>
parents: 426
diff changeset
19 ngx_file_t *file);
86dad910eeb6 nginx 0.8.11
Igor Sysoev <http://sysoev.ru>
parents: 426
diff changeset
20 static void ngx_http_copy_aio_event_handler(ngx_event_t *ev);
86dad910eeb6 nginx 0.8.11
Igor Sysoev <http://sysoev.ru>
parents: 426
diff changeset
21 #endif
86dad910eeb6 nginx 0.8.11
Igor Sysoev <http://sysoev.ru>
parents: 426
diff changeset
22
50
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
23 static void *ngx_http_copy_filter_create_conf(ngx_conf_t *cf);
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
24 static char *ngx_http_copy_filter_merge_conf(ngx_conf_t *cf,
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
25 void *parent, void *child);
230
38e7b94d63ac nginx 0.4.0
Igor Sysoev <http://sysoev.ru>
parents: 216
diff changeset
26 static ngx_int_t ngx_http_copy_filter_init(ngx_conf_t *cf);
50
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
27
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
28
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
29 static ngx_command_t ngx_http_copy_filter_commands[] = {
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
30
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
31 { ngx_string("output_buffers"),
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
32 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE2,
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
33 ngx_conf_set_bufs_slot,
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
34 NGX_HTTP_LOC_CONF_OFFSET,
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
35 offsetof(ngx_http_copy_filter_conf_t, bufs),
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
36 NULL },
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
37
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
38 ngx_null_command
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
39 };
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
40
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
41
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
42 static ngx_http_module_t ngx_http_copy_filter_module_ctx = {
58
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
43 NULL, /* preconfiguration */
230
38e7b94d63ac nginx 0.4.0
Igor Sysoev <http://sysoev.ru>
parents: 216
diff changeset
44 ngx_http_copy_filter_init, /* postconfiguration */
50
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
45
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
46 NULL, /* create main configuration */
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
47 NULL, /* init main configuration */
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
48
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
49 NULL, /* create server configuration */
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
50 NULL, /* merge server configuration */
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
51
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
52 ngx_http_copy_filter_create_conf, /* create location configuration */
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
53 ngx_http_copy_filter_merge_conf /* merge location configuration */
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
54 };
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
55
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
56
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
57 ngx_module_t ngx_http_copy_filter_module = {
58
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
58 NGX_MODULE_V1,
50
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
59 &ngx_http_copy_filter_module_ctx, /* module context */
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
60 ngx_http_copy_filter_commands, /* module directives */
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
61 NGX_HTTP_MODULE, /* module type */
90
71c46860eb55 nginx 0.1.45
Igor Sysoev <http://sysoev.ru>
parents: 76
diff changeset
62 NULL, /* init master */
230
38e7b94d63ac nginx 0.4.0
Igor Sysoev <http://sysoev.ru>
parents: 216
diff changeset
63 NULL, /* init module */
90
71c46860eb55 nginx 0.1.45
Igor Sysoev <http://sysoev.ru>
parents: 76
diff changeset
64 NULL, /* init process */
71c46860eb55 nginx 0.1.45
Igor Sysoev <http://sysoev.ru>
parents: 76
diff changeset
65 NULL, /* init thread */
71c46860eb55 nginx 0.1.45
Igor Sysoev <http://sysoev.ru>
parents: 76
diff changeset
66 NULL, /* exit thread */
71c46860eb55 nginx 0.1.45
Igor Sysoev <http://sysoev.ru>
parents: 76
diff changeset
67 NULL, /* exit process */
71c46860eb55 nginx 0.1.45
Igor Sysoev <http://sysoev.ru>
parents: 76
diff changeset
68 NULL, /* exit master */
71c46860eb55 nginx 0.1.45
Igor Sysoev <http://sysoev.ru>
parents: 76
diff changeset
69 NGX_MODULE_V1_PADDING
50
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
70 };
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
71
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
72
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
73 static ngx_http_output_body_filter_pt ngx_http_next_filter;
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
74
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
75
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
76 static ngx_int_t
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
77 ngx_http_copy_filter(ngx_http_request_t *r, ngx_chain_t *in)
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
78 {
132
91372f004adf nginx 0.3.13
Igor Sysoev <http://sysoev.ru>
parents: 118
diff changeset
79 ngx_int_t rc;
91372f004adf nginx 0.3.13
Igor Sysoev <http://sysoev.ru>
parents: 118
diff changeset
80 ngx_connection_t *c;
50
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
81 ngx_output_chain_ctx_t *ctx;
518
86dad910eeb6 nginx 0.8.11
Igor Sysoev <http://sysoev.ru>
parents: 426
diff changeset
82 ngx_http_core_loc_conf_t *clcf;
50
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
83 ngx_http_copy_filter_conf_t *conf;
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
84
132
91372f004adf nginx 0.3.13
Igor Sysoev <http://sysoev.ru>
parents: 118
diff changeset
85 c = r->connection;
91372f004adf nginx 0.3.13
Igor Sysoev <http://sysoev.ru>
parents: 118
diff changeset
86
518
86dad910eeb6 nginx 0.8.11
Igor Sysoev <http://sysoev.ru>
parents: 426
diff changeset
87 if (r->aio) {
86dad910eeb6 nginx 0.8.11
Igor Sysoev <http://sysoev.ru>
parents: 426
diff changeset
88 return NGX_AGAIN;
86dad910eeb6 nginx 0.8.11
Igor Sysoev <http://sysoev.ru>
parents: 426
diff changeset
89 }
86dad910eeb6 nginx 0.8.11
Igor Sysoev <http://sysoev.ru>
parents: 426
diff changeset
90
132
91372f004adf nginx 0.3.13
Igor Sysoev <http://sysoev.ru>
parents: 118
diff changeset
91 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, c->log, 0,
91372f004adf nginx 0.3.13
Igor Sysoev <http://sysoev.ru>
parents: 118
diff changeset
92 "copy filter: \"%V?%V\"", &r->uri, &r->args);
58
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
93
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
94 ctx = ngx_http_get_module_ctx(r, ngx_http_copy_filter_module);
50
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
95
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
96 if (ctx == NULL) {
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
97 ctx = ngx_pcalloc(r->pool, sizeof(ngx_output_chain_ctx_t));
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
98 if (ctx == NULL) {
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
99 return NGX_ERROR;
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
100 }
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
101
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
102 ngx_http_set_ctx(r, ctx, ngx_http_copy_filter_module);
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
103
518
86dad910eeb6 nginx 0.8.11
Igor Sysoev <http://sysoev.ru>
parents: 426
diff changeset
104 conf = ngx_http_get_module_loc_conf(r, ngx_http_copy_filter_module);
86dad910eeb6 nginx 0.8.11
Igor Sysoev <http://sysoev.ru>
parents: 426
diff changeset
105 clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module);
86dad910eeb6 nginx 0.8.11
Igor Sysoev <http://sysoev.ru>
parents: 426
diff changeset
106
132
91372f004adf nginx 0.3.13
Igor Sysoev <http://sysoev.ru>
parents: 118
diff changeset
107 ctx->sendfile = c->sendfile;
62
0790a8599248 nginx 0.1.31
Igor Sysoev <http://sysoev.ru>
parents: 58
diff changeset
108 ctx->need_in_memory = r->main_filter_need_in_memory
0790a8599248 nginx 0.1.31
Igor Sysoev <http://sysoev.ru>
parents: 58
diff changeset
109 || r->filter_need_in_memory;
50
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
110 ctx->need_in_temp = r->filter_need_temporary;
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
111
518
86dad910eeb6 nginx 0.8.11
Igor Sysoev <http://sysoev.ru>
parents: 426
diff changeset
112 ctx->alignment = clcf->directio_alignment;
86dad910eeb6 nginx 0.8.11
Igor Sysoev <http://sysoev.ru>
parents: 426
diff changeset
113
50
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
114 ctx->pool = r->pool;
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
115 ctx->bufs = conf->bufs;
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
116 ctx->tag = (ngx_buf_tag_t) &ngx_http_copy_filter_module;
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
117
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
118 ctx->output_filter = (ngx_output_chain_filter_pt) ngx_http_next_filter;
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
119 ctx->filter_ctx = r;
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
120
518
86dad910eeb6 nginx 0.8.11
Igor Sysoev <http://sysoev.ru>
parents: 426
diff changeset
121 #if (NGX_HAVE_FILE_AIO)
86dad910eeb6 nginx 0.8.11
Igor Sysoev <http://sysoev.ru>
parents: 426
diff changeset
122 if (clcf->aio) {
86dad910eeb6 nginx 0.8.11
Igor Sysoev <http://sysoev.ru>
parents: 426
diff changeset
123 ctx->aio = ngx_http_copy_aio_handler;
86dad910eeb6 nginx 0.8.11
Igor Sysoev <http://sysoev.ru>
parents: 426
diff changeset
124 }
86dad910eeb6 nginx 0.8.11
Igor Sysoev <http://sysoev.ru>
parents: 426
diff changeset
125 #endif
86dad910eeb6 nginx 0.8.11
Igor Sysoev <http://sysoev.ru>
parents: 426
diff changeset
126
216
fa32d59d9a15 nginx 0.3.55
Igor Sysoev <http://sysoev.ru>
parents: 132
diff changeset
127 r->request_output = 1;
50
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
128 }
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
129
132
91372f004adf nginx 0.3.13
Igor Sysoev <http://sysoev.ru>
parents: 118
diff changeset
130 rc = ngx_output_chain(ctx, in);
58
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
131
518
86dad910eeb6 nginx 0.8.11
Igor Sysoev <http://sysoev.ru>
parents: 426
diff changeset
132 if (ctx->in == NULL) {
86dad910eeb6 nginx 0.8.11
Igor Sysoev <http://sysoev.ru>
parents: 426
diff changeset
133 r->buffered &= ~NGX_HTTP_COPY_BUFFERED;
254
f3ec44f4a53b nginx 0.4.12
Igor Sysoev <http://sysoev.ru>
parents: 230
diff changeset
134
518
86dad910eeb6 nginx 0.8.11
Igor Sysoev <http://sysoev.ru>
parents: 426
diff changeset
135 } else {
86dad910eeb6 nginx 0.8.11
Igor Sysoev <http://sysoev.ru>
parents: 426
diff changeset
136 r->buffered |= NGX_HTTP_COPY_BUFFERED;
86dad910eeb6 nginx 0.8.11
Igor Sysoev <http://sysoev.ru>
parents: 426
diff changeset
137 }
254
f3ec44f4a53b nginx 0.4.12
Igor Sysoev <http://sysoev.ru>
parents: 230
diff changeset
138
518
86dad910eeb6 nginx 0.8.11
Igor Sysoev <http://sysoev.ru>
parents: 426
diff changeset
139 ngx_log_debug3(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
86dad910eeb6 nginx 0.8.11
Igor Sysoev <http://sysoev.ru>
parents: 426
diff changeset
140 "copy filter: %i \"%V?%V\"", rc, &r->uri, &r->args);
132
91372f004adf nginx 0.3.13
Igor Sysoev <http://sysoev.ru>
parents: 118
diff changeset
141
91372f004adf nginx 0.3.13
Igor Sysoev <http://sysoev.ru>
parents: 118
diff changeset
142 return rc;
50
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
143 }
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
144
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
145
518
86dad910eeb6 nginx 0.8.11
Igor Sysoev <http://sysoev.ru>
parents: 426
diff changeset
146 #if (NGX_HAVE_FILE_AIO)
86dad910eeb6 nginx 0.8.11
Igor Sysoev <http://sysoev.ru>
parents: 426
diff changeset
147
86dad910eeb6 nginx 0.8.11
Igor Sysoev <http://sysoev.ru>
parents: 426
diff changeset
148 static void
86dad910eeb6 nginx 0.8.11
Igor Sysoev <http://sysoev.ru>
parents: 426
diff changeset
149 ngx_http_copy_aio_handler(ngx_output_chain_ctx_t *ctx, ngx_file_t *file)
86dad910eeb6 nginx 0.8.11
Igor Sysoev <http://sysoev.ru>
parents: 426
diff changeset
150 {
86dad910eeb6 nginx 0.8.11
Igor Sysoev <http://sysoev.ru>
parents: 426
diff changeset
151 ngx_http_request_t *r;
86dad910eeb6 nginx 0.8.11
Igor Sysoev <http://sysoev.ru>
parents: 426
diff changeset
152
86dad910eeb6 nginx 0.8.11
Igor Sysoev <http://sysoev.ru>
parents: 426
diff changeset
153 r = ctx->filter_ctx;
86dad910eeb6 nginx 0.8.11
Igor Sysoev <http://sysoev.ru>
parents: 426
diff changeset
154
86dad910eeb6 nginx 0.8.11
Igor Sysoev <http://sysoev.ru>
parents: 426
diff changeset
155 file->aio->data = r;
86dad910eeb6 nginx 0.8.11
Igor Sysoev <http://sysoev.ru>
parents: 426
diff changeset
156 file->aio->handler = ngx_http_copy_aio_event_handler;
86dad910eeb6 nginx 0.8.11
Igor Sysoev <http://sysoev.ru>
parents: 426
diff changeset
157
86dad910eeb6 nginx 0.8.11
Igor Sysoev <http://sysoev.ru>
parents: 426
diff changeset
158 r->main->blocked++;
86dad910eeb6 nginx 0.8.11
Igor Sysoev <http://sysoev.ru>
parents: 426
diff changeset
159 r->aio = 1;
86dad910eeb6 nginx 0.8.11
Igor Sysoev <http://sysoev.ru>
parents: 426
diff changeset
160 }
86dad910eeb6 nginx 0.8.11
Igor Sysoev <http://sysoev.ru>
parents: 426
diff changeset
161
86dad910eeb6 nginx 0.8.11
Igor Sysoev <http://sysoev.ru>
parents: 426
diff changeset
162
86dad910eeb6 nginx 0.8.11
Igor Sysoev <http://sysoev.ru>
parents: 426
diff changeset
163 static void
86dad910eeb6 nginx 0.8.11
Igor Sysoev <http://sysoev.ru>
parents: 426
diff changeset
164 ngx_http_copy_aio_event_handler(ngx_event_t *ev)
86dad910eeb6 nginx 0.8.11
Igor Sysoev <http://sysoev.ru>
parents: 426
diff changeset
165 {
86dad910eeb6 nginx 0.8.11
Igor Sysoev <http://sysoev.ru>
parents: 426
diff changeset
166 ngx_event_aio_t *aio;
86dad910eeb6 nginx 0.8.11
Igor Sysoev <http://sysoev.ru>
parents: 426
diff changeset
167 ngx_http_request_t *r;
86dad910eeb6 nginx 0.8.11
Igor Sysoev <http://sysoev.ru>
parents: 426
diff changeset
168
86dad910eeb6 nginx 0.8.11
Igor Sysoev <http://sysoev.ru>
parents: 426
diff changeset
169 aio = ev->data;
86dad910eeb6 nginx 0.8.11
Igor Sysoev <http://sysoev.ru>
parents: 426
diff changeset
170 r = aio->data;
86dad910eeb6 nginx 0.8.11
Igor Sysoev <http://sysoev.ru>
parents: 426
diff changeset
171
86dad910eeb6 nginx 0.8.11
Igor Sysoev <http://sysoev.ru>
parents: 426
diff changeset
172 r->main->blocked--;
86dad910eeb6 nginx 0.8.11
Igor Sysoev <http://sysoev.ru>
parents: 426
diff changeset
173 r->aio = 0;
86dad910eeb6 nginx 0.8.11
Igor Sysoev <http://sysoev.ru>
parents: 426
diff changeset
174
86dad910eeb6 nginx 0.8.11
Igor Sysoev <http://sysoev.ru>
parents: 426
diff changeset
175 r->connection->write->handler(r->connection->write);
86dad910eeb6 nginx 0.8.11
Igor Sysoev <http://sysoev.ru>
parents: 426
diff changeset
176 }
86dad910eeb6 nginx 0.8.11
Igor Sysoev <http://sysoev.ru>
parents: 426
diff changeset
177
86dad910eeb6 nginx 0.8.11
Igor Sysoev <http://sysoev.ru>
parents: 426
diff changeset
178 #endif
86dad910eeb6 nginx 0.8.11
Igor Sysoev <http://sysoev.ru>
parents: 426
diff changeset
179
86dad910eeb6 nginx 0.8.11
Igor Sysoev <http://sysoev.ru>
parents: 426
diff changeset
180
50
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
181 static void *
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
182 ngx_http_copy_filter_create_conf(ngx_conf_t *cf)
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
183 {
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
184 ngx_http_copy_filter_conf_t *conf;
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
185
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
186 conf = ngx_palloc(cf->pool, sizeof(ngx_http_copy_filter_conf_t));
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
187 if (conf == NULL) {
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
188 return NULL;
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
189 }
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
190
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
191 conf->bufs.num = 0;
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
192
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
193 return conf;
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
194 }
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
195
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
196
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
197 static char *
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
198 ngx_http_copy_filter_merge_conf(ngx_conf_t *cf, void *parent, void *child)
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
199 {
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
200 ngx_http_copy_filter_conf_t *prev = parent;
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
201 ngx_http_copy_filter_conf_t *conf = child;
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
202
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
203 ngx_conf_merge_bufs_value(conf->bufs, prev->bufs, 1, 32768);
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
204
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
205 return NULL;
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
206 }
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
207
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
208
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
209 static ngx_int_t
230
38e7b94d63ac nginx 0.4.0
Igor Sysoev <http://sysoev.ru>
parents: 216
diff changeset
210 ngx_http_copy_filter_init(ngx_conf_t *cf)
50
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
211 {
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
212 ngx_http_next_filter = ngx_http_top_body_filter;
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
213 ngx_http_top_body_filter = ngx_http_copy_filter;
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
214
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
215 return NGX_OK;
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
216 }
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
217