nginx-0.0.7-2004-06-15-21:47:16 import

This commit is contained in:
Igor Sysoev 2004-06-15 17:47:16 +00:00
parent 87350f269d
commit d09f7a1e9a
18 changed files with 206 additions and 102 deletions

View File

@ -5,10 +5,11 @@ echo "checking for $ngx_func" >> $NGX_ERR
ngx_found=no ngx_found=no
func=`echo $ngx_func | sed -e 's/()$//' | tr '[a-z]' '[A-Z]'` func=`echo $ngx_func | sed -e 's/()$//' | tr '[a-z.]' '[A-Z_]'`
cat << END > $NGX_AUTOTEST.c cat << END > $NGX_AUTOTEST.c
#include <sys/types.h>
$NGX_UNISTD_H $NGX_UNISTD_H
$ngx_func_inc $ngx_func_inc

View File

@ -45,4 +45,10 @@ case $PLATFORM in
CORE_LIBS="$CORE_LIBS ws2_32.lib" CORE_LIBS="$CORE_LIBS ws2_32.lib"
;; ;;
*)
CORE_INCS="$UNIX_INCS"
CORE_DEPS="$UNIX_DEPS $POSIX_DEPS"
CORE_SRCS="$UNIX_SRCS"
;;
esac esac

View File

@ -66,6 +66,3 @@ if [ $EVENT_AIO = YES ]; then
else else
have=HAVE_AIO . auto/nohave have=HAVE_AIO . auto/nohave
fi fi
have=HAVE_MSGHDR_MSG_CONTROL . auto/have

View File

@ -77,6 +77,3 @@ ngx_func_test="prctl(PR_SET_DUMPABLE, 1, 0, 0, 0)"
if [ $ngx_found = yes ]; then if [ $ngx_found = yes ]; then
have=HAVE_PR_SET_DUMPABLE . auto/have have=HAVE_PR_SET_DUMPABLE . auto/have
fi fi
have=HAVE_MSGHDR_MSG_CONTROL . auto/have

View File

@ -125,6 +125,8 @@ UNIX_SRCS="$CORE_SRCS $EVENT_SRCS \
src/os/unix/ngx_posix_init.c \ src/os/unix/ngx_posix_init.c \
src/os/unix/ngx_process_cycle.c" src/os/unix/ngx_process_cycle.c"
POSIX_DEPS=src/os/unix/ngx_posix_config.h
FREEBSD_DEPS=src/os/unix/ngx_freebsd_config.h FREEBSD_DEPS=src/os/unix/ngx_freebsd_config.h
FREEBSD_SRCS=src/os/unix/ngx_freebsd_init.c FREEBSD_SRCS=src/os/unix/ngx_freebsd_init.c
FREEBSD_SENDFILE_SRCS=src/os/unix/ngx_freebsd_sendfile_chain.c FREEBSD_SENDFILE_SRCS=src/os/unix/ngx_freebsd_sendfile_chain.c

View File

@ -41,8 +41,7 @@ ngx_types="int"; . auto/types/typedef
ngx_func="sin_len" ngx_func="sin_len"
ngx_func_inc="#include <sys/types.h> ngx_func_inc="#include <sys/socket.h>
#include <sys/socket.h>
#include <netinet/in.h>" #include <netinet/in.h>"
ngx_func_test="struct sockaddr_in sa; sa.sin_len = 5" ngx_func_test="struct sockaddr_in sa; sa.sin_len = 5"
@ -122,3 +121,15 @@ ngx_func="memalign()"
ngx_func_inc="#include <stdlib.h>" ngx_func_inc="#include <stdlib.h>"
ngx_func_test="void *p; p = memalign(4096, 4096)" ngx_func_test="void *p; p = memalign(4096, 4096)"
. auto/func . auto/func
ngx_func="msghdr.msg_control"
ngx_func_inc="#include <sys/socket.h>"
ngx_func_test="struct msghdr msg; msg.msg_control = NULL"
. auto/func
ngx_func="FIONBIO"
ngx_func_inc="#include <sys/filio.h>"
ngx_func_test="int i; i = FIONBIO"
. auto/func

