diff options
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/ngx_config.h | 207 | ||||
-rw-r--r-- | src/core/ngx_core.h | 6 | ||||
-rw-r--r-- | src/core/ngx_file.c | 2 | ||||
-rw-r--r-- | src/core/ngx_hunk.c | 8 | ||||
-rw-r--r-- | src/core/ngx_log.c | 2 | ||||
-rw-r--r-- | src/core/ngx_modules.c | 6 | ||||
-rw-r--r-- | src/core/ngx_os_init.h | 21 |
7 files changed, 61 insertions, 191 deletions
diff --git a/src/core/ngx_config.h b/src/core/ngx_config.h index 690cb32f5..b72412912 100644 --- a/src/core/ngx_config.h +++ b/src/core/ngx_config.h @@ -4,218 +4,59 @@ #include <ngx_auto_config.h> -/* - auto_conf - ngx_inline inline __inline __inline__ -*/ - -/* STUB */ -#undef FD_SETSIZE -#define FD_SETSIZE 1024 - - -/* auto_conf */ -#define NGX_ALIGN (4 - 1) -#define NGX_ALIGN_TYPE unsigned - -#define ngx_align(p) (char *) (((NGX_ALIGN_TYPE) p + NGX_ALIGN) & ~NGX_ALIGN) - - - -/* Platform specific: array[NGX_INVALID_ARRAY_INDEX] should cause SIGSEGV */ -#define NGX_INVALID_ARRAY_INDEX 0x80000000 +#if defined __FreeBSD__ +#include <ngx_freebsd_config.h> -#ifdef _WIN32 -#define WIN32 1 +#elif defined __linux__ +#include <ngx_linux_config.h> -#include <winsock2.h> -#include <mswsock.h> -#include <stddef.h> /* offsetof */ -#include <stdio.h> -#include <stdarg.h> + /* Solaris */ +#elif defined(sun) && (defined(__svr4__) || defined(__SVR4)) +#include <ngx_solaris_config.h> -#define ngx_inline __inline - - -#ifndef HAVE_INHERITED_NONBLOCK -#define HAVE_INHERITED_NONBLOCK 1 -#endif - -#ifndef HAVE_WIN32_TRANSMITPACKETS -#define HAVE_WIN32_TRANSMITPACKETS 1 -#define HAVE_WIN32_TRANSMITFILE 0 -#endif - -#ifndef HAVE_WIN32_TRANSMITFILE -#define HAVE_WIN32_TRANSMITFILE 1 -#endif - -#if (HAVE_WIN32_TRANSMITPACKETS) || (HAVE_WIN32_TRANSMITFILE) -#define HAVE_SENDFILE 1 -#endif - -#else /* POSIX */ +#elif defined _WIN32 +/* STUB to allocate a big ngx_connections */ +#undef FD_SETSIZE +#define FD_SETSIZE 1024 -/* Solaris */ -#if defined(sun) && (defined(__svr4__) || defined(__SVR4)) +#include <ngx_win32_config.h> -#define SOLARIS 1 -#define _FILE_OFFSET_BITS 64 /* should be before sys/types.h */ +#else /* posix */ -#ifndef HAVE_INHERITED_NONBLOCK -#define HAVE_INHERITED_NONBLOCK 1 #endif -#include <sys/stropts.h> /* INFTIM */ - -#endif /* Solaris */ +/* TODO: platform specific: array[NGX_INVALID_ARRAY_INDEX] must cause SIGSEGV */ +#define NGX_INVALID_ARRAY_INDEX 0x80000000 -#include <unistd.h> -#include <stddef.h> /* offsetof */ -#include <stdlib.h> -#include <stdio.h> -#include <stdarg.h> -#include <fcntl.h> -#include <signal.h> -#include <string.h> -#include <sys/types.h> -#include <sys/mman.h> -#include <sys/wait.h> -#include <sys/time.h> -#include <sys/socket.h> -#include <sys/uio.h> -#include <sys/resource.h> -#include <netinet/in.h> -#include <arpa/inet.h> -#include <netdb.h> +/* TODO: auto_conf */ +#define NGX_ALIGN (4 - 1) +#define NGX_ALIGN_TYPE (unsigned int) -#ifndef HAVE_POLL -#define HAVE_POLL 1 -#include <poll.h> -#endif +#define ngx_align(p) (char *) ((NGX_ALIGN_TYPE p + NGX_ALIGN) & ~NGX_ALIGN) -#if (HAVE_DEVPOLL) && !(TEST_DEVPOLL) -#include <sys/ioctl.h> -#include <sys/devpoll.h> /* Solaris, HP/UX */ +/* TODO: auto_conf: ngx_inline inline __inline __inline__ */ +#ifndef ngx_inline +#define ngx_inline inline #endif -#if (HAVE_AIO) -#include <aio.h> +#ifndef INADDR_NONE /* Solaris */ +#define INADDR_NONE ((unsigned long) -1) #endif - -#define ngx_inline inline - - -#endif /* POSIX */ - - - -#define LF 10 -#define CR 13 -#define CRLF "\x0d\x0a" - - #ifndef INET_ADDRSTRLEN #define INET_ADDRSTRLEN 16 #endif -#if defined SO_ACCEPTFILTER || defined TCP_DEFER_ACCEPT - -#ifndef HAVE_DEFERRED_ACCEPT -#define HAVE_DEFERRED_ACCEPT 1 -#endif - -#endif - - -#ifndef HAVE_SELECT -#define HAVE_SELECT 1 -#endif - - -#ifdef __FreeBSD__ - -#include <osreldate.h> - -#ifndef HAVE_INHERITED_NONBLOCK -#define HAVE_INHERITED_NONBLOCK 1 -#endif - -/* FreeBSD sendfile */ -#if __FreeBSD_version >= 300007 - -#ifndef HAVE_FREEBSD_SENDFILE -#define HAVE_FREEBSD_SENDFILE 1 -#endif - -#ifndef HAVE_FREEBSD_SENDFILE_NBYTES_BUG -#define HAVE_FREEBSD_SENDFILE_NBYTES_BUG 2 -#endif - -#endif /* FreeBSD sendfile */ - -/* FreeBSD sendfile nbytes bug */ -#if (__FreeBSD__ == 4 && __FreeBSD_version >= 460100) \ - || __FreeBSD_version == 460001 \ - || __FreeBSD_version >= 500029 - -#if (HAVE_FREEBSD_SENDFILE_NBYTES_BUG == 2) -#undef HAVE_FREEBSD_SENDFILE_NBYTES_BUG -#define HAVE_FREEBSD_SENDFILE_NBYTES_BUG 0 -#endif - -#endif /* FreeBSD sendfile nbytes bug */ - -#if (HAVE_FREEBSD_SENDFILE) -#define HAVE_SENDFILE 1 -#endif - - -/* FreeBSD kqueue */ -#if (__FreeBSD__ == 4 && __FreeBSD_version >= 410000) \ - || __FreeBSD_version >= 500011 - -#ifndef HAVE_KQUEUE -#define HAVE_KQUEUE 1 -#include <sys/event.h> -#endif - -/* kqueue's NOTE_LOWAT */ -#if (__FreeBSD__ == 4 && __FreeBSD_version >= 430000) \ - || __FreeBSD_version >= 500018 - -#ifndef HAVE_LOWAT_EVENT -#define HAVE_LOWAT_EVENT 1 -#endif - -#endif - -#endif /* FreeBSD kqueue */ - - -#endif /* __FreeBSD__ */ - - -#ifdef __SOME_OS_TEMPLATE__ - -#ifndef HAVE_INHERITED_NONBLOCK -#define HAVE_INHERITED_NONBLOCK 1 -#endif - -#endif - - #endif /* _NGX_CONFIG_H_INCLUDED_ */ diff --git a/src/core/ngx_core.h b/src/core/ngx_core.h index 76003fb37..aabbbc7f7 100644 --- a/src/core/ngx_core.h +++ b/src/core/ngx_core.h @@ -37,6 +37,12 @@ typedef struct ngx_event_s ngx_event_t; */ +#define LF 10 +#define CR 13 +#define CRLF "\x0d\x0a" + + + #define NGX_MAXHOSTNAMELEN 32 /* #define NGX_MAXHOSTNAMELEN MAXHOSTNAMELEN diff --git a/src/core/ngx_file.c b/src/core/ngx_file.c index d70004b2f..b85b4729e 100644 --- a/src/core/ngx_file.c +++ b/src/core/ngx_file.c @@ -81,7 +81,7 @@ ngx_log_debug(file->log, "temp fd: %d" _ file->fd); if (ngx_create_path(file, path) == NGX_ERROR) { return NGX_ERROR; - } + } } } diff --git a/src/core/ngx_hunk.c b/src/core/ngx_hunk.c index d2c31d52a..691387f96 100644 --- a/src/core/ngx_hunk.c +++ b/src/core/ngx_hunk.c @@ -25,9 +25,9 @@ ngx_hunk_t *ngx_create_temp_hunk(ngx_pool_t *pool, int size, return h; } - + ngx_hunk_t *ngx_create_hunk_before(ngx_pool_t *pool, ngx_hunk_t *hunk, int size) -{ +{ ngx_hunk_t *h; ngx_test_null(h, ngx_palloc(pool, sizeof(ngx_hunk_t)), NULL); @@ -47,7 +47,7 @@ ngx_hunk_t *ngx_create_hunk_before(ngx_pool_t *pool, ngx_hunk_t *hunk, int size) } else { ngx_test_null(h->pre_start, ngx_palloc(pool, size), NULL); - h->start = h->pos = h->last = h->pre_start; + h->start = h->pos = h->last = h->pre_start; h->end = h->post_end = h->start + size; h->file_pos = h->file_last = 0; @@ -84,7 +84,7 @@ ngx_hunk_t *ngx_create_hunk_after(ngx_pool_t *pool, ngx_hunk_t *hunk, int size) } else { ngx_test_null(h->pre_start, ngx_palloc(pool, size), NULL); - h->start = h->pos = h->last = h->pre_start; + h->start = h->pos = h->last = h->pre_start; h->end = h->post_end = h->start + size; h->file_pos = h->file_last = 0; diff --git a/src/core/ngx_log.c b/src/core/ngx_log.c index fee60187c..aff3998eb 100644 --- a/src/core/ngx_log.c +++ b/src/core/ngx_log.c @@ -147,7 +147,7 @@ void ngx_log_stderr(ngx_event_t *ev) n = read((ngx_fd_t) ev->data, errstr, sizeof(errstr - 1)); if (n == -1) { - err = ngx_errno; + err = ngx_errno; if (err == NGX_EAGAIN) { return; } diff --git a/src/core/ngx_modules.c b/src/core/ngx_modules.c index 5e5f5a8bd..cf5458c5a 100644 --- a/src/core/ngx_modules.c +++ b/src/core/ngx_modules.c @@ -17,6 +17,9 @@ extern ngx_module_t ngx_kqueue_module; #if (HAVE_DEVPOLL) extern ngx_module_t ngx_devpoll_module; #endif +#if (HAVE_AIO) +extern ngx_module_t ngx_aio_module; +#endif extern ngx_module_t ngx_http_module; @@ -47,6 +50,9 @@ ngx_module_t *ngx_modules[] = { #if (HAVE_DEVPOLL) &ngx_devpoll_module, #endif +#if (HAVE_AIO) + &ngx_aio_module, +#endif /* http */ diff --git a/src/core/ngx_os_init.h b/src/core/ngx_os_init.h index b65932def..8a14ad0ce 100644 --- a/src/core/ngx_os_init.h +++ b/src/core/ngx_os_init.h @@ -4,23 +4,40 @@ #include <ngx_config.h> #include <ngx_core.h> -#if 0 -#include <ngx_connection.h> + + +#define NGX_IO_SENDFILE 1 +#define NGX_IO_ZEROCOPY 2 + +#if (HAVE_SENDFILE) +#define NGX_HAVE_SENDFILE NGX_IO_SENDFILE +#else +#define NGX_HAVE_SENDFILE 0 #endif +#if (HAVE_ZEROCOPY) +#define NGX_HAVE_ZEROCOPY NGX_IO_ZEROCOPY +#else +#define NGX_HAVE_ZEROCOPY 0 +#endif + + typedef struct { ssize_t (*recv)(ngx_connection_t *c, char *buf, size_t size); void *dummy_recv_chain; void *dummy_send; ngx_chain_t *(*send_chain)(ngx_connection_t *c, ngx_chain_t *in); + int flags; } ngx_os_io_t; int ngx_os_init(ngx_log_t *log); + extern ngx_os_io_t ngx_os_io; extern int ngx_max_sockets; +extern int ngx_inherited_nonblocking; #endif /* _NGX_OS_INIT_H_INCLUDED_ */ |