ngx_binext=".exe"
ngx_long_start='@<<
- '
+ '
ngx_long_end='<<'
ngx_long_regex_cont=' \
'
# Copyright (C) Igor Sysoev
-case $USE_THREADS in
- NO) OPENSSL_OPT="$OPENSSL_OPT no-threads" ;;
- *) OPENSSL_OPT="$OPENSSL_OPT threads" ;;
-esac
-
case "$CC" in
cl)
;;
- cl | bcc32)
+ bcc32)
ngx_opt=`echo "-DOPENSSL=\"$OPENSSL\" -DOPENSSL_OPT=\"$OPENSSL_OPT\"" \
| sed -e "s/\//$ngx_regex_dirsep/g"`
;;
*)
- case $OPENSSL in
-
- /*)
- ngx_prefix="$OPENSSL/openssl"
- ;;
-
- *)
- ngx_prefix="$PWD/$OPENSSL/openssl"
- ;;
+ case $USE_THREADS in
+ NO) OPENSSL_OPT="$OPENSSL_OPT no-threads" ;;
+ *) OPENSSL_OPT="$OPENSSL_OPT threads" ;;
+ esac
+ case $OPENSSL in
+ /*) ngx_prefix="$OPENSSL/openssl" ;;
+ *) ngx_prefix="$PWD/$OPENSSL/openssl" ;;
esac
cat << END >> $NGX_MAKEFILE
return 0;
}
+ if (ngx_signal) {
+ return ngx_signal_process(cycle, ngx_signal);
+ }
+
ngx_os_status(cycle->log);
ngx_cycle = cycle;
ngx_process = NGX_PROCESS_MASTER;
}
- if (ngx_signal) {
- return ngx_signal_process(cycle, ngx_signal);
- }
-
#if !(NGX_WIN32)
if (ngx_init_signals(cycle->log) != NGX_OK) {
static ngx_int_t ngx_conf_handler(ngx_conf_t *cf, ngx_int_t last);
static ngx_int_t ngx_conf_read_token(ngx_conf_t *cf);
static char *ngx_conf_include(ngx_conf_t *cf, ngx_command_t *cmd, void *conf);
+static ngx_int_t ngx_conf_test_full_name(ngx_str_t *name);
static void ngx_conf_flush_files(ngx_cycle_t *cycle);
ngx_conf_full_name(ngx_cycle_t *cycle, ngx_str_t *name, ngx_uint_t conf_prefix)
{
size_t len;
- u_char *p, *prefix;
- ngx_str_t old;
+ u_char *p, *n, *prefix;
+ ngx_int_t rc;
-#if (NGX_WIN32)
+ rc = ngx_conf_test_full_name(name);
- if (name->len > 2
- && name->data[1] == ':'
- && ((name->data[0] >= 'a' && name->data[0] <= 'z')
- || (name->data[0] >= 'A' && name->data[0] <= 'Z')))
- {
- return NGX_OK;
+ if (rc == NGX_OK) {
+ return rc;
}
-#else
-
- if (name->data[0] == '/') {
- return NGX_OK;
- }
-
-#endif
-
- old = *name;
-
if (conf_prefix) {
len = cycle->conf_prefix.len;
prefix = cycle->conf_prefix.data;
prefix = cycle->prefix.data;
}
- name->len = len + old.len;
- name->data = ngx_pnalloc(cycle->pool, name->len + 1);
- if (name->data == NULL) {
+#if (NGX_WIN32)
+
+ if (rc == 2) {
+ len = rc;
+ }
+
+#endif
+
+ n = ngx_pnalloc(cycle->pool, len + name->len + 1);
+ if (n == NULL) {
return NGX_ERROR;
}
- p = ngx_cpymem(name->data, prefix, len);
- ngx_cpystrn(p, old.data, old.len + 1);
+ p = ngx_cpymem(n, prefix, len);
+ ngx_cpystrn(p, name->data, name->len + 1);
+
+ name->len += len;
+ name->data = n;
return NGX_OK;
}
+static ngx_int_t
+ngx_conf_test_full_name(ngx_str_t *name)
+{
+#if (NGX_WIN32)
+ u_char c0, c1;
+
+ c0 = name->data[0];
+
+ if (name->len < 2) {
+ if (c0 == '/') {
+ return 2;
+ }
+
+ return NGX_DECLINED;
+ }
+
+ c1 = name->data[1];
+
+ if (c1 == ':') {
+ c0 |= 0x20;
+
+ if ((c0 >= 'a' && c0 <= 'z')) {
+ return NGX_OK;
+ }
+
+ return NGX_DECLINED;
+ }
+
+ if (c1 == '/') {
+ return NGX_OK;
+ }
+
+ if (c0 == '/') {
+ return 2;
+ }
+
+ return NGX_DECLINED;
+
+#else
+
+ if (name->data[0] == '/') {
+ return NGX_OK;
+ }
+
+ return NGX_DECLINED;
+
+#endif
+}
+
+
ngx_open_file_t *
ngx_conf_open_file(ngx_cycle_t *cycle, ngx_str_t *name)
{
ngx_log_error(NGX_LOG_EMERG, cycle->log, ngx_socket_errno,
ngx_close_socket_n " %V failed", &ls[i].addr_text);
}
+
+ ls[i].fd = (ngx_socket_t) -1;
}
}
cycle->conf_file.data);
}
-
for (i = 0; ngx_modules[i]; i++) {
if (ngx_modules[i]->type != NGX_CORE_MODULE) {
continue;
}
}
+ if (ngx_process == NGX_PROCESS_SIGNALLER) {
+ return cycle;
+ }
ccf = (ngx_core_conf_t *) ngx_get_conf(cycle->conf_ctx, ngx_core_module);
goto failed;
}
- if (!shm_zone[i].shm.exists) {
-
- if (ngx_init_zone_pool(cycle, &shm_zone[i]) != NGX_OK) {
- goto failed;
- }
+ if (ngx_init_zone_pool(cycle, &shm_zone[i]) != NGX_OK) {
+ goto failed;
}
if (shm_zone[i].init(&shm_zone[i], NULL) != NGX_OK) {
}
}
- if (ngx_process != NGX_PROCESS_SIGNALLER) {
- if (ngx_open_listening_sockets(cycle) != NGX_OK) {
- goto failed;
- }
+ if (ngx_open_listening_sockets(cycle) != NGX_OK) {
+ goto failed;
+ }
- if (!ngx_test_config) {
- ngx_configure_listening_sockets(cycle);
- }
+ if (!ngx_test_config) {
+ ngx_configure_listening_sockets(cycle);
}
ls = old_cycle->listening.elts;
for (i = 0; i < old_cycle->listening.nelts; i++) {
- if (ls[i].remain) {
+
+ if (ls[i].remain || ls[i].fd == -1) {
continue;
}
sp = (ngx_slab_pool_t *) zn->shm.addr;
+ if (zn->shm.exists) {
+
+ if (sp == sp->addr) {
+ return NGX_OK;
+ }
+
+ ngx_log_error(NGX_LOG_EMERG, cycle->log, 0,
+ "shared zone \"%V\" has no equal addresses: %p vs %p",
+ &zn->shm.name, sp->addr, sp);
+ return NGX_ERROR;
+ }
+
sp->end = zn->shm.addr + zn->shm.size;
sp->min_shift = 3;
+ sp->addr = zn->shm.addr;
#if (NGX_HAVE_ATOMIC_OPS)
err = ngx_errno;
- if (err == NGX_ENOENT) {
-
+ if (err
+#if (NGX_WIN32)
+ == ERROR_PATH_NOT_FOUND
+#else
+ == NGX_ENOENT
+#endif
+ )
+ {
if (!ext->create_path) {
goto failed;
}
u_char zero;
void *data;
+ void *addr;
} ngx_slab_pool_t;
for ( ;; ) {
num = ngx_next_temp_number(collision);
- ngx_sprintf(name + to->len, ".%0muA.DELETE", num);
+ ngx_sprintf(name + to->len, ".%0muA.DELETE%Z", num);
if (MoveFile((const char *) to->data, (const char *) name) != 0) {
break;
collision = 1;
- ngx_log_error(NGX_LOG_CRIT, log, ngx_errno, "MoveFile() failed");
+ ngx_log_error(NGX_LOG_CRIT, log, ngx_errno,
+ "MoveFile() \"%s\" to \"%s\" failed", to->data, name);
}
if (MoveFile((const char *) from->data, (const char *) to->data) == 0) {
}
if (DeleteFile((const char *) name) == 0) {
- ngx_log_error(NGX_LOG_CRIT, log, ngx_errno, "DeleteFile() failed");
+ ngx_log_error(NGX_LOG_CRIT, log, ngx_errno,
+ "DeleteFile() \"%s\" failed", name);
}
if (rc == NGX_ERROR) {
- ngx_log_error(NGX_LOG_CRIT, log, ngx_errno, "MoveFile() failed");
+ ngx_log_error(NGX_LOG_CRIT, log, ngx_errno,
+ "MoveFile() \"%s\" to \"%s\" failed",
+ from->data, to->data);
}
/* mutex_unlock() */
ngx_pid_t
ngx_spawn_process(ngx_cycle_t *cycle, char *name, ngx_int_t respawn)
{
- u_long rc, n;
+ u_long rc, n, code;
ngx_int_t s;
ngx_pid_t pid;
ngx_exec_ctx_t ctx;
+ HANDLE events[2];
char file[MAX_PATH + 1];
if (respawn >= 0) {
ngx_sprintf(ngx_processes[s].reopen_event, "ngx_%s_reopen_%ul%Z",
name, pid);
- rc = WaitForSingleObject(ngx_master_process_event, 5000);
+ events[0] = ngx_master_process_event;
+ events[1] = ctx.child;
+
+ rc = WaitForMultipleObjects(2, events, 0, 5000);
ngx_time_update(0, 0);
ngx_log_debug1(NGX_LOG_DEBUG_CORE, cycle->log, 0,
- "WaitForSingleObject: %ul", rc);
+ "WaitForMultipleObjects: %ul", rc);
switch (rc) {
break;
+ case WAIT_OBJECT_0 + 1:
+ if (GetExitCodeProcess(ctx.child, &code) == 0) {
+ ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno,
+ "GetExitCodeProcess(%P) failed", pid);
+ }
+
+ ngx_log_error(NGX_LOG_ALERT, cycle->log, 0,
+ "%s process %P exited with code %Xul",
+ name, pid, code);
+
+ goto failed;
+
case WAIT_TIMEOUT:
ngx_log_error(NGX_LOG_ALERT, cycle->log, 0,
"the event \"%s\" was not signaled for 5s",
static void ngx_console_init(ngx_cycle_t *cycle);
static int __stdcall ngx_console_handler(u_long type);
static ngx_int_t ngx_create_events(ngx_cycle_t *cycle);
-static void ngx_start_worker_processes(ngx_cycle_t *cycle, ngx_int_t type);
+static ngx_int_t ngx_start_worker_processes(ngx_cycle_t *cycle, ngx_int_t type);
static void ngx_reopen_worker_processes(ngx_cycle_t *cycle);
static void ngx_quit_worker_processes(ngx_cycle_t *cycle, ngx_uint_t old);
static void ngx_terminate_worker_processes(ngx_cycle_t *cycle);
ngx_close_listening_sockets(cycle);
- ngx_start_worker_processes(cycle, NGX_PROCESS_RESPAWN);
+ if (ngx_start_worker_processes(cycle, NGX_PROCESS_RESPAWN) == 0) {
+ exit(2);
+ }
timer = 0;
timeout = INFINITE;
ngx_cycle = cycle;
- ngx_start_worker_processes(cycle, NGX_PROCESS_JUST_RESPAWN);
- ngx_quit_worker_processes(cycle, 1);
+ ngx_close_listening_sockets(cycle);
+
+ if (ngx_start_worker_processes(cycle, NGX_PROCESS_JUST_RESPAWN)) {
+ ngx_quit_worker_processes(cycle, 1);
+ }
continue;
}
}
-static void
+static ngx_int_t
ngx_start_worker_processes(ngx_cycle_t *cycle, ngx_int_t type)
{
ngx_int_t n;
for (n = 0; n < ccf->worker_processes; n++) {
if (ngx_spawn_process(cycle, "worker", type) == NGX_INVALID_PID) {
- return;
+ break;
}
}
+
+ return n;
}
for (n = 0; n < ngx_last_process; n++) {
ngx_log_debug5(NGX_LOG_DEBUG_CORE, cycle->log, 0,
- "process: %d %P %p e:%d t:%d r:%d j:%d",
+ "process: %d %P %p e:%d j:%d",
n,
ngx_processes[n].pid,
ngx_processes[n].handle,
}
if (GetExitCodeProcess(h, &code) == 0) {
- ngx_log_error(NGX_LOG_ALERT, cycle->log, 0,
+ ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno,
"GetExitCodeProcess(%P) failed",
ngx_processes[n].pid);
}
for (n = 0; n < ngx_last_process; n++) {
ngx_log_debug5(NGX_LOG_DEBUG_CORE, cycle->log, 0,
- "process: %d %P %p e:%d t:%d r:%d j:%d",
+ "process: %d %P %p e:%d j:%d",
n,
ngx_processes[n].pid,
ngx_processes[n].handle,
ngx_int_t
ngx_shm_alloc(ngx_shm_t *shm)
{
- u_char *name;
+ u_char *name;
+ uint64_t size;
name = ngx_alloc(shm->name.len + 2 + sizeof(NGX_INT32_LEN), shm->log);
if (name == NULL) {
return NGX_ERROR;
}
- ngx_sprintf(name, "%V_%s%Z", &shm->name, ngx_unique);
+ (void) ngx_sprintf(name, "%V_%s%Z", &shm->name, ngx_unique);
ngx_set_errno(0);
+ size = shm->size;
+
shm->handle = CreateFileMapping(INVALID_HANDLE_VALUE, NULL, PAGE_READWRITE,
- 0, shm->size, (char *) name);
+ (u_long) (size >> 32),
+ (u_long) (size & 0xffffffff),
+ (char *) name);
if (shm->handle == NULL) {
ngx_log_error(NGX_LOG_ALERT, shm->log, ngx_errno,
"CreateFileMapping(%uz, %s) failed",
- shm->size, shm->name.data);
- goto failed;
+ shm->size, name);
+ ngx_free(name);
+
+ return NGX_ERROR;
}
+ ngx_free(name);
+
if (ngx_errno == ERROR_ALREADY_EXISTS) {
shm->exists = 1;
}
}
ngx_log_error(NGX_LOG_ALERT, shm->log, ngx_errno,
- "MapViewOfFile(%uz) failed", shm->size);
+ "MapViewOfFile(%uz) of file mapping \"%V\" failed",
+ shm->size, &shm->name);
if (CloseHandle(shm->handle) == 0) {
ngx_log_error(NGX_LOG_ALERT, shm->log, ngx_errno,
- "CloseHandle() failed");
+ "CloseHandle() of file mapping \"%V\" failed",
+ &shm->name);
}
-failed:
-
- ngx_free(name);
-
return NGX_ERROR;
}
{
if (UnmapViewOfFile(shm->addr) == 0) {
ngx_log_error(NGX_LOG_ALERT, shm->log, ngx_errno,
- "UnmapViewOfFile(%p) failed", shm->addr);
+ "UnmapViewOfFile(%p) of file mapping \"%V\" failed",
+ shm->addr, &shm->name);
}
if (CloseHandle(shm->handle) == 0) {
ngx_log_error(NGX_LOG_ALERT, shm->log, ngx_errno,
- "CloseHandle() failed");
+ "CloseHandle() of file mapping \"%V\" failed",
+ &shm->name);
}
}