diff options
Diffstat (limited to '')
| -rw-r--r-- | src/os/unix/ngx_freebsd_config.h | 38 | ||||
| -rw-r--r-- | src/os/unix/ngx_linux_config.h | 43 | ||||
| -rw-r--r-- | src/os/unix/ngx_posix_config.h | 55 | ||||
| -rw-r--r-- | src/os/unix/ngx_posix_init.c | 20 | ||||
| -rw-r--r-- | src/os/unix/ngx_process.c | 2 | ||||
| -rw-r--r-- | src/os/unix/ngx_process.h | 1 | ||||
| -rw-r--r-- | src/os/unix/ngx_process_cycle.c | 23 | ||||
| -rw-r--r-- | src/os/unix/ngx_solaris_config.h | 38 |
8 files changed, 151 insertions, 69 deletions
diff --git a/src/os/unix/ngx_freebsd_config.h b/src/os/unix/ngx_freebsd_config.h index f0a8430fe..ce77ab938 100644 --- a/src/os/unix/ngx_freebsd_config.h +++ b/src/os/unix/ngx_freebsd_config.h @@ -2,35 +2,38 @@ #define _NGX_FREEBSD_CONFIG_H_INCLUDED_ +#include <sys/types.h> +#include <sys/time.h> #include <unistd.h> -#include <stddef.h> /* offsetof() */ -#include <stdlib.h> #include <stdarg.h> +#include <stddef.h> /* offsetof() */ #include <stdio.h> +#include <stdlib.h> #include <errno.h> -#include <fcntl.h> #include <string.h> #include <signal.h> -#include <limits.h> -#include <sys/types.h> -#include <sys/stat.h> -#include <sys/time.h> +#include <pwd.h> +#include <grp.h> +#include <dirent.h> + #include <sys/uio.h> -#include <sys/ioctl.h> -#include <sys/resource.h> -#include <sys/sysctl.h> +#include <sys/filio.h> /* FIONBIO */ +#include <sys/stat.h> +#include <fcntl.h> + #include <sys/wait.h> #include <sys/mman.h> +#include <sys/resource.h> + #include <sys/socket.h> #include <netinet/in.h> -#include <netinet/tcp.h> /* TCP_NOPUSH */ #include <arpa/inet.h> -#include <pwd.h> -#include <grp.h> #include <netdb.h> -#include <dirent.h> -#include <libutil.h> /* setproctitle() brefore 4.1 */ + +#include <libutil.h> /* setproctitle() before 4.1 */ #include <osreldate.h> +#include <sys/sysctl.h> +#include <netinet/tcp.h> /* TCP_NOPUSH */ #include <ngx_auto_config.h> @@ -89,11 +92,6 @@ pid_t rfork_thread(int flags, void *stack, int (*func)(void *arg), void *arg); #endif -#ifndef HAVE_FIONBIO -#define HAVE_FIONBIO 1 -#endif - - /* STUB: autoconf */ #define ngx_setproctitle setproctitle diff --git a/src/os/unix/ngx_linux_config.h b/src/os/unix/ngx_linux_config.h index 95cf54a34..2b6eb9cb3 100644 --- a/src/os/unix/ngx_linux_config.h +++ b/src/os/unix/ngx_linux_config.h @@ -8,35 +8,43 @@ #define _LARGEFILE_SOURCE +#include <sys/types.h> +#include <sys/time.h> #include <unistd.h> -#include <stddef.h> /* offsetof() */ -#include <stdlib.h> #include <stdarg.h> +#include <stddef.h> /* offsetof() */ #include <stdio.h> +#include <stdlib.h> #include <errno.h> -#include <fcntl.h> #include <string.h> #include <signal.h> -#include <limits.h> -#include <time.h> -#include <sys/types.h> -#include <sys/time.h> -#include <sys/select.h> +#include <pwd.h> +#include <grp.h> +#include <dirent.h> + #include <sys/uio.h> -#include <sys/ioctl.h> -#include <sys/resource.h> -#include <sys/sysctl.h> +#include <sys/stat.h> +#include <fcntl.h> + #include <sys/wait.h> #include <sys/mman.h> +#include <sys/resource.h> + #include <sys/socket.h> #include <netinet/in.h> -#include <netinet/tcp.h> /* TCP_CORK */ #include <arpa/inet.h> -#include <pwd.h> -#include <grp.h> #include <netdb.h> -#include <dirent.h> +#include <time.h> /* tzset() */ +#include <sys/ioctl.h> +#include <sys/sysctl.h> +#include <netinet/tcp.h> /* TCP_CORK */ + + +/* Linux has no <sys/filio.h> so autoconfigure does not find FIONBIO */ +#ifndef HAVE_FIONBIO +#define HAVE_FIONBIO 1 +#endif #include <ngx_auto_config.h> @@ -80,11 +88,6 @@ extern ssize_t sendfile(int s, int fd, int32_t *offset, size_t size); #endif -#ifndef HAVE_FIONBIO -#define HAVE_FIONBIO 1 -#endif - - #ifndef HAVE_SELECT_CHANGE_TIMEOUT #define HAVE_SELECT_CHANGE_TIMEOUT 1 #endif diff --git a/src/os/unix/ngx_posix_config.h b/src/os/unix/ngx_posix_config.h new file mode 100644 index 000000000..e6da52ffa --- /dev/null +++ b/src/os/unix/ngx_posix_config.h @@ -0,0 +1,55 @@ +#ifndef _NGX_POSIX_CONFIG_H_INCLUDED_ +#define _NGX_POSIX_CONFIG_H_INCLUDED_ + + +#include <sys/types.h> +#include <sys/time.h> +#include <unistd.h> +#include <stdarg.h> +#include <stddef.h> /* offsetof() */ +#include <stdio.h> +#include <stdlib.h> +#include <errno.h> +#include <string.h> +#include <signal.h> +#include <pwd.h> +#include <grp.h> +#include <dirent.h> + +#include <sys/uio.h> +#include <sys/filio.h> /* FIONBIO */ +#include <sys/stat.h> +#include <fcntl.h> + +#include <sys/wait.h> +#include <sys/mman.h> +#include <sys/resource.h> + +#include <sys/socket.h> +#include <netinet/in.h> +#include <arpa/inet.h> +#include <netdb.h> + +#include <ngx_auto_config.h> + + +#ifndef HAVE_SELECT +#define HAVE_SELECT 1 +#endif + + +#ifndef HAVE_POLL +#define HAVE_POLL 1 +#endif +#if (HAVE_POLL) +#include <poll.h> +#endif + + +#define ngx_setproctitle(title) + + +#define NGX_POSIX_IO 1 + + +#endif /* _NGX_POSIX_CONFIG_H_INCLUDED_ */ diff --git a/src/os/unix/ngx_posix_init.c b/src/os/unix/ngx_posix_init.c index e2ed96a90..f94ffffc6 100644 --- a/src/os/unix/ngx_posix_init.c +++ b/src/os/unix/ngx_posix_init.c @@ -7,6 +7,26 @@ int ngx_max_sockets; int ngx_inherited_nonblocking; +#if (NGX_POSIX_IO) + +ngx_os_io_t ngx_os_io = { + ngx_unix_recv, + ngx_readv_chain, + NULL, + ngx_writev_chain, + 0 +}; + + +int ngx_os_init(ngx_log_t *log) +{ + return ngx_posix_init(log); +} + + +#endif + + void ngx_signal_handler(int signo); diff --git a/src/os/unix/ngx_process.c b/src/os/unix/ngx_process.c index 81af78fca..3d05a35ea 100644 --- a/src/os/unix/ngx_process.c +++ b/src/os/unix/ngx_process.c @@ -6,6 +6,7 @@ static void ngx_execute_proc(ngx_cycle_t *cycle, void *data); +ngx_int_t ngx_current_slot; ngx_int_t ngx_last_process; ngx_socket_t ngx_channel; ngx_process_t ngx_processes[NGX_MAX_PROCESSES]; @@ -44,6 +45,7 @@ ngx_pid_t ngx_spawn_process(ngx_cycle_t *cycle, } ngx_channel = ngx_processes[s].channel[1]; + ngx_current_slot = s; pid = fork(); diff --git a/src/os/unix/ngx_process.h b/src/os/unix/ngx_process.h index 1ce39e5f6..9b7ae4448 100644 --- a/src/os/unix/ngx_process.h +++ b/src/os/unix/ngx_process.h @@ -49,6 +49,7 @@ ngx_pid_t ngx_execute(ngx_cycle_t *cycle, ngx_exec_ctx_t *ctx); void ngx_process_get_status(void); extern ngx_pid_t ngx_pid; +extern ngx_int_t ngx_current_slot; extern ngx_int_t ngx_last_process; extern ngx_socket_t ngx_channel; extern ngx_process_t ngx_processes[NGX_MAX_PROCESSES]; diff --git a/src/os/unix/ngx_process_cycle.c b/src/os/unix/ngx_process_cycle.c index d30e73812..262b769a4 100644 --- a/src/os/unix/ngx_process_cycle.c +++ b/src/os/unix/ngx_process_cycle.c @@ -527,10 +527,16 @@ static void ngx_worker_process_cycle(ngx_cycle_t *cycle, void *data) } } - for (n = 0; n < ngx_last_process; n++) { + for (n = 0; n <= ngx_last_process; n++) { - ngx_log_debug1(NGX_LOG_DEBUG_CORE, cycle->log, 0, - "close channel %d", ngx_processes[n].channel[1]); + if (n == ngx_current_slot) { + if (close(ngx_processes[n].channel[0]) == -1) { + ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno, + "close() failed"); + } + + continue; + } if (close(ngx_processes[n].channel[1]) == -1) { ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno, @@ -538,11 +544,6 @@ static void ngx_worker_process_cycle(ngx_cycle_t *cycle, void *data) } } - if (close(ngx_processes[ngx_last_process].channel[0]) == -1) { - ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno, - "close() failed"); - } - #if 0 ngx_last_process = 0; #endif @@ -737,7 +738,7 @@ ngx_int_t ngx_write_channel(ngx_socket_t s, ngx_channel_t *ch, size_t size, msg.msg_controllen = 0; } else { - msg.msg_control = &cm; + msg.msg_control = (caddr_t) &cm; msg.msg_controllen = sizeof(struct cmsghdr) + sizeof(int); cm.cmsg_len = sizeof(struct cmsghdr) + sizeof(int); @@ -802,7 +803,7 @@ ngx_int_t ngx_read_channel(ngx_socket_t s, ngx_channel_t *ch, size_t size, msg.msg_iovlen = 1; #if (HAVE_MSGHDR_MSG_CONTROL) - msg.msg_control = &cm; + msg.msg_control = (caddr_t) &cm; msg.msg_controllen = sizeof(struct cmsghdr) + sizeof(int); #else msg.msg_accrights = (caddr_t) &fd; @@ -830,7 +831,7 @@ ngx_int_t ngx_read_channel(ngx_socket_t s, ngx_channel_t *ch, size_t size, #if (HAVE_MSGHDR_MSG_CONTROL) if (ch->command == NGX_CMD_OPEN_CHANNEL) { - cm = msg.msg_control; + cm = (struct cmsghdr *) msg.msg_control; if (cm == NULL) { ngx_log_error(NGX_LOG_ALERT, log, 0, diff --git a/src/os/unix/ngx_solaris_config.h b/src/os/unix/ngx_solaris_config.h index 431841cff..b1e71cd4e 100644 --- a/src/os/unix/ngx_solaris_config.h +++ b/src/os/unix/ngx_solaris_config.h @@ -6,33 +6,40 @@ #define _REENTRANT -#define _FILE_OFFSET_BITS 64 /* must be before sys/types.h */ +#define _FILE_OFFSET_BITS 64 /* must be before <sys/types.h> */ +#include <sys/types.h> +#include <sys/time.h> #include <unistd.h> -#include <inttypes.h> -#include <stddef.h> /* offsetof() */ -#include <stdlib.h> #include <stdarg.h> +#include <stddef.h> /* offsetof() */ #include <stdio.h> +#include <stdlib.h> #include <errno.h> -#include <fcntl.h> #include <string.h> #include <signal.h> -#include <limits.h> -#include <sys/types.h> +#include <pwd.h> +#include <grp.h> +#include <dirent.h> + +#include <sys/uio.h> +#include <sys/filio.h> /* FIONBIO */ #include <sys/stat.h> +#include <fcntl.h> + #include <sys/wait.h> #include <sys/mman.h> +#include <sys/resource.h> + #include <sys/socket.h> -#include <sys/sendfile.h> -#include <sys/filio.h> /* FIONBIO */ -#include <sys/systeminfo.h> #include <netinet/in.h> #include <arpa/inet.h> -#include <pwd.h> -#include <grp.h> #include <netdb.h> -#include <dirent.h> + +#include <sys/sendfile.h> +#include <sys/systeminfo.h> +#include <limits.h> /* IOV_MAX */ +#include <inttypes.h> #include <ngx_auto_config.h> @@ -66,11 +73,6 @@ #endif -#ifndef HAVE_FIONBIO -#define HAVE_FIONBIO 1 -#endif - - #define ngx_setproctitle(title) |
