summaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorRuslan Ermilov <ru@nginx.com>2015-03-13 16:42:52 +0300
committerRuslan Ermilov <ru@nginx.com>2015-03-13 16:42:52 +0300
commitdb999274ec57511d791bb19185499fac8a20b727 (patch)
treebbd2d4c1ec4db709082b99b2374fc792af78f650 /src
parentbcd8123913acc4e1e532c8bcceef79e034e4f3e7 (diff)
downloadnginx-db999274ec57511d791bb19185499fac8a20b727.tar.gz
nginx-db999274ec57511d791bb19185499fac8a20b727.tar.bz2
The "aio" directive parser made smarter.
It now prints meaningful warnings on all platforms. No functional changes.
Diffstat (limited to 'src')
-rw-r--r--src/http/ngx_http_core_module.c77
-rw-r--r--src/http/ngx_http_core_module.h2
2 files changed, 52 insertions, 27 deletions
diff --git a/src/http/ngx_http_core_module.c b/src/http/ngx_http_core_module.c
index bb2c1df52..be39accb8 100644
--- a/src/http/ngx_http_core_module.c
+++ b/src/http/ngx_http_core_module.c
@@ -54,6 +54,8 @@ static char *ngx_http_core_server_name(ngx_conf_t *cf, ngx_command_t *cmd,
static char *ngx_http_core_root(ngx_conf_t *cf, ngx_command_t *cmd, void *conf);
static char *ngx_http_core_limit_except(ngx_conf_t *cf, ngx_command_t *cmd,
void *conf);
+static char *ngx_http_core_set_aio(ngx_conf_t *cf, ngx_command_t *cmd,
+ void *conf);
static char *ngx_http_core_directio(ngx_conf_t *cf, ngx_command_t *cmd,
void *conf);
static char *ngx_http_core_error_page(ngx_conf_t *cf, ngx_command_t *cmd,
@@ -114,20 +116,6 @@ static ngx_conf_enum_t ngx_http_core_request_body_in_file[] = {
};
-#if (NGX_HAVE_FILE_AIO)
-
-static ngx_conf_enum_t ngx_http_core_aio[] = {
- { ngx_string("off"), NGX_HTTP_AIO_OFF },
- { ngx_string("on"), NGX_HTTP_AIO_ON },
-#if (NGX_HAVE_AIO_SENDFILE)
- { ngx_string("sendfile"), NGX_HTTP_AIO_ON },
-#endif
- { ngx_null_string, 0 }
-};
-
-#endif
-
-
static ngx_conf_enum_t ngx_http_core_satisfy[] = {
{ ngx_string("all"), NGX_HTTP_SATISFY_ALL },
{ ngx_string("any"), NGX_HTTP_SATISFY_ANY },
@@ -423,16 +411,12 @@ static ngx_command_t ngx_http_core_commands[] = {
offsetof(ngx_http_core_loc_conf_t, sendfile_max_chunk),
NULL },
-#if (NGX_HAVE_FILE_AIO)
-
{ ngx_string("aio"),
NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1,
- ngx_conf_set_enum_slot,
+ ngx_http_core_set_aio,
NGX_HTTP_LOC_CONF_OFFSET,
- offsetof(ngx_http_core_loc_conf_t, aio),
- &ngx_http_core_aio },
-
-#endif
+ 0,
+ NULL },
{ ngx_string("read_ahead"),
NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1,
@@ -3639,9 +3623,7 @@ ngx_http_core_create_loc_conf(ngx_conf_t *cf)
clcf->internal = NGX_CONF_UNSET;
clcf->sendfile = NGX_CONF_UNSET;
clcf->sendfile_max_chunk = NGX_CONF_UNSET_SIZE;
-#if (NGX_HAVE_FILE_AIO)
clcf->aio = NGX_CONF_UNSET;
-#endif
clcf->read_ahead = NGX_CONF_UNSET_SIZE;
clcf->directio = NGX_CONF_UNSET;
clcf->directio_alignment = NGX_CONF_UNSET;
@@ -3857,9 +3839,7 @@ ngx_http_core_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child)
ngx_conf_merge_value(conf->sendfile, prev->sendfile, 0);
ngx_conf_merge_size_value(conf->sendfile_max_chunk,
prev->sendfile_max_chunk, 0);
-#if (NGX_HAVE_FILE_AIO)
ngx_conf_merge_value(conf->aio, prev->aio, NGX_HTTP_AIO_OFF);
-#endif
ngx_conf_merge_size_value(conf->read_ahead, prev->read_ahead, 0);
ngx_conf_merge_off_value(conf->directio, prev->directio,
NGX_OPEN_FILE_DIRECTIO_OFF);
@@ -4654,6 +4634,53 @@ ngx_http_core_limit_except(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
static char *
+ngx_http_core_set_aio(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
+{
+ ngx_http_core_loc_conf_t *clcf = conf;
+
+ ngx_str_t *value;
+
+ if (clcf->aio != NGX_CONF_UNSET) {
+ return "is duplicate";
+ }
+
+ value = cf->args->elts;
+
+ if (ngx_strcmp(value[1].data, "off") == 0) {
+ clcf->aio = NGX_HTTP_AIO_OFF;
+ return NGX_CONF_OK;
+ }
+
+ if (ngx_strcmp(value[1].data, "on") == 0) {
+#if (NGX_HAVE_FILE_AIO)
+ clcf->aio = NGX_HTTP_AIO_ON;
+ return NGX_CONF_OK;
+#else
+ ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
+ "\"aio on\" "
+ "is unsupported on this platform");
+ return NGX_CONF_ERROR;
+#endif
+ }
+
+#if (NGX_HAVE_AIO_SENDFILE)
+
+ if (ngx_strcmp(value[1].data, "sendfile") == 0) {
+ clcf->aio = NGX_HTTP_AIO_ON;
+
+ ngx_conf_log_error(NGX_LOG_WARN, cf, 0,
+ "the \"sendfile\" parameter of "
+ "the \"aio\" directive is deprecated");
+ return NGX_CONF_OK;
+ }
+
+#endif
+
+ return "invalid value";
+}
+
+
+static char *
ngx_http_core_directio(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
{
ngx_http_core_loc_conf_t *clcf = conf;
diff --git a/src/http/ngx_http_core_module.h b/src/http/ngx_http_core_module.h
index 258393db2..de7d4edcd 100644
--- a/src/http/ngx_http_core_module.h
+++ b/src/http/ngx_http_core_module.h
@@ -395,9 +395,7 @@ struct ngx_http_core_loc_conf_s {
/* client_body_in_singe_buffer */
ngx_flag_t internal; /* internal */
ngx_flag_t sendfile; /* sendfile */
-#if (NGX_HAVE_FILE_AIO)
ngx_flag_t aio; /* aio */
-#endif
ngx_flag_t tcp_nopush; /* tcp_nopush */
ngx_flag_t tcp_nodelay; /* tcp_nodelay */
ngx_flag_t reset_timedout_connection; /* reset_timedout_connection */