diff options
Diffstat (limited to 'src/os/unix')
-rw-r--r-- | src/os/unix/ngx_channel.c | 14 | ||||
-rw-r--r-- | src/os/unix/ngx_channel.h | 1 | ||||
-rw-r--r-- | src/os/unix/ngx_freebsd_init.c | 8 | ||||
-rw-r--r-- | src/os/unix/ngx_linux.h | 2 | ||||
-rw-r--r-- | src/os/unix/ngx_linux_init.c | 20 | ||||
-rw-r--r-- | src/os/unix/ngx_process.c | 18 | ||||
-rw-r--r-- | src/os/unix/ngx_process.h | 1 | ||||
-rw-r--r-- | src/os/unix/ngx_process_cycle.c | 4 | ||||
-rw-r--r-- | src/os/unix/ngx_pthread_thread.c | 4 | ||||
-rw-r--r-- | src/os/unix/ngx_solaris_init.c | 9 |
10 files changed, 57 insertions, 24 deletions
diff --git a/src/os/unix/ngx_channel.c b/src/os/unix/ngx_channel.c index 01416d6ab..694b1d83c 100644 --- a/src/os/unix/ngx_channel.c +++ b/src/os/unix/ngx_channel.c @@ -205,7 +205,7 @@ ngx_int_t ngx_add_channel_event(ngx_cycle_t *cycle, ngx_fd_t fd, ev->event_handler = handler; - if (ngx_add_conn) { + if (ngx_add_conn && (ngx_event_flags & NGX_USE_EPOLL_EVENT) == 0) { if (ngx_add_conn(c) == NGX_ERROR) { return NGX_ERROR; } @@ -218,3 +218,15 @@ ngx_int_t ngx_add_channel_event(ngx_cycle_t *cycle, ngx_fd_t fd, return NGX_OK; } + + +void ngx_close_channel(ngx_fd_t *fd, ngx_log_t *log) +{ + if (close(fd[0]) == -1) { + ngx_log_error(NGX_LOG_ALERT, log, ngx_errno, "close() failed"); + } + + if (close(fd[1]) == -1) { + ngx_log_error(NGX_LOG_ALERT, log, ngx_errno, "close() failed"); + } +} diff --git a/src/os/unix/ngx_channel.h b/src/os/unix/ngx_channel.h index ffa2ed4c8..276825232 100644 --- a/src/os/unix/ngx_channel.h +++ b/src/os/unix/ngx_channel.h @@ -21,6 +21,7 @@ ngx_int_t ngx_read_channel(ngx_socket_t s, ngx_channel_t *ch, size_t size, ngx_log_t *log); ngx_int_t ngx_add_channel_event(ngx_cycle_t *cycle, ngx_fd_t fd, ngx_int_t event, ngx_event_handler_pt handler); +void ngx_close_channel(ngx_fd_t *fd, ngx_log_t *log); #endif /* _NGX_CHANNEL_H_INCLUDED_ */ diff --git a/src/os/unix/ngx_freebsd_init.c b/src/os/unix/ngx_freebsd_init.c index 5addd26a8..6e7db8565 100644 --- a/src/os/unix/ngx_freebsd_init.c +++ b/src/os/unix/ngx_freebsd_init.c @@ -84,7 +84,7 @@ int ngx_os_init(ngx_log_t *log) size = sizeof(ngx_freebsd_kern_ostype); if (sysctlbyname("kern.ostype", ngx_freebsd_kern_ostype, &size, NULL, 0) == -1) { - ngx_log_error(NGX_LOG_ALERT, log, errno, + ngx_log_error(NGX_LOG_ALERT, log, ngx_errno, "sysctlbyname(kern.ostype) failed"); return NGX_ERROR; } @@ -92,7 +92,7 @@ int ngx_os_init(ngx_log_t *log) size = sizeof(ngx_freebsd_kern_osrelease); if (sysctlbyname("kern.osrelease", ngx_freebsd_kern_osrelease, &size, NULL, 0) == -1) { - ngx_log_error(NGX_LOG_ALERT, log, errno, + ngx_log_error(NGX_LOG_ALERT, log, ngx_errno, "sysctlbyname(kern.osrelease) failed"); return NGX_ERROR; } @@ -104,7 +104,7 @@ int ngx_os_init(ngx_log_t *log) size = sizeof(int); if (sysctlbyname("kern.osreldate", &ngx_freebsd_kern_osreldate, &size, NULL, 0) == -1) { - ngx_log_error(NGX_LOG_ALERT, log, errno, + ngx_log_error(NGX_LOG_ALERT, log, ngx_errno, "sysctlbyname(kern.osreldate) failed"); return NGX_ERROR; } @@ -169,7 +169,7 @@ int ngx_os_init(ngx_log_t *log) size = sysctls[i].size; if (sysctlbyname(sysctls[i].name, sysctls[i].value, &size, NULL, 0) == -1) { - err = errno; + err = ngx_errno; if (err != NGX_ENOENT) { if (sysctls[i].value == &ngx_freebsd_machdep_hlt_logical_cpus) { continue; diff --git a/src/os/unix/ngx_linux.h b/src/os/unix/ngx_linux.h index a5fc9d907..b3e415571 100644 --- a/src/os/unix/ngx_linux.h +++ b/src/os/unix/ngx_linux.h @@ -5,5 +5,7 @@ ngx_chain_t *ngx_linux_sendfile_chain(ngx_connection_t *c, ngx_chain_t *in, off_t limit); +extern int ngx_linux_rtsig_max; + #endif /* _NGX_LINUX_H_INCLUDED_ */ diff --git a/src/os/unix/ngx_linux_init.c b/src/os/unix/ngx_linux_init.c index ea2e812be..9773e5626 100644 --- a/src/os/unix/ngx_linux_init.c +++ b/src/os/unix/ngx_linux_init.c @@ -6,6 +6,8 @@ char ngx_linux_kern_ostype[50]; char ngx_linux_kern_osrelease[20]; +int ngx_linux_rtsig_max; + ngx_os_io_t ngx_os_io = { ngx_unix_recv, @@ -23,14 +25,15 @@ ngx_os_io_t ngx_os_io = { int ngx_os_init(ngx_log_t *log) { - int name[2], len; + int name[2], len, rtsig_max; name[0] = CTL_KERN; name[1] = KERN_OSTYPE; len = sizeof(ngx_linux_kern_ostype); if (sysctl(name, sizeof(name), ngx_linux_kern_ostype, &len, NULL, 0) == -1) { - ngx_log_error(NGX_LOG_ALERT, log, errno, "sysctl(KERN_OSTYPE) failed"); + ngx_log_error(NGX_LOG_ALERT, log, ngx_errno, + "sysctl(KERN_OSTYPE) failed"); return NGX_ERROR; } @@ -39,7 +42,7 @@ int ngx_os_init(ngx_log_t *log) len = sizeof(ngx_linux_kern_osrelease); if (sysctl(name, sizeof(name), ngx_linux_kern_osrelease, &len, NULL, 0) == -1) { - ngx_log_error(NGX_LOG_ALERT, log, errno, + ngx_log_error(NGX_LOG_ALERT, log, ngx_errno, "sysctl(KERN_OSRELEASE) failed"); return NGX_ERROR; } @@ -48,5 +51,16 @@ int ngx_os_init(ngx_log_t *log) ngx_linux_kern_ostype, ngx_linux_kern_osrelease); + name[0] = CTL_KERN; + name[1] = KERN_RTSIGMAX; + len = sizeof(rtsig_max); + if (sysctl(name, sizeof(name), &rtsig_max, &len, NULL, 0) == -1) { + ngx_log_error(NGX_LOG_INFO, log, ngx_errno, + "sysctl(KERN_RTSIGMAX) failed"); + } else { + ngx_linux_rtsig_max = 1; + } + + return ngx_posix_init(log); } diff --git a/src/os/unix/ngx_process.c b/src/os/unix/ngx_process.c index cd160c233..cd6fd2f1e 100644 --- a/src/os/unix/ngx_process.c +++ b/src/os/unix/ngx_process.c @@ -2,6 +2,7 @@ #include <ngx_config.h> #include <ngx_core.h> #include <ngx_event.h> +#include <ngx_channel.h> static void ngx_execute_proc(ngx_cycle_t *cycle, void *data); @@ -50,6 +51,11 @@ ngx_pid_t ngx_spawn_process(ngx_cycle_t *cycle, return NGX_ERROR; } + ngx_log_debug2(NGX_LOG_DEBUG_CORE, cycle->log, 0, + "channel %d:%d", + ngx_processes[s].channel[0], + ngx_processes[s].channel[1]); + if (ngx_nonblocking(ngx_processes[s].channel[0]) == -1) { ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno, ngx_nonblocking_n " failed while spawning \"%s\"", @@ -270,15 +276,3 @@ void ngx_process_get_status() } } } - - -void ngx_close_channel(ngx_fd_t *fd, ngx_log_t *log) -{ - if (close(fd[0]) == -1) { - ngx_log_error(NGX_LOG_ALERT, log, ngx_errno, "close() failed"); - } - - if (close(fd[1]) == -1) { - ngx_log_error(NGX_LOG_ALERT, log, ngx_errno, "close() failed"); - } -} diff --git a/src/os/unix/ngx_process.h b/src/os/unix/ngx_process.h index 66ef38d57..31549062c 100644 --- a/src/os/unix/ngx_process.h +++ b/src/os/unix/ngx_process.h @@ -47,7 +47,6 @@ ngx_pid_t ngx_spawn_process(ngx_cycle_t *cycle, char *name, ngx_int_t respawn); ngx_pid_t ngx_execute(ngx_cycle_t *cycle, ngx_exec_ctx_t *ctx); void ngx_process_get_status(void); -void ngx_close_channel(ngx_fd_t *fd, ngx_log_t *log); #define ngx_sched_yield() sched_yield() diff --git a/src/os/unix/ngx_process_cycle.c b/src/os/unix/ngx_process_cycle.c index 4ff2bae01..941bc4287 100644 --- a/src/os/unix/ngx_process_cycle.c +++ b/src/os/unix/ngx_process_cycle.c @@ -614,6 +614,10 @@ static void ngx_worker_process_cycle(ngx_cycle_t *cycle, void *data) continue; } + if (n == ngx_process_slot) { + continue; + } + if (close(ngx_processes[n].channel[1]) == -1) { ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno, "close() failed"); diff --git a/src/os/unix/ngx_pthread_thread.c b/src/os/unix/ngx_pthread_thread.c index d5d816f2e..621565621 100644 --- a/src/os/unix/ngx_pthread_thread.c +++ b/src/os/unix/ngx_pthread_thread.c @@ -146,6 +146,10 @@ ngx_int_t ngx_mutex_trylock(ngx_mutex_t *m) err = pthread_mutex_trylock(&m->mutex); + if (err == NGX_EBUSY) { + return NGX_AGAIN; + } + if (err != 0) { ngx_log_error(NGX_LOG_ALERT, m->log, err, "pthread_mutex_trylock(" PTR_FMT ") failed", m); diff --git a/src/os/unix/ngx_solaris_init.c b/src/os/unix/ngx_solaris_init.c index 8f2e484b2..59db3d870 100644 --- a/src/os/unix/ngx_solaris_init.c +++ b/src/os/unix/ngx_solaris_init.c @@ -27,21 +27,24 @@ int ngx_os_init(ngx_log_t *log) if (sysinfo(SI_SYSNAME, ngx_solaris_sysname, sizeof(ngx_solaris_sysname)) == -1) { - ngx_log_error(NGX_LOG_ALERT, log, errno, "sysinfo(SI_SYSNAME) failed"); + ngx_log_error(NGX_LOG_ALERT, log, ngx_errno, + "sysinfo(SI_SYSNAME) failed"); return NGX_ERROR; } if (sysinfo(SI_RELEASE, ngx_solaris_release, sizeof(ngx_solaris_release)) == -1) { - ngx_log_error(NGX_LOG_ALERT, log, errno, "sysinfo(SI_RELEASE) failed"); + ngx_log_error(NGX_LOG_ALERT, log, ngx_errno, + "sysinfo(SI_RELEASE) failed"); return NGX_ERROR; } if (sysinfo(SI_VERSION, ngx_solaris_version, sizeof(ngx_solaris_version)) == -1) { - ngx_log_error(NGX_LOG_ALERT, log, errno, "sysinfo(SI_SYSNAME) failed"); + ngx_log_error(NGX_LOG_ALERT, log, ngx_errno, + "sysinfo(SI_SYSNAME) failed"); return NGX_ERROR; } |