aboutsummaryrefslogtreecommitdiff
path: root/src/core/nginx.c
diff options
context:
space:
mode:
authorIgor Sysoev <igor@sysoev.ru>2005-09-23 11:02:22 +0000
committerIgor Sysoev <igor@sysoev.ru>2005-09-23 11:02:22 +0000
commit31eb8c015d58a5b36b9578d4ee6c217e16cb776f (patch)
tree28ebccc10deba4132e05414aac1874d5013fdf58 /src/core/nginx.c
parentf44a1f5f579e19441db2d477a7c81d8894ba2262 (diff)
downloadnginx-31eb8c015d58a5b36b9578d4ee6c217e16cb776f.tar.gz
nginx-31eb8c015d58a5b36b9578d4ee6c217e16cb776f.zip
nginx-0.2.0-RELEASE importrelease-0.2.0
*) The pid-file names used during online upgrade was changed and now is not required a manual rename operation. The old master process adds the ".oldbin" suffix to its pid-file and executes a new binary file. The new master process creates usual pid-file without the ".newbin" suffix. If the master process exits, then old master process renames back its pid-file with the ".oldbin" suffix to the pid-file without suffix. *) Change: the "worker_connections" directive, new name of the "connections" directive; now the directive specifies maximum number of connections, but not maximum socket descriptor number. *) Feature: SSL supports the session cache inside one worker process. *) Feature: the "satisfy_any" directive. *) Change: the ngx_http_access_module and ngx_http_auth_basic_module do not run for subrequests. *) Feature: the "worker_rlimit_nofile" and "worker_rlimit_sigpending" directives. *) Bugfix: if all backend using in load-balancing failed after one error, then nginx did not try do connect to them during 60 seconds. *) Bugfix: in IMAP/POP3 command argument parsing. Thanks to Rob Mueller. *) Bugfix: errors while using SSL in IMAP/POP3 proxy. *) Bugfix: errors while using SSI and gzipping. *) Bugfix: the "Expires" and "Cache-Control" header lines were omitted from the 304 responses. Thanks to Alexandr Kukushkin.
Diffstat (limited to 'src/core/nginx.c')
-rw-r--r--src/core/nginx.c106
1 files changed, 77 insertions, 29 deletions
diff --git a/src/core/nginx.c b/src/core/nginx.c
index 10db55540..09edae5b8 100644
--- a/src/core/nginx.c
+++ b/src/core/nginx.c
@@ -42,6 +42,13 @@ static ngx_command_t ngx_core_commands[] = {
offsetof(ngx_core_conf_t, master),
NULL },
+ { ngx_string("pid"),
+ NGX_MAIN_CONF|NGX_DIRECT_CONF|NGX_CONF_TAKE1,
+ ngx_conf_set_str_slot,
+ 0,
+ offsetof(ngx_core_conf_t, pid),
+ NULL },
+
{ ngx_string("worker_processes"),
NGX_MAIN_CONF|NGX_DIRECT_CONF|NGX_CONF_TAKE1,
ngx_conf_set_num_slot,
@@ -56,24 +63,6 @@ static ngx_command_t ngx_core_commands[] = {
offsetof(ngx_core_conf_t, debug_points),
&ngx_debug_points },
-#if (NGX_THREADS)
-
- { ngx_string("worker_threads"),
- NGX_MAIN_CONF|NGX_DIRECT_CONF|NGX_CONF_TAKE1,
- ngx_conf_set_num_slot,
- 0,
- offsetof(ngx_core_conf_t, worker_threads),
- NULL },
-
- { ngx_string("thread_stack_size"),
- NGX_MAIN_CONF|NGX_DIRECT_CONF|NGX_CONF_TAKE1,
- ngx_conf_set_size_slot,
- 0,
- offsetof(ngx_core_conf_t, thread_stack_size),
- NULL },
-
-#endif
-
{ ngx_string("user"),
NGX_MAIN_CONF|NGX_DIRECT_CONF|NGX_CONF_TAKE12,
ngx_set_user,
@@ -88,11 +77,18 @@ static ngx_command_t ngx_core_commands[] = {
0,
NULL },
- { ngx_string("pid"),
+ { ngx_string("worker_rlimit_nofile"),
NGX_MAIN_CONF|NGX_DIRECT_CONF|NGX_CONF_TAKE1,
- ngx_conf_set_str_slot,
+ ngx_conf_set_num_slot,
0,
- offsetof(ngx_core_conf_t, pid),
+ offsetof(ngx_core_conf_t, rlimit_nofile),
+ NULL },
+
+ { ngx_string("worker_rlimit_sigpending"),
+ NGX_MAIN_CONF|NGX_DIRECT_CONF|NGX_CONF_TAKE1,
+ ngx_conf_set_num_slot,
+ 0,
+ offsetof(ngx_core_conf_t, rlimit_sigpending),
NULL },
{ ngx_string("working_directory"),
@@ -102,6 +98,24 @@ static ngx_command_t ngx_core_commands[] = {
offsetof(ngx_core_conf_t, working_directory),
NULL },
+#if (NGX_THREADS)
+
+ { ngx_string("worker_threads"),
+ NGX_MAIN_CONF|NGX_DIRECT_CONF|NGX_CONF_TAKE1,
+ ngx_conf_set_num_slot,
+ 0,
+ offsetof(ngx_core_conf_t, worker_threads),
+ NULL },
+
+ { ngx_string("thread_stack_size"),
+ NGX_MAIN_CONF|NGX_DIRECT_CONF|NGX_CONF_TAKE1,
+ ngx_conf_set_size_slot,
+ 0,
+ offsetof(ngx_core_conf_t, thread_stack_size),
+ NULL },
+
+#endif
+
ngx_null_command
};
@@ -324,13 +338,15 @@ ngx_add_inherited_sockets(ngx_cycle_t *cycle)
}
-ngx_pid_t ngx_exec_new_binary(ngx_cycle_t *cycle, char *const *argv)
+ngx_pid_t
+ngx_exec_new_binary(ngx_cycle_t *cycle, char *const *argv)
{
char *env[3], *var;
u_char *p;
ngx_uint_t i;
ngx_pid_t pid;
ngx_exec_ctx_t ctx;
+ ngx_core_conf_t *ccf;
ngx_listening_t *ls;
ctx.path = argv[0];
@@ -374,15 +390,42 @@ ngx_pid_t ngx_exec_new_binary(ngx_cycle_t *cycle, char *const *argv)
ctx.envp = (char *const *) &env;
+ ccf = (ngx_core_conf_t *) ngx_get_conf(cycle->conf_ctx, ngx_core_module);
+
+ if (ngx_rename_file((char *) ccf->pid.data, (char *) ccf->oldpid.data)
+ != NGX_OK)
+ {
+ ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno,
+ ngx_rename_file_n " %s to %s failed "
+ "before executing new binary process \"%s\"",
+ ccf->pid.data, ccf->oldpid.data, argv[0]);
+
+ ngx_free(var);
+
+ return NGX_INVALID_PID;
+ }
+
pid = ngx_execute(cycle, &ctx);
+ if (pid == NGX_INVALID_PID) {
+ if (ngx_rename_file((char *) ccf->oldpid.data, (char *) ccf->pid.data)
+ != NGX_OK)
+ {
+ ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno,
+ ngx_rename_file_n " %s back to %s failed "
+ "after try to executing new binary process \"%s\"",
+ ccf->oldpid.data, ccf->pid.data, argv[0]);
+ }
+ }
+
ngx_free(var);
return pid;
}
-static ngx_int_t ngx_getopt(ngx_cycle_t *cycle, int argc, char *const *argv)
+static ngx_int_t
+ngx_getopt(ngx_cycle_t *cycle, int argc, char *const *argv)
{
ngx_int_t i;
@@ -485,7 +528,7 @@ ngx_core_module_create_conf(ngx_cycle_t *cycle)
* set by pcalloc()
*
* ccf->pid = NULL;
- * ccf->newpid = NULL;
+ * ccf->oldpid = NULL;
* ccf->priority = 0;
*/
@@ -493,8 +536,13 @@ ngx_core_module_create_conf(ngx_cycle_t *cycle)
ccf->master = NGX_CONF_UNSET;
ccf->worker_processes = NGX_CONF_UNSET;
ccf->debug_points = NGX_CONF_UNSET;
+
+ ccf->rlimit_nofile = NGX_CONF_UNSET;
+ ccf->rlimit_sigpending = NGX_CONF_UNSET;
+
ccf->user = (ngx_uid_t) NGX_CONF_UNSET_UINT;
ccf->group = (ngx_gid_t) NGX_CONF_UNSET_UINT;
+
#if (NGX_THREADS)
ccf->worker_threads = NGX_CONF_UNSET;
ccf->thread_stack_size = NGX_CONF_UNSET_SIZE;
@@ -558,15 +606,15 @@ ngx_core_module_init_conf(ngx_cycle_t *cycle, void *conf)
return NGX_CONF_ERROR;
}
- ccf->newpid.len = ccf->pid.len + sizeof(NGX_NEWPID_EXT);
+ ccf->oldpid.len = ccf->pid.len + sizeof(NGX_OLDPID_EXT);
- ccf->newpid.data = ngx_palloc(cycle->pool, ccf->newpid.len);
- if (ccf->newpid.data == NULL) {
+ ccf->oldpid.data = ngx_palloc(cycle->pool, ccf->oldpid.len);
+ if (ccf->oldpid.data == NULL) {
return NGX_CONF_ERROR;
}
- ngx_memcpy(ngx_cpymem(ccf->newpid.data, ccf->pid.data, ccf->pid.len),
- NGX_NEWPID_EXT, sizeof(NGX_NEWPID_EXT));
+ ngx_memcpy(ngx_cpymem(ccf->oldpid.data, ccf->pid.data, ccf->pid.len),
+ NGX_OLDPID_EXT, sizeof(NGX_OLDPID_EXT));
#endif