View File

@ -22,17 +22,11 @@
#elif defined _WIN32 #elif defined _WIN32
/* STUB to allocate a big ngx_connections */
#undef FD_SETSIZE
#define FD_SETSIZE 1024
#include <ngx_win32_config.h> #include <ngx_win32_config.h>
#else /* posix */ #else /* posix */
#include <ngx_posix_config.h>
#include <ngx_auto_config.h>
#endif #endif

View File

@ -596,12 +596,14 @@ static char *ngx_select_init_conf(ngx_cycle_t *cycle, void *conf)
/* disable warning: the default FD_SETSIZE is 1024U in FreeBSD 5.x */ /* disable warning: the default FD_SETSIZE is 1024U in FreeBSD 5.x */
#if !(WIN32)
if ((unsigned) ecf->connections > FD_SETSIZE) { if ((unsigned) ecf->connections > FD_SETSIZE) {
ngx_log_error(NGX_LOG_EMERG, cycle->log, 0, ngx_log_error(NGX_LOG_EMERG, cycle->log, 0,
"the maximum number of files " "the maximum number of files "
"supported by select() is " ngx_value(FD_SETSIZE)); "supported by select() is " ngx_value(FD_SETSIZE));
return NGX_CONF_ERROR; return NGX_CONF_ERROR;
} }
#endif
return NGX_CONF_OK; return NGX_CONF_OK;
} }

View File

@ -658,8 +658,12 @@ static char *ngx_event_init_conf(ngx_cycle_t *cycle, void *conf)
#elif (HAVE_SELECT) #elif (HAVE_SELECT)
#if (WIN32)
ngx_conf_init_unsigned_value(ecf->connections, DEFAULT_CONNECTIONS);
#else
ngx_conf_init_unsigned_value(ecf->connections, ngx_conf_init_unsigned_value(ecf->connections,
FD_SETSIZE < DEFAULT_CONNECTIONS ? FD_SETSIZE : DEFAULT_CONNECTIONS); FD_SETSIZE < DEFAULT_CONNECTIONS ? FD_SETSIZE : DEFAULT_CONNECTIONS);
#endif
ngx_conf_init_value(ecf->use, ngx_select_module.ctx_index); ngx_conf_init_value(ecf->use, ngx_select_module.ctx_index);
ngx_conf_init_ptr_value(ecf->name, ngx_select_module_ctx.name->data); ngx_conf_init_ptr_value(ecf->name, ngx_select_module_ctx.name->data);

View File

@ -668,7 +668,15 @@ static int ngx_http_gzip_body_filter(ngx_http_request_t *r, ngx_chain_t *in)
trailer->crc32 = ctx->crc32; trailer->crc32 = ctx->crc32;
trailer->zlen = ctx->zin; trailer->zlen = ctx->zin;
#else #else
/* STUB */ Oops ! trailer->crc32[0] = ctx->crc32 & 0xff;
trailer->crc32[1] = (ctx->crc32 >> 8) & 0xff;
trailer->crc32[2] = (ctx->crc32 >> 16) & 0xff;
trailer->crc32[3] = (ctx->crc32 >> 24) & 0xff;
trailer->zlen[0] = ctx->zin & 0xff;
trailer->zlen[1] = (ctx->zin >> 8) & 0xff;
trailer->zlen[2] = (ctx->zin >> 16) & 0xff;
trailer->zlen[3] = (ctx->zin >> 24) & 0xff;
#endif #endif
ctx->zstream.avail_in = 0; ctx->zstream.avail_in = 0;

View File

