comparison src/http/ngx_http_core_module.c @ 3224:8e76e636ae3b

allow to set listen options in any server
author Igor Sysoev <igor@sysoev.ru>
date Wed, 21 Oct 2009 19:16:38 +0000
parents c8de5a8b6d17
children f649453396f5
comparison
equal deleted inserted replaced
3223:bfcc1a6dd184 3224:8e76e636ae3b
3302 lsopt.wildcard = u.wildcard; 3302 lsopt.wildcard = u.wildcard;
3303 3303
3304 (void) ngx_sock_ntop((struct sockaddr *) &lsopt.sockaddr, lsopt.addr, 3304 (void) ngx_sock_ntop((struct sockaddr *) &lsopt.sockaddr, lsopt.addr,
3305 NGX_SOCKADDR_STRLEN, 1); 3305 NGX_SOCKADDR_STRLEN, 1);
3306 3306
3307 if (cf->args->nelts > 2 && ngx_strcmp(value[2].data, "default") == 0) { 3307 for (n = 2; n < cf->args->nelts; n++) {
3308 lsopt.default_server = 1; 3308
3309 n = 3; 3309 if (ngx_strcmp(value[n].data, "default") == 0) {
3310 3310 lsopt.default_server = 1;
3311 } else { 3311 continue;
3312 n = 2;
3313 }
3314
3315 for ( /* void */ ; n < cf->args->nelts; n++) {
3316
3317 if (lsopt.default_server == 0) {
3318 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
3319 "\"%V\" parameter can be specified for "
3320 "the default \"listen\" directive only",
3321 &value[n]);
3322 return NGX_CONF_ERROR;
3323 } 3312 }
3324 3313
3325 if (ngx_strcmp(value[n].data, "bind") == 0) { 3314 if (ngx_strcmp(value[n].data, "bind") == 0) {
3315 lsopt.set = 1;
3326 lsopt.bind = 1; 3316 lsopt.bind = 1;
3327 continue; 3317 continue;
3328 } 3318 }
3329 3319
3330 if (ngx_strncmp(value[n].data, "backlog=", 8) == 0) { 3320 if (ngx_strncmp(value[n].data, "backlog=", 8) == 0) {
3331 lsopt.backlog = ngx_atoi(value[n].data + 8, value[n].len - 8); 3321 lsopt.backlog = ngx_atoi(value[n].data + 8, value[n].len - 8);
3322 lsopt.set = 1;
3332 lsopt.bind = 1; 3323 lsopt.bind = 1;
3333 3324
3334 if (lsopt.backlog == NGX_ERROR || lsopt.backlog == 0) { 3325 if (lsopt.backlog == NGX_ERROR || lsopt.backlog == 0) {
3335 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, 3326 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
3336 "invalid backlog \"%V\"", &value[n]); 3327 "invalid backlog \"%V\"", &value[n]);
3343 if (ngx_strncmp(value[n].data, "rcvbuf=", 7) == 0) { 3334 if (ngx_strncmp(value[n].data, "rcvbuf=", 7) == 0) {
3344 size.len = value[n].len - 7; 3335 size.len = value[n].len - 7;
3345 size.data = value[n].data + 7; 3336 size.data = value[n].data + 7;
3346 3337
3347 lsopt.rcvbuf = ngx_parse_size(&size); 3338 lsopt.rcvbuf = ngx_parse_size(&size);
3339 lsopt.set = 1;
3348 lsopt.bind = 1; 3340 lsopt.bind = 1;
3349 3341
3350 if (lsopt.rcvbuf == NGX_ERROR) { 3342 if (lsopt.rcvbuf == NGX_ERROR) {
3351 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, 3343 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
3352 "invalid rcvbuf \"%V\"", &value[n]); 3344 "invalid rcvbuf \"%V\"", &value[n]);
3359 if (ngx_strncmp(value[n].data, "sndbuf=", 7) == 0) { 3351 if (ngx_strncmp(value[n].data, "sndbuf=", 7) == 0) {
3360 size.len = value[n].len - 7; 3352 size.len = value[n].len - 7;
3361 size.data = value[n].data + 7; 3353 size.data = value[n].data + 7;
3362 3354
3363 lsopt.sndbuf = ngx_parse_size(&size); 3355 lsopt.sndbuf = ngx_parse_size(&size);
3356 lsopt.set = 1;
3364 lsopt.bind = 1; 3357 lsopt.bind = 1;
3365 3358
3366 if (lsopt.sndbuf == NGX_ERROR) { 3359 if (lsopt.sndbuf == NGX_ERROR) {
3367 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, 3360 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
3368 "invalid sndbuf \"%V\"", &value[n]); 3361 "invalid sndbuf \"%V\"", &value[n]);
3373 } 3366 }
3374 3367
3375 if (ngx_strncmp(value[n].data, "accept_filter=", 14) == 0) { 3368 if (ngx_strncmp(value[n].data, "accept_filter=", 14) == 0) {
3376 #if (NGX_HAVE_DEFERRED_ACCEPT && defined SO_ACCEPTFILTER) 3369 #if (NGX_HAVE_DEFERRED_ACCEPT && defined SO_ACCEPTFILTER)
3377 lsopt.accept_filter = (char *) &value[n].data[14]; 3370 lsopt.accept_filter = (char *) &value[n].data[14];
3371 lsopt.set = 1;
3378 lsopt.bind = 1; 3372 lsopt.bind = 1;
3379 #else 3373 #else
3380 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, 3374 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
3381 "accept filters \"%V\" are not supported " 3375 "accept filters \"%V\" are not supported "
3382 "on this platform, ignored", 3376 "on this platform, ignored",
3386 } 3380 }
3387 3381
3388 if (ngx_strcmp(value[n].data, "deferred") == 0) { 3382 if (ngx_strcmp(value[n].data, "deferred") == 0) {
3389 #if (NGX_HAVE_DEFERRED_ACCEPT && defined TCP_DEFER_ACCEPT) 3383 #if (NGX_HAVE_DEFERRED_ACCEPT && defined TCP_DEFER_ACCEPT)
3390 lsopt.deferred_accept = 1; 3384 lsopt.deferred_accept = 1;
3385 lsopt.set = 1;
3391 lsopt.bind = 1; 3386 lsopt.bind = 1;
3392 #else 3387 #else
3393 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, 3388 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
3394 "the deferred accept is not supported " 3389 "the deferred accept is not supported "
3395 "on this platform, ignored"); 3390 "on this platform, ignored");
3416 "invalid ipv6only flags \"%s\"", 3411 "invalid ipv6only flags \"%s\"",
3417 &value[n].data[9]); 3412 &value[n].data[9]);
3418 return NGX_CONF_ERROR; 3413 return NGX_CONF_ERROR;
3419 } 3414 }
3420 3415
3416 lsopt.set = 1;
3421 lsopt.bind = 1; 3417 lsopt.bind = 1;
3422 3418
3423 } else { 3419 } else {
3424 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, 3420 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
3425 "ipv6only is not supported " 3421 "ipv6only is not supported "
3435 #endif 3431 #endif
3436 } 3432 }
3437 3433
3438 if (ngx_strcmp(value[n].data, "ssl") == 0) { 3434 if (ngx_strcmp(value[n].data, "ssl") == 0) {
3439 #if (NGX_HTTP_SSL) 3435 #if (NGX_HTTP_SSL)
3436 lsopt.set = 1;
3440 lsopt.ssl = 1; 3437 lsopt.ssl = 1;
3441 continue; 3438 continue;
3442 #else 3439 #else
3443 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, 3440 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
3444 "the \"ssl\" parameter requires " 3441 "the \"ssl\" parameter requires "