[nginx] svn commit: r4907 - in branches/stable-1.2: . src/core

mdounin at mdounin.ru mdounin at mdounin.ru
Tue Nov 13 11:00:37 UTC 2012


Author: mdounin
Date: 2012-11-13 11:00:37 +0000 (Tue, 13 Nov 2012)
New Revision: 4907
URL: http://trac.nginx.org/nginx/changeset/4907/nginx

Log:
Merge of r4891: worker_processes auto.

Core: the "auto" parameter of the "worker_processes" directive.

The parameter will set the number of worker processes to the
autodetected number of available CPU cores.


Modified:
   branches/stable-1.2/
   branches/stable-1.2/src/core/nginx.c

Index: branches/stable-1.2
===================================================================
--- branches/stable-1.2	2012-11-13 10:45:23 UTC (rev 4906)
+++ branches/stable-1.2	2012-11-13 11:00:37 UTC (rev 4907)

Property changes on: branches/stable-1.2
___________________________________________________________________
Modified: svn:mergeinfo
## -1 +1 ##
-/trunk:4611-4632,4636-4657,4671-4672,4674-4676,4682,4684-4699,4704-4706,4713,4736-4741,4754,4756-4771,4775,4777-4780,4782-4785,4795,4811-4820,4822-4824,4828-4835,4840-4844,4865-4872,4885-4887,4890,4893-4895
+/trunk:4611-4632,4636-4657,4671-4672,4674-4676,4682,4684-4699,4704-4706,4713,4736-4741,4754,4756-4771,4775,4777-4780,4782-4785,4795,4811-4820,4822-4824,4828-4835,4840-4844,4865-4872,4885-4887,4890-4891,4893-4895
\ No newline at end of property
Modified: branches/stable-1.2/src/core/nginx.c
===================================================================
--- branches/stable-1.2/src/core/nginx.c	2012-11-13 10:45:23 UTC (rev 4906)
+++ branches/stable-1.2/src/core/nginx.c	2012-11-13 11:00:37 UTC (rev 4907)
@@ -21,6 +21,8 @@
 static char *ngx_set_priority(ngx_conf_t *cf, ngx_command_t *cmd, void *conf);
 static char *ngx_set_cpu_affinity(ngx_conf_t *cf, ngx_command_t *cmd,
     void *conf);
+static char *ngx_set_worker_processes(ngx_conf_t *cf, ngx_command_t *cmd,
+    void *conf);
 
 
 static ngx_conf_enum_t  ngx_debug_points[] = {
@@ -69,9 +71,9 @@
 
     { ngx_string("worker_processes"),
       NGX_MAIN_CONF|NGX_DIRECT_CONF|NGX_CONF_TAKE1,
-      ngx_conf_set_num_slot,
+      ngx_set_worker_processes,
       0,
-      offsetof(ngx_core_conf_t, worker_processes),
+      0,
       NULL },
 
     { ngx_string("debug_points"),
@@ -1329,3 +1331,32 @@
 
     return ccf->cpu_affinity[ccf->cpu_affinity_n - 1];
 }
+
+
+static char *
+ngx_set_worker_processes(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
+{
+    ngx_str_t        *value;
+    ngx_core_conf_t  *ccf;
+
+    ccf = (ngx_core_conf_t *) conf;
+
+    if (ccf->worker_processes != NGX_CONF_UNSET) {
+        return "is duplicate";
+    }
+
+    value = (ngx_str_t *) cf->args->elts;
+
+    if (ngx_strcmp(value[1].data, "auto") == 0) {
+        ccf->worker_processes = ngx_ncpu;
+        return NGX_CONF_OK;
+    }
+
+    ccf->worker_processes = ngx_atoi(value[1].data, value[1].len);
+
+    if (ccf->worker_processes == NGX_ERROR) {
+        return "invalid value";
+    }
+
+    return NGX_CONF_OK;
+}



More information about the nginx-devel mailing list