From 0915977df53c486abbc6081e1c83f9f8e7a8f111 Mon Sep 17 00:00:00 2001 From: Igor Sysoev Date: Thu, 12 Jun 2003 05:54:39 +0000 Subject: [PATCH] nginx-0.0.1-2003-06-12-09:54:39 import --- src/core/ngx_alloc.c | 10 +++++----- src/core/ngx_config.h | 18 +++++++++--------- src/core/ngx_core.h | 2 ++ src/core/ngx_os_init.h | 4 ++-- src/http/ngx_http.c | 3 ++- src/http/ngx_http_core_module.h | 8 ++++---- src/http/ngx_http_event.c | 5 ++--- src/http/ngx_http_output_filter.c | 2 +- src/os/unix/ngx_freebsd_config.h | 25 ++++++++++++------------- src/os/unix/ngx_linux_config.h | 9 +++++---- src/os/unix/ngx_solaris_config.h | 8 ++++---- src/os/unix/ngx_time.h | 2 +- src/os/win32/ngx_socket.h | 1 - src/os/win32/ngx_types.h | 8 ++++---- 14 files changed, 53 insertions(+), 52 deletions(-) diff --git a/src/core/ngx_alloc.c b/src/core/ngx_alloc.c index af59a223c..050fcbfa8 100644 --- a/src/core/ngx_alloc.c +++ b/src/core/ngx_alloc.c @@ -74,17 +74,17 @@ void ngx_destroy_pool(ngx_pool_t *pool) void *ngx_palloc(ngx_pool_t *pool, size_t size) { - void *m; + char *m; ngx_pool_t *p, *n; ngx_pool_large_t *large, *last; if (size <= NGX_MAX_ALLOC_FROM_POOL) { for (p = pool, n = pool->next; /* void */; p = n, n = n->next) { - if ((size_t) (p->end - ngx_align(p->last)) >= size) { - m = ngx_align(p->last); - p->last = ngx_align(p->last); - p->last += size ; + m = ngx_align(p->last); + + if ((size_t) (p->end - m) >= size) { + p->last = m + size ; return m; } diff --git a/src/core/ngx_config.h b/src/core/ngx_config.h index b9a0988dc..807ca06dc 100644 --- a/src/core/ngx_config.h +++ b/src/core/ngx_config.h @@ -38,10 +38,10 @@ /* TODO: auto_conf */ -#define NGX_ALIGN (4 - 1) -#define NGX_ALIGN_TYPE (unsigned int) +#define NGX_ALIGN (sizeof(unsigned long) - 1) /* platform word */ +#define NGX_ALIGN_CAST (unsigned long) /* size of the pointer */ -#define ngx_align(p) (char *) ((NGX_ALIGN_TYPE p + NGX_ALIGN) & ~NGX_ALIGN) +#define ngx_align(p) (char *) ((NGX_ALIGN_CAST p + NGX_ALIGN) & ~NGX_ALIGN) /* TODO: auto_conf: ngx_inline inline __inline __inline__ */ @@ -50,16 +50,16 @@ #endif -#ifndef INFTIM /* Linux */ -#define INFTIM -1 +#ifndef INFTIM /* Linux */ +#define INFTIM -1 #endif -#ifndef INADDR_NONE /* Solaris */ -#define INADDR_NONE ((unsigned long) -1) +#ifndef INADDR_NONE /* Solaris */ +#define INADDR_NONE ((unsigned int) -1) #endif -#ifndef INET_ADDRSTRLEN -#define INET_ADDRSTRLEN 16 +#ifndef INET_ADDRSTRLEN /* Win32 */ +#define INET_ADDRSTRLEN 16 #endif diff --git a/src/core/ngx_core.h b/src/core/ngx_core.h index 8963d08ff..573675692 100644 --- a/src/core/ngx_core.h +++ b/src/core/ngx_core.h @@ -56,8 +56,10 @@ typedef struct ngx_connection_s ngx_connection_t; */ +#if 0 /* STUB */ extern ngx_log_t ngx_log; +#endif #endif /* _NGX_CORE_H_INCLUDED_ */ diff --git a/src/core/ngx_os_init.h b/src/core/ngx_os_init.h index 8a14ad0ce..355509587 100644 --- a/src/core/ngx_os_init.h +++ b/src/core/ngx_os_init.h @@ -25,8 +25,8 @@ typedef struct { ssize_t (*recv)(ngx_connection_t *c, char *buf, size_t size); - void *dummy_recv_chain; - void *dummy_send; + ssize_t (*recv_chain)(ngx_connection_t *c, ngx_chain_t *in); + ssize_t (*send)(ngx_connection_t *c, char *buf, size_t size); ngx_chain_t *(*send_chain)(ngx_connection_t *c, ngx_chain_t *in); int flags; } ngx_os_io_t; diff --git a/src/http/ngx_http.c b/src/http/ngx_http.c index 005f230fb..10f002311 100644 --- a/src/http/ngx_http.c +++ b/src/http/ngx_http.c @@ -513,7 +513,8 @@ static char *ngx_http_block(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) /* prepare for the next cycle */ - (char *) in_port[p].addrs.elts += in_port[p].addrs.size; + in_port[p].addrs.elts = (char *) in_port[p].addrs.elts + + in_port[p].addrs.size; in_port[p].addrs.nelts--; in_addr = (ngx_http_in_addr_t *) in_port[p].addrs.elts; diff --git a/src/http/ngx_http_core_module.h b/src/http/ngx_http_core_module.h index 4cf966a1d..df9bcca02 100644 --- a/src/http/ngx_http_core_module.h +++ b/src/http/ngx_http_core_module.h @@ -35,9 +35,9 @@ typedef struct { ngx_msec_t post_accept_timeout; ssize_t connection_pool_size; - size_t request_pool_size; + ssize_t request_pool_size; ngx_msec_t client_header_timeout; - size_t client_header_buffer_size; + ssize_t client_header_buffer_size; int large_client_header; } ngx_http_core_srv_conf_t; @@ -99,8 +99,8 @@ typedef struct { int sendfile; /* sendfile */ ngx_msec_t send_timeout; /* send_timeout */ - size_t send_lowat; /* send_lowat */ - size_t discarded_buffer_size; /* discarded_buffer_size */ + ssize_t send_lowat; /* send_lowat */ + ssize_t discarded_buffer_size; /* discarded_buffer_size */ ngx_msec_t keepalive_timeout; /* keepalive_timeout */ ngx_msec_t lingering_time; /* lingering_time */ ngx_msec_t lingering_timeout; /* lingering_timeout */ diff --git a/src/http/ngx_http_event.c b/src/http/ngx_http_event.c index 991b87d3b..06a98a372 100644 --- a/src/http/ngx_http_event.c +++ b/src/http/ngx_http_event.c @@ -1035,8 +1035,7 @@ static void ngx_http_read_discarded_body_event(ngx_event_t *rev) static int ngx_http_read_discarded_body(ngx_http_request_t *r) { - size_t size; - ssize_t n; + ssize_t size, n; ngx_http_core_loc_conf_t *clcf; ngx_log_debug(r->connection->log, "http read discarded body"); @@ -1318,7 +1317,7 @@ static void ngx_http_lingering_close_handler(ngx_event_t *rev) or the end of parsed header (otherwise) instead of r->header_in->last */ - if ((size_t)(r->header_in->end - r->header_in->last) + if (r->header_in->end - r->header_in->last >= clcf->discarded_buffer_size) { r->discarded_buffer = r->header_in->last; diff --git a/src/http/ngx_http_output_filter.c b/src/http/ngx_http_output_filter.c index 7ee6a9673..09b7bfab5 100644 --- a/src/http/ngx_http_output_filter.c +++ b/src/http/ngx_http_output_filter.c @@ -69,7 +69,7 @@ ngx_module_t ngx_http_output_filter_module = { int ngx_http_output_filter(ngx_http_request_t *r, ngx_hunk_t *hunk) { int rc; - size_t size; + ssize_t size; ngx_chain_t *ce, *le; ngx_http_output_filter_ctx_t *ctx; ngx_http_output_filter_conf_t *conf; diff --git a/src/os/unix/ngx_freebsd_config.h b/src/os/unix/ngx_freebsd_config.h index 6fd0a694e..64175fe82 100644 --- a/src/os/unix/ngx_freebsd_config.h +++ b/src/os/unix/ngx_freebsd_config.h @@ -22,22 +22,21 @@ #include -/* STUB */ -#define QD_FMT "%lld" -#define QX_FMT "%llx" -/**/ - #if (i386) -#define OFF_FMT "%lld" -#define SIZE_FMT "%d" -#define SIZEX_FMT "%x" -#else -#define OFF_FMT "%ld" -#define SIZE_FMT "%ld" -#define SIZEX_FMT "%lx" + +#define OFF_FMT "%lld" +#define SIZE_FMT "%d" +#define SIZEX_FMT "%x" + +#else /* amd64, alpha, sparc64, ia64 */ + +#define OFF_FMT "%ld" +#define SIZE_FMT "%ld" +#define SIZEX_FMT "%lx" + #endif -#define PID_FMT "%d" +#define PID_FMT "%d" #ifndef HAVE_SELECT diff --git a/src/os/unix/ngx_linux_config.h b/src/os/unix/ngx_linux_config.h index 27fa317bc..9056657f4 100644 --- a/src/os/unix/ngx_linux_config.h +++ b/src/os/unix/ngx_linux_config.h @@ -30,10 +30,11 @@ -#define QD_FMT "%qd" -#define QX_FMT "%qx" -#define OFF_FMT "%qd" -#define PID_FMT "%d" +#define OFF_FMT "%lld" +#define SIZE_FMT "%d" +#define SIZEX_FMT "%x" +#define PID_FMT "%d" + #ifndef HAVE_SELECT diff --git a/src/os/unix/ngx_solaris_config.h b/src/os/unix/ngx_solaris_config.h index 78eeb7213..a5b66c465 100644 --- a/src/os/unix/ngx_solaris_config.h +++ b/src/os/unix/ngx_solaris_config.h @@ -27,10 +27,10 @@ typedef uint32_t u_int32_t; -#define QD_FMT "%lld" -#define QX_FMT "%llx" -#define OFF_FMT "%lld" -#define PID_FMT "%ld" +#define OFF_FMT "%lld" +#define SIZE_FMT "%d" +#define SIZEX_FMT "%x" +#define PID_FMT "%ld" #ifndef HAVE_SELECT diff --git a/src/os/unix/ngx_time.h b/src/os/unix/ngx_time.h index 4b5fa5949..ee5b47f9d 100644 --- a/src/os/unix/ngx_time.h +++ b/src/os/unix/ngx_time.h @@ -5,7 +5,7 @@ #include typedef u_int ngx_msec_t; -#define NGX_MAX_MSEC (u_int) ~0 +#define NGX_MAX_MSEC (u_int) -1 typedef struct tm ngx_tm_t; diff --git a/src/os/win32/ngx_socket.h b/src/os/win32/ngx_socket.h index 55629a1a9..a78c40c6b 100644 --- a/src/os/win32/ngx_socket.h +++ b/src/os/win32/ngx_socket.h @@ -8,7 +8,6 @@ #define NGX_WRITE_SHUTDOWN SD_SEND -#define INET_ADDRSTRLEN 16 typedef SOCKET ngx_socket_t; typedef int socklen_t; diff --git a/src/os/win32/ngx_types.h b/src/os/win32/ngx_types.h index b858faee9..c009b5aa9 100644 --- a/src/os/win32/ngx_types.h +++ b/src/os/win32/ngx_types.h @@ -16,10 +16,10 @@ typedef unsigned __int64 off_t; typedef BY_HANDLE_FILE_INFORMATION ngx_file_info_t; -#define QD_FMT "%I64d" -#define QX_FMT "%I64x" -#define OFF_FMT "%I64d" -#define PID_FMT "%d" +#define OFF_FMT "%I64d" +#define SIZE_FMT "%d" +#define SIZEX_FMT "%x" +#define PID_FMT "%d" #endif /* _NGX_TYPES_H_INCLUDED_ */