@ -2,35 +2,38 @@
#define _NGX_FREEBSD_CONFIG_H_INCLUDED_ #define _NGX_FREEBSD_CONFIG_H_INCLUDED_
#include <sys/types.h>
#include <sys/time.h>
#include <unistd.h> #include <unistd.h>
#include <stddef.h> /* offsetof() */
#include <stdlib.h>
#include <stdarg.h> #include <stdarg.h>
#include <stddef.h> /* offsetof() */
#include <stdio.h> #include <stdio.h>
#include <stdlib.h>
#include <errno.h> #include <errno.h>
#include <fcntl.h>
#include <string.h> #include <string.h>
#include <signal.h> #include <signal.h>
#include <limits.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/time.h>
#include <sys/uio.h>
#include <sys/ioctl.h>
#include <sys/resource.h>
#include <sys/sysctl.h>
#include <sys/wait.h>
#include <sys/mman.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netinet/tcp.h> /* TCP_NOPUSH */
#include <arpa/inet.h>
#include <pwd.h> #include <pwd.h>
#include <grp.h> #include <grp.h>
#include <netdb.h>
#include <dirent.h> #include <dirent.h>
#include <libutil.h> /* setproctitle() brefore 4.1 */
#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 <libutil.h> /* setproctitle() before 4.1 */
#include <osreldate.h> #include <osreldate.h>
#include <sys/sysctl.h>
#include <netinet/tcp.h> /* TCP_NOPUSH */
#include <ngx_auto_config.h> #include <ngx_auto_config.h>
@ -89,11 +92,6 @@ pid_t rfork_thread(int flags, void *stack, int (*func)(void *arg), void *arg);
#endif #endif
#ifndef HAVE_FIONBIO
#define HAVE_FIONBIO 1
#endif
/* STUB: autoconf */ /* STUB: autoconf */
#define ngx_setproctitle setproctitle #define ngx_setproctitle setproctitle

View File

@ -8,35 +8,43 @@
#define _LARGEFILE_SOURCE #define _LARGEFILE_SOURCE
#include <unistd.h>
#include <stddef.h> /* offsetof() */
#include <stdlib.h>
#include <stdarg.h>
#include <stdio.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/types.h>
#include <sys/time.h> #include <sys/time.h>
#include <sys/select.h> #include <unistd.h>
#include <sys/uio.h> #include <stdarg.h>
#include <sys/ioctl.h> #include <stddef.h> /* offsetof() */
#include <sys/resource.h> #include <stdio.h>
#include <sys/sysctl.h> #include <stdlib.h>
#include <sys/wait.h> #include <errno.h>
#include <sys/mman.h> #include <string.h>
#include <sys/socket.h> #include <signal.h>
#include <netinet/in.h>
#include <netinet/tcp.h> /* TCP_CORK */
#include <arpa/inet.h>
#include <pwd.h> #include <pwd.h>
#include <grp.h> #include <grp.h>
#include <netdb.h>
#include <dirent.h> #include <dirent.h>
#include <sys/uio.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 <arpa/inet.h>
#include <netdb.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> #include <ngx_auto_config.h>
@ -80,11 +88,6 @@ extern ssize_t sendfile(int s, int fd, int32_t *offset, size_t size);
#endif #endif
#ifndef HAVE_FIONBIO
#define HAVE_FIONBIO 1
#endif
#ifndef HAVE_SELECT_CHANGE_TIMEOUT #ifndef HAVE_SELECT_CHANGE_TIMEOUT
#define HAVE_SELECT_CHANGE_TIMEOUT 1 #define HAVE_SELECT_CHANGE_TIMEOUT 1
#endif #endif

View File

@ -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_ */

View File

@ -7,6 +7,26 @@ int ngx_max_sockets;
int ngx_inherited_nonblocking; 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); void ngx_signal_handler(int signo);

View File

