changeset 104:7db96f59bc29

nginx-0.0.1-2003-06-12-09:54:39 import
author Igor Sysoev <igor@sysoev.ru>
date Thu, 12 Jun 2003 05:54:39 +0000
parents 6dfda4cf5200
children 00bee6e7b485
files src/core/ngx_alloc.c src/core/ngx_config.h src/core/ngx_core.h src/core/ngx_os_init.h src/http/ngx_http.c src/http/ngx_http_core_module.h src/http/ngx_http_event.c src/http/ngx_http_output_filter.c src/os/unix/ngx_freebsd_config.h src/os/unix/ngx_linux_config.h src/os/unix/ngx_solaris_config.h src/os/unix/ngx_time.h src/os/win32/ngx_socket.h src/os/win32/ngx_types.h
diffstat 14 files changed, 53 insertions(+), 52 deletions(-) [+]
line wrap: on
line diff
--- 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;
             }
--- 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
 
 
--- a/src/core/ngx_core.h
+++ b/src/core/ngx_core.h
@@ -56,8 +56,10 @@ typedef struct ngx_connection_s  ngx_con
 */
 
 
+#if 0
 /* STUB */
 extern ngx_log_t  ngx_log;
+#endif
 
 
 #endif /* _NGX_CORE_H_INCLUDED_ */
--- 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;
--- a/src/http/ngx_http.c
+++ b/src/http/ngx_http.c
@@ -513,7 +513,8 @@ static char *ngx_http_block(ngx_conf_t *
 
                     /* 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;
--- 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 */
--- 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
 
 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_han
                  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;
 
--- 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_mod
 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;
--- a/src/os/unix/ngx_freebsd_config.h
+++ b/src/os/unix/ngx_freebsd_config.h
@@ -22,22 +22,21 @@
 #include <osreldate.h>
 
 
-/* STUB */
-#define  QD_FMT   "%lld"
-#define  QX_FMT   "%llx"
-/**/
+#if (i386)
+
+#define OFF_FMT    "%lld"
+#define SIZE_FMT   "%d"
+#define SIZEX_FMT  "%x"
 
-#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"
+#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
--- 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
--- 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
--- a/src/os/unix/ngx_time.h
+++ b/src/os/unix/ngx_time.h
@@ -5,7 +5,7 @@
 #include <ngx_config.h>
 
 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;
 
--- 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;
--- a/src/os/win32/ngx_types.h
+++ b/src/os/win32/ngx_types.h
@@ -16,10 +16,10 @@ typedef unsigned __int64            off_
 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_ */