comparison src/mail/ngx_mail_core_module.c @ 366:babd3d9efb62 NGINX_0_6_27

nginx 0.6.27 *) Change: now by default the rtsig method is not built on Linux 2.6.18+. *) Change: now a request method is not changed while redirection to a named location via an "error_page" directive. *) Feature: the "resolver" and "resolver_timeout" directives in SMTP proxy. *) Feature: the "post_action" directive supports named locations. *) Bugfix: a segmentation fault occurred in worker process, if a request was redirected from proxy, FastCGI, or memcached location to static named locations. *) Bugfix: browsers did not repeat SSL handshake if there is no valid client certificate in first handshake. Thanks to Alexander V. Inyukhin. *) Bugfix: if response code 495-497 was redirected via an "error_page" directive without code change, then nginx tried to allocate too many memory. *) Bugfix: memory leak in long-lived non buffered connections. *) Bugfix: memory leak in resolver. *) Bugfix: a segmentation fault occurred in worker process, if a request was redirected from proxy, FastCGI, or memcached location to static named locations. *) Bugfix: in the $proxy_host and $proxy_port variables caching. Thanks to Sergey Bochenkov. *) Bugfix: a "proxy_pass" directive with variables used incorrectly the same port as in another "proxy_pass" directive with the same host name and without variables. Thanks to Sergey Bochenkov. *) Bugfix: an alert "sendmsg() failed (9: Bad file descriptor)" on some 64-bit platforms while reconfiguration. *) Bugfix: a segmentation fault occurred in worker process, if empty stub block was used second time in SSI. *) Bugfix: in copying URI part contained escaped symbols into arguments.
author Igor Sysoev <http://sysoev.ru>
date Wed, 12 Mar 2008 00:00:00 +0300
parents 10cc350ed8a1
children d13234035cad
comparison
equal deleted inserted replaced
365:9b0140fa1132 366:babd3d9efb62
18 void *conf); 18 void *conf);
19 static char *ngx_mail_core_listen(ngx_conf_t *cf, ngx_command_t *cmd, 19 static char *ngx_mail_core_listen(ngx_conf_t *cf, ngx_command_t *cmd,
20 void *conf); 20 void *conf);
21 static char *ngx_mail_core_protocol(ngx_conf_t *cf, ngx_command_t *cmd, 21 static char *ngx_mail_core_protocol(ngx_conf_t *cf, ngx_command_t *cmd,
22 void *conf); 22 void *conf);
23 static char *ngx_mail_core_resolver(ngx_conf_t *cf, ngx_command_t *cmd,
24 void *conf);
23 25
24 26
25 static ngx_command_t ngx_mail_core_commands[] = { 27 static ngx_command_t ngx_mail_core_commands[] = {
26 28
27 { ngx_string("server"), 29 { ngx_string("server"),
62 { ngx_string("server_name"), 64 { ngx_string("server_name"),
63 NGX_MAIL_MAIN_CONF|NGX_MAIL_SRV_CONF|NGX_CONF_TAKE1, 65 NGX_MAIL_MAIN_CONF|NGX_MAIL_SRV_CONF|NGX_CONF_TAKE1,
64 ngx_conf_set_str_slot, 66 ngx_conf_set_str_slot,
65 NGX_MAIL_SRV_CONF_OFFSET, 67 NGX_MAIL_SRV_CONF_OFFSET,
66 offsetof(ngx_mail_core_srv_conf_t, server_name), 68 offsetof(ngx_mail_core_srv_conf_t, server_name),
69 NULL },
70
71 { ngx_string("resolver"),
72 NGX_MAIL_MAIN_CONF|NGX_MAIL_SRV_CONF|NGX_CONF_TAKE1,
73 ngx_mail_core_resolver,
74 NGX_MAIL_SRV_CONF_OFFSET,
75 0,
76 NULL },
77
78 { ngx_string("resolver_timeout"),
79 NGX_MAIL_MAIN_CONF|NGX_MAIL_SRV_CONF|NGX_CONF_TAKE1,
80 ngx_conf_set_msec_slot,
81 NGX_MAIL_SRV_CONF_OFFSET,
82 offsetof(ngx_mail_core_srv_conf_t, resolver_timeout),
67 NULL }, 83 NULL },
68 84
69 ngx_null_command 85 ngx_null_command
70 }; 86 };
71 87
139 * 155 *
140 * cscf->protocol = NULL; 156 * cscf->protocol = NULL;
141 */ 157 */
142 158
143 cscf->timeout = NGX_CONF_UNSET_MSEC; 159 cscf->timeout = NGX_CONF_UNSET_MSEC;
160 cscf->resolver_timeout = NGX_CONF_UNSET_MSEC;
144 cscf->so_keepalive = NGX_CONF_UNSET; 161 cscf->so_keepalive = NGX_CONF_UNSET;
162
163 cscf->resolver = NGX_CONF_UNSET_PTR;
164
165 cscf->file_name = cf->conf_file->file.name.data;
166 cscf->line = cf->conf_file->line;
145 167
146 return cscf; 168 return cscf;
147 } 169 }
148 170
149 171
152 { 174 {
153 ngx_mail_core_srv_conf_t *prev = parent; 175 ngx_mail_core_srv_conf_t *prev = parent;
154 ngx_mail_core_srv_conf_t *conf = child; 176 ngx_mail_core_srv_conf_t *conf = child;
155 177
156 ngx_conf_merge_msec_value(conf->timeout, prev->timeout, 60000); 178 ngx_conf_merge_msec_value(conf->timeout, prev->timeout, 60000);
179 ngx_conf_merge_msec_value(conf->resolver_timeout, prev->resolver_timeout,
180 30000);
157 181
158 ngx_conf_merge_value(conf->so_keepalive, prev->so_keepalive, 0); 182 ngx_conf_merge_value(conf->so_keepalive, prev->so_keepalive, 0);
159 183
160 184
161 ngx_conf_merge_str_value(conf->server_name, prev->server_name, ""); 185 ngx_conf_merge_str_value(conf->server_name, prev->server_name, "");
181 ngx_log_error(NGX_LOG_EMERG, cf->log, 0, 205 ngx_log_error(NGX_LOG_EMERG, cf->log, 0,
182 "unknown mail protocol for server in %s:%ui", 206 "unknown mail protocol for server in %s:%ui",
183 conf->file_name, conf->line); 207 conf->file_name, conf->line);
184 return NGX_CONF_ERROR; 208 return NGX_CONF_ERROR;
185 } 209 }
210
211 ngx_conf_merge_ptr_value(conf->resolver, prev->resolver, NULL);
186 212
187 return NGX_CONF_OK; 213 return NGX_CONF_OK;
188 } 214 }
189 215
190 216
235 /* the server configuration context */ 261 /* the server configuration context */
236 262
237 cscf = ctx->srv_conf[ngx_mail_core_module.ctx_index]; 263 cscf = ctx->srv_conf[ngx_mail_core_module.ctx_index];
238 cscf->ctx = ctx; 264 cscf->ctx = ctx;
239 265
240 cscf->file_name = cf->conf_file->file.name.data;
241 cscf->line = cf->conf_file->line;
242
243 cmcf = ctx->main_conf[ngx_mail_core_module.ctx_index]; 266 cmcf = ctx->main_conf[ngx_mail_core_module.ctx_index];
244 267
245 cscfp = ngx_array_push(&cmcf->servers); 268 cscfp = ngx_array_push(&cmcf->servers);
246 if (cscfp == NULL) { 269 if (cscfp == NULL) {
247 return NGX_CONF_ERROR; 270 return NGX_CONF_ERROR;
387 "unknown protocol \"%V\"", &value[1]); 410 "unknown protocol \"%V\"", &value[1]);
388 return NGX_CONF_ERROR; 411 return NGX_CONF_ERROR;
389 } 412 }
390 413
391 414
415 static char *
416 ngx_mail_core_resolver(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
417 {
418 ngx_mail_core_srv_conf_t *cscf = conf;
419
420 ngx_url_t u;
421 ngx_str_t *value;
422
423 value = cf->args->elts;
424
425 if (cscf->resolver != NGX_CONF_UNSET_PTR) {
426 return "is duplicate";
427 }
428
429 if (ngx_strcmp(value[1].data, "off") == 0) {
430 cscf->resolver = NULL;
431 return NGX_CONF_OK;
432 }
433
434 ngx_memzero(&u, sizeof(ngx_url_t));
435
436 u.host = value[1];
437 u.port = 53;
438
439 if (ngx_inet_resolve_host(cf->pool, &u) != NGX_OK) {
440 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, "%V: %s", &u.host, u.err);
441 return NGX_CONF_ERROR;
442 }
443
444 cscf->resolver = ngx_resolver_create(cf, &u.addrs[0]);
445 if (cscf->resolver == NULL) {
446 return NGX_CONF_OK;
447 }
448
449 return NGX_CONF_OK;
450 }
451
452
392 char * 453 char *
393 ngx_mail_capabilities(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) 454 ngx_mail_capabilities(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
394 { 455 {
395 char *p = conf; 456 char *p = conf;
396 457