Mercurial > hg > nginx
comparison src/http/ngx_http_core_module.c @ 6022:1fdba317ee6d
Added support for offloading read() in thread pools.
author | Valentin Bartenev <vbart@nginx.com> |
---|---|
date | Sat, 14 Mar 2015 17:37:25 +0300 |
parents | 942283a53c28 |
children | 42d9beeb22db |
comparison
equal
deleted
inserted
replaced
6021:117c77b22db1 | 6022:1fdba317ee6d |
---|---|
3622 clcf->client_body_in_single_buffer = NGX_CONF_UNSET; | 3622 clcf->client_body_in_single_buffer = NGX_CONF_UNSET; |
3623 clcf->internal = NGX_CONF_UNSET; | 3623 clcf->internal = NGX_CONF_UNSET; |
3624 clcf->sendfile = NGX_CONF_UNSET; | 3624 clcf->sendfile = NGX_CONF_UNSET; |
3625 clcf->sendfile_max_chunk = NGX_CONF_UNSET_SIZE; | 3625 clcf->sendfile_max_chunk = NGX_CONF_UNSET_SIZE; |
3626 clcf->aio = NGX_CONF_UNSET; | 3626 clcf->aio = NGX_CONF_UNSET; |
3627 #if (NGX_THREADS) | |
3628 clcf->thread_pool = NGX_CONF_UNSET_PTR; | |
3629 clcf->thread_pool_value = NGX_CONF_UNSET_PTR; | |
3630 #endif | |
3627 clcf->read_ahead = NGX_CONF_UNSET_SIZE; | 3631 clcf->read_ahead = NGX_CONF_UNSET_SIZE; |
3628 clcf->directio = NGX_CONF_UNSET; | 3632 clcf->directio = NGX_CONF_UNSET; |
3629 clcf->directio_alignment = NGX_CONF_UNSET; | 3633 clcf->directio_alignment = NGX_CONF_UNSET; |
3630 clcf->tcp_nopush = NGX_CONF_UNSET; | 3634 clcf->tcp_nopush = NGX_CONF_UNSET; |
3631 clcf->tcp_nodelay = NGX_CONF_UNSET; | 3635 clcf->tcp_nodelay = NGX_CONF_UNSET; |
3837 prev->client_body_in_single_buffer, 0); | 3841 prev->client_body_in_single_buffer, 0); |
3838 ngx_conf_merge_value(conf->internal, prev->internal, 0); | 3842 ngx_conf_merge_value(conf->internal, prev->internal, 0); |
3839 ngx_conf_merge_value(conf->sendfile, prev->sendfile, 0); | 3843 ngx_conf_merge_value(conf->sendfile, prev->sendfile, 0); |
3840 ngx_conf_merge_size_value(conf->sendfile_max_chunk, | 3844 ngx_conf_merge_size_value(conf->sendfile_max_chunk, |
3841 prev->sendfile_max_chunk, 0); | 3845 prev->sendfile_max_chunk, 0); |
3846 #if (NGX_HAVE_FILE_AIO || NGX_THREADS) | |
3842 ngx_conf_merge_value(conf->aio, prev->aio, NGX_HTTP_AIO_OFF); | 3847 ngx_conf_merge_value(conf->aio, prev->aio, NGX_HTTP_AIO_OFF); |
3848 #endif | |
3849 #if (NGX_THREADS) | |
3850 ngx_conf_merge_ptr_value(conf->thread_pool, prev->thread_pool, NULL); | |
3851 ngx_conf_merge_ptr_value(conf->thread_pool_value, prev->thread_pool_value, | |
3852 NULL); | |
3853 #endif | |
3843 ngx_conf_merge_size_value(conf->read_ahead, prev->read_ahead, 0); | 3854 ngx_conf_merge_size_value(conf->read_ahead, prev->read_ahead, 0); |
3844 ngx_conf_merge_off_value(conf->directio, prev->directio, | 3855 ngx_conf_merge_off_value(conf->directio, prev->directio, |
3845 NGX_OPEN_FILE_DIRECTIO_OFF); | 3856 NGX_OPEN_FILE_DIRECTIO_OFF); |
3846 ngx_conf_merge_off_value(conf->directio_alignment, prev->directio_alignment, | 3857 ngx_conf_merge_off_value(conf->directio_alignment, prev->directio_alignment, |
3847 512); | 3858 512); |
4642 | 4653 |
4643 if (clcf->aio != NGX_CONF_UNSET) { | 4654 if (clcf->aio != NGX_CONF_UNSET) { |
4644 return "is duplicate"; | 4655 return "is duplicate"; |
4645 } | 4656 } |
4646 | 4657 |
4658 #if (NGX_THREADS) | |
4659 clcf->thread_pool = NULL; | |
4660 clcf->thread_pool_value = NULL; | |
4661 #endif | |
4662 | |
4647 value = cf->args->elts; | 4663 value = cf->args->elts; |
4648 | 4664 |
4649 if (ngx_strcmp(value[1].data, "off") == 0) { | 4665 if (ngx_strcmp(value[1].data, "off") == 0) { |
4650 clcf->aio = NGX_HTTP_AIO_OFF; | 4666 clcf->aio = NGX_HTTP_AIO_OFF; |
4651 return NGX_CONF_OK; | 4667 return NGX_CONF_OK; |
4674 return NGX_CONF_OK; | 4690 return NGX_CONF_OK; |
4675 } | 4691 } |
4676 | 4692 |
4677 #endif | 4693 #endif |
4678 | 4694 |
4695 if (ngx_strncmp(value[1].data, "threads", 7) == 0 | |
4696 && (value[1].len == 7 || value[1].data[7] == '=')) | |
4697 { | |
4698 #if (NGX_THREADS) | |
4699 ngx_str_t name; | |
4700 ngx_thread_pool_t *tp; | |
4701 ngx_http_complex_value_t cv; | |
4702 ngx_http_compile_complex_value_t ccv; | |
4703 | |
4704 clcf->aio = NGX_HTTP_AIO_THREADS; | |
4705 | |
4706 if (value[1].len >= 8) { | |
4707 name.len = value[1].len - 8; | |
4708 name.data = value[1].data + 8; | |
4709 | |
4710 ngx_memzero(&ccv, sizeof(ngx_http_compile_complex_value_t)); | |
4711 | |
4712 ccv.cf = cf; | |
4713 ccv.value = &name; | |
4714 ccv.complex_value = &cv; | |
4715 | |
4716 if (ngx_http_compile_complex_value(&ccv) != NGX_OK) { | |
4717 return NGX_CONF_ERROR; | |
4718 } | |
4719 | |
4720 if (cv.lengths != NULL) { | |
4721 clcf->thread_pool_value = ngx_palloc(cf->pool, | |
4722 sizeof(ngx_http_complex_value_t)); | |
4723 if (clcf->thread_pool_value == NULL) { | |
4724 return NGX_CONF_ERROR; | |
4725 } | |
4726 | |
4727 *clcf->thread_pool_value = cv; | |
4728 | |
4729 return NGX_CONF_OK; | |
4730 } | |
4731 | |
4732 tp = ngx_thread_pool_add(cf, &name); | |
4733 | |
4734 } else { | |
4735 tp = ngx_thread_pool_add(cf, NULL); | |
4736 } | |
4737 | |
4738 if (tp == NULL) { | |
4739 return NGX_CONF_ERROR; | |
4740 } | |
4741 | |
4742 clcf->thread_pool = tp; | |
4743 | |
4744 return NGX_CONF_OK; | |
4745 #else | |
4746 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, | |
4747 "\"aio threads\" " | |
4748 "is unsupported on this platform"); | |
4749 return NGX_CONF_ERROR; | |
4750 #endif | |
4751 } | |
4752 | |
4679 return "invalid value"; | 4753 return "invalid value"; |
4680 } | 4754 } |
4681 | 4755 |
4682 | 4756 |
4683 static char * | 4757 static char * |