@ -6,6 +6,7 @@
static void ngx_execute_proc(ngx_cycle_t *cycle, void *data); static void ngx_execute_proc(ngx_cycle_t *cycle, void *data);
ngx_int_t ngx_current_slot;
ngx_int_t ngx_last_process; ngx_int_t ngx_last_process;
ngx_socket_t ngx_channel; ngx_socket_t ngx_channel;
ngx_process_t ngx_processes[NGX_MAX_PROCESSES]; 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_channel = ngx_processes[s].channel[1];
ngx_current_slot = s;
pid = fork(); pid = fork();

View File

@ -49,6 +49,7 @@ ngx_pid_t ngx_execute(ngx_cycle_t *cycle, ngx_exec_ctx_t *ctx);
void ngx_process_get_status(void); void ngx_process_get_status(void);
extern ngx_pid_t ngx_pid; extern ngx_pid_t ngx_pid;
extern ngx_int_t ngx_current_slot;
extern ngx_int_t ngx_last_process; extern ngx_int_t ngx_last_process;
extern ngx_socket_t ngx_channel; extern ngx_socket_t ngx_channel;
extern ngx_process_t ngx_processes[NGX_MAX_PROCESSES]; extern ngx_process_t ngx_processes[NGX_MAX_PROCESSES];

View File

@ -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, if (n == ngx_current_slot) {
"close channel %d", ngx_processes[n].channel[1]); 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) { if (close(ngx_processes[n].channel[1]) == -1) {
ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno, 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 #if 0
ngx_last_process = 0; ngx_last_process = 0;
#endif #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; msg.msg_controllen = 0;
} else { } else {
msg.msg_control = &cm; msg.msg_control = (caddr_t) &cm;
msg.msg_controllen = sizeof(struct cmsghdr) + sizeof(int); msg.msg_controllen = sizeof(struct cmsghdr) + sizeof(int);
cm.cmsg_len = 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; msg.msg_iovlen = 1;
#if (HAVE_MSGHDR_MSG_CONTROL) #if (HAVE_MSGHDR_MSG_CONTROL)
msg.msg_control = &cm; msg.msg_control = (caddr_t) &cm;
msg.msg_controllen = sizeof(struct cmsghdr) + sizeof(int); msg.msg_controllen = sizeof(struct cmsghdr) + sizeof(int);
#else #else
msg.msg_accrights = (caddr_t) &fd; 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 (HAVE_MSGHDR_MSG_CONTROL)
if (ch->command == NGX_CMD_OPEN_CHANNEL) { if (ch->command == NGX_CMD_OPEN_CHANNEL) {
cm = msg.msg_control; cm = (struct cmsghdr *) msg.msg_control;
if (cm == NULL) { if (cm == NULL) {
ngx_log_error(NGX_LOG_ALERT, log, 0, ngx_log_error(NGX_LOG_ALERT, log, 0,

View File

@ -6,34 +6,41 @@
#define _REENTRANT #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 <unistd.h>
#include <inttypes.h>
#include <stddef.h> /* offsetof() */
#include <stdlib.h>
#include <stdarg.h> #include <stdarg.h>
#include <stddef.h> /* offsetof() */
#include <stdio.h> #include <stdio.h>
#include <stdlib.h>
#include <errno.h> #include <errno.h>
#include <fcntl.h>
#include <string.h> #include <string.h>
#include <signal.h> #include <signal.h>
#include <limits.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/wait.h>
#include <sys/mman.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 <pwd.h>
#include <grp.h> #include <grp.h>
#include <netdb.h>
#include <dirent.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 <sys/sendfile.h>
#include <sys/systeminfo.h>
#include <limits.h> /* IOV_MAX */
#include <inttypes.h>
#include <ngx_auto_config.h> #include <ngx_auto_config.h>
@ -66,11 +73,6 @@
#endif #endif
#ifndef HAVE_FIONBIO
#define HAVE_FIONBIO 1
#endif
#define ngx_setproctitle(title) #define ngx_setproctitle(title)