]> git.kaiwu.me - nginx.git/commitdiff
nginx-0.0.3-2004-03-30-10:27:36 import
authorIgor Sysoev <igor@sysoev.ru>
Tue, 30 Mar 2004 06:27:36 +0000 (06:27 +0000)
committerIgor Sysoev <igor@sysoev.ru>
Tue, 30 Mar 2004 06:27:36 +0000 (06:27 +0000)
16 files changed:
auto/cc
auto/modules
auto/nohave [new file with mode: 0644]
auto/os/freebsd
auto/os/linux
src/core/ngx_atomic.h
src/http/modules/proxy/ngx_http_proxy_handler.c
src/http/modules/proxy/ngx_http_proxy_handler.h
src/http/modules/proxy/ngx_http_proxy_upstream.c
src/http/ngx_http_request.c
src/http/ngx_http_request.h
src/os/unix/ngx_aio.h
src/os/unix/ngx_aio_read.c
src/os/unix/ngx_aio_read_chain.c
src/os/unix/ngx_aio_write.c
src/os/unix/ngx_aio_write_chain.c

diff --git a/auto/cc b/auto/cc
index 67f364d4eb304e725490031f59e29b989d1a1547..16684b0c86cbb0d59558b451648748071a611d65 100644 (file)
--- a/auto/cc
+++ b/auto/cc
@@ -62,8 +62,8 @@ case $CC in
          # debug
          CFLAGS="$CFLAGS -g"
 
-         # DragonFly's gcc3 generate DWARF
-         CFLAGS="$CFLAGS -g -gstabs"
+         # DragonFly's gcc3 generates DWARF
+         #CFLAGS="$CFLAGS -g -gstabs"
 
          have=HAVE_GCC_VARIADIC_MACROS . auto/have
 
index e2c909280085cd8a9c8d48525c20363f6a16cb59..8fcaf8a2267fc78bfe3bc3eecd48b6c03479ea92 100644 (file)
@@ -1,10 +1,4 @@
 
-if [ $EVENT_RTSIG = YES ]; then
-    have=HAVE_RTSIG . auto/have
-    EVENT_MODULES="$EVENT_MODULES $RTSIG_MODULE"
-    CORE_SRCS="$CORE_SRCS $RTSIG_SRCS"
-fi
-
 if [ $EVENT_SELECT = NO -a $EVENT_FOUND = NO ]; then
     EVENT_SELECT=YES
 fi
diff --git a/auto/nohave b/auto/nohave
new file mode 100644 (file)
index 0000000..49bb7ce
--- /dev/null
@@ -0,0 +1,8 @@
+
+cat << END >> $NGX_AUTO_CONFIG_H
+
+#ifndef $have
+#define $have  0
+#endif
+
+END
index 82e442c56c0877a253de1ebebfaaa0ccb9978ba6..5fa8e33e3afb477a4258a7152b9085bc3a7a4af0 100644 (file)
@@ -42,8 +42,8 @@ then
 
     have=HAVE_KQUEUE . auto/have
     have=HAVE_CLEAR_EVENT . auto/have
-    CORE_SRCS="$CORE_SRCS $KQUEUE_SRCS"
     EVENT_MODULES="$EVENT_MODULES $KQUEUE_MODULE"
+    CORE_SRCS="$CORE_SRCS $KQUEUE_SRCS"
     EVENT_FOUND=YES
 fi
 
@@ -60,6 +60,9 @@ fi
 
 
 if [ $EVENT_AIO = YES ]; then
-    CORE_SRCS="$CORE_SRCS $AIO_SRCS"
+    have=HAVE_AIO . auto/have
     EVENT_MODULES="$EVENT_MODULES $AIO_MODULE"
+    CORE_SRCS="$CORE_SRCS $AIO_SRCS"
+else
+    have=HAVE_AIO . auto/nohave
 fi
index 78ab3d14b98e067988a94ae64fdff7ba5966ee34..4a9823dd9eb36744182157760b18d1563c4539e7 100644 (file)
@@ -30,6 +30,15 @@ if [ $ngx_found = yes ]; then
 fi
 
 
+# rtsig
+
+if [ $EVENT_RTSIG = YES ]; then
+    have=HAVE_RTSIG . auto/have
+    EVENT_MODULES="$EVENT_MODULES $RTSIG_MODULE"
+    CORE_SRCS="$CORE_SRCS $RTSIG_SRCS"
+fi
+
+
 # sendfile()
 
 CC_TEST_FLAGS="-D_GNU_SOURCE"
index 311ef8892ff565525053badf0ef27972c1d4b8a9..6270d8a51eebfcb1454b07a1b3402234da2aefe7 100644 (file)
@@ -64,7 +64,7 @@ static ngx_inline uint32_t ngx_atomic_cmp_set(ngx_atomic_t *lock,
     "   setz      %%al;     "
     "   movzbl    %%al, %0; "
 
-    : "+a" (res) : "m" (*lock), "a" (old), "q" (set));
+    : "=a" (res) : "m" (*lock), "a" (old), "q" (set));
 
     return res;
 }
index 3fc8d0ef47930e0beb154e8fac230758ca71220c..8f0336a9b1885643e7a6487666b91a91f51d3ec4 100644 (file)
@@ -374,28 +374,29 @@ static int ngx_http_proxy_handler(ngx_http_request_t *r)
 }
 
 
-void ngx_http_proxy_check_broken_connection(ngx_event_t *wev)
+void ngx_http_proxy_check_broken_connection(ngx_event_t *ev)
 {
     ngx_connection_t      *c;
     ngx_http_request_t    *r;
     ngx_http_proxy_ctx_t  *p;
 
-    ngx_log_debug0(NGX_LOG_DEBUG_HTTP, wev->log, 0, "http proxy check client");
+    ngx_log_debug1(NGX_LOG_DEBUG_HTTP, ev->log, 0,
+                   "http proxy check client, write event:%d", ev->write);
 
-    c = wev->data;
+    c = ev->data;
     r = c->data;
     p = ngx_http_get_module_ctx(r, ngx_http_proxy_module);
 
 #if (HAVE_KQUEUE)
-    if (wev->kq_eof) {
-        wev->eof = 1;
+    if (ev->kq_eof) {
+        ev->eof = 1;
 
-        if (wev->kq_errno) {
-            wev->error = 1;
+        if (ev->kq_errno) {
+            ev->error = 1;
         }
 
         if (!p->cachable && p->upstream->peer.connection) {
-            ngx_log_error(NGX_LOG_INFO, wev->log, wev->kq_errno,
+            ngx_log_error(NGX_LOG_INFO, ev->log, ev->kq_errno,
                           "kevent() reported that client have closed "
                           "prematurely connection, "
                           "so upstream connection is closed too");
@@ -403,7 +404,7 @@ void ngx_http_proxy_check_broken_connection(ngx_event_t *wev)
             return;
         }
 
-        ngx_log_error(NGX_LOG_INFO, wev->log, wev->kq_errno,
+        ngx_log_error(NGX_LOG_INFO, ev->log, ev->kq_errno,
                       "kevent() reported that client have closed "
                       "prematurely connection");
 
index 210ca89f8b173dabd31349c36710b0a615b759fb..d204cac59608085da3639bede5992fdace93a58b 100644 (file)
@@ -227,7 +227,7 @@ void ngx_http_proxy_cache_busy_lock(ngx_http_proxy_ctx_t *p);
 
 #endif
 
-void ngx_http_proxy_check_broken_connection(ngx_event_t *wev);
+void ngx_http_proxy_check_broken_connection(ngx_event_t *ev);
 
 void ngx_http_proxy_busy_lock_handler(ngx_event_t *rev);
 void ngx_http_proxy_upstream_busy_lock(ngx_http_proxy_ctx_t *p);
index 6bc11a25ddd3e70fae9463bc2b444e3edc272ccd..00a0780092df23f7dca73853cce7c5a431c835e7 100644 (file)
@@ -70,41 +70,37 @@ int ngx_http_proxy_request_upstream(ngx_http_proxy_ctx_t *p)
     }
     r->request_body = rb;
 
-    if (r->headers_in.content_length_n > 0) {
-
-        if (!(tf = ngx_pcalloc(r->pool, sizeof(ngx_temp_file_t)))) {
-            return NGX_HTTP_INTERNAL_SERVER_ERROR;
-        }
+    if (r->headers_in.content_length_n <= 0) {
+        ngx_http_proxy_init_upstream(p);
+        return NGX_DONE;
+    }
 
-        tf->file.fd = NGX_INVALID_FILE;
-        tf->file.log = r->connection->log;
-        tf->path = p->lcf->temp_path;
-        tf->pool = r->pool;
-        tf->warn = "a client request body is buffered to a temporary file";
-        /* tf->persistent = 0; */
+    if (!(tf = ngx_pcalloc(r->pool, sizeof(ngx_temp_file_t)))) {
+        return NGX_HTTP_INTERNAL_SERVER_ERROR;
+    }
 
-        rb->buf_size = p->lcf->request_buffer_size;
-        rb->handler = ngx_http_proxy_init_upstream;
-        rb->data = p;
-        /* rb->bufs = NULL; */
-        /* rb->buf = NULL; */
-        /* rb->rest = 0; */
+    tf->file.fd = NGX_INVALID_FILE;
+    tf->file.log = r->connection->log;
+    tf->path = p->lcf->temp_path;
+    tf->pool = r->pool;
+    tf->warn = "a client request body is buffered to a temporary file";
+    /* tf->persistent = 0; */
 
-        rb->temp_file = tf;
+    rb->buf_size = p->lcf->request_buffer_size;
+    rb->handler = ngx_http_proxy_init_upstream;
+    rb->data = p;
+    /* rb->bufs = NULL; */
+    /* rb->buf = NULL; */
+    /* rb->rest = 0; */
 
-        rc = ngx_http_read_client_request_body(r);
+    rb->temp_file = tf;
 
-        if (rc == NGX_AGAIN) {
-            return NGX_DONE;
-        }
+    rc = ngx_http_read_client_request_body(r);
 
-        if (rc >= NGX_HTTP_SPECIAL_RESPONSE) {
-            return rc;
-        }
+    if (rc >= NGX_HTTP_SPECIAL_RESPONSE) {
+        return rc;
     }
 
-    ngx_http_proxy_init_upstream(p);
-
     return NGX_DONE;
 }
 
@@ -323,13 +319,15 @@ static void ngx_http_proxy_init_upstream(void *data)
     r = p->request;
 
     ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
-                  "http proxy set timer: %d",
+                  "http proxy init upstream, client timer: %d",
                   r->connection->read->timer_set);
 
     if (r->connection->read->timer_set) {
         ngx_del_timer(r->connection->read);
     }
 
+    r->connection->read->event_handler = ngx_http_proxy_check_broken_connection;
+
     if ((ngx_event_flags & (NGX_USE_CLEAR_EVENT|NGX_HAVE_KQUEUE_EVENT))
         && !r->connection->write->active)
     {
index 6562c8d52ea623e9060f94adec3277558f7e7425..86321b51b6e37a26fa125b664ec575328a73e91a 100644 (file)
@@ -39,6 +39,7 @@ static char *client_header_errors[] = {
     "client %s sent too long header line, URL: %s",
     "client %s sent HTTP/1.1 request without \"Host\" header, URL: %s",
     "client %s sent invalid \"Content-Length\" header, URL: %s"
+    "client %s sent POST method without \"Content-Length\" header, URL: %s"
 };
 
 
@@ -873,6 +874,10 @@ static ngx_int_t ngx_http_process_request_header(ngx_http_request_t *r)
         }
     }
 
+    if (r->method == NGX_HTTP_POST && r->headers_in.content_length_n <= 0) {
+        return NGX_HTTP_PARSE_POST_WO_CL_HEADER;
+    }
+
     if (r->headers_in.connection) {
         if (r->headers_in.connection->value.len == 5
             && ngx_strcasecmp(r->headers_in.connection->value.data, "close")
@@ -1222,10 +1227,17 @@ static void ngx_http_set_keepalive(ngx_http_request_t *r)
     wev = c->write;
     wev->event_handler = ngx_http_empty_handler;
 
+
+    /* skip the tralling "\r\n" before the possible pipelined request */
+
+    while (h->pos < h->last && (*h->pos == CR || *h->pos == LF)) {
+        h->pos++;
+    }
+
     if (h->pos < h->last) {
 
         /*
-         * Pipelined request.
+         * The pipelined request.
          *
          * We do not know here whether the pipelined request is complete
          * so if the large client headers are not enabled
index 555d55593422fd9b0801dcf21a5ac48e1d0d3c0c..a3161531fb4d46923bdc70aeebff92687b782f1c 100644 (file)
@@ -30,6 +30,7 @@
 #define NGX_HTTP_PARSE_TOO_LONG_HEADER     15
 #define NGX_HTTP_PARSE_NO_HOST_HEADER      16
 #define NGX_HTTP_PARSE_INVALID_CL_HEADER   17
+#define NGX_HTTP_PARSE_POST_WO_CL_HEADER   18
 
 
 #define NGX_HTTP_OK                        200
index a357ff524e557299eced0521023d77da124414ea..0bbb7ec9b9324d9267d48f13db970eecd1de00a9 100644 (file)
@@ -5,9 +5,9 @@
 #include <ngx_core.h>
 
 
-ssize_t ngx_aio_read(ngx_connection_t *c, char *buf, size_t size);
+ssize_t ngx_aio_read(ngx_connection_t *c, u_char *buf, size_t size);
 ssize_t ngx_aio_read_chain(ngx_connection_t *c, ngx_chain_t *cl);
-ssize_t ngx_aio_write(ngx_connection_t *c, char *buf, size_t size);
+ssize_t ngx_aio_write(ngx_connection_t *c, u_char *buf, size_t size);
 ngx_chain_t *ngx_aio_write_chain(ngx_connection_t *c, ngx_chain_t *in);
 
 
index 84301886a5e1b0bd1be79d94ca3bf697b71904c8..6c0c40084ed16a6f4eb0a848ca637c3f67972842 100644 (file)
@@ -17,7 +17,7 @@
  *                               timeout, aio_cancel(), aio_error()
  */
 
-ssize_t ngx_aio_read(ngx_connection_t *c, char *buf, size_t size)
+ssize_t ngx_aio_read(ngx_connection_t *c, u_char *buf, size_t size)
 {
     int           n;
     ngx_event_t  *rev;
index 8fc8870ddfc77674c7061969b8dd8a653fb634a7..3a56e861361f0933f5acfee3a032b1ce47dfcc03 100644 (file)
@@ -8,7 +8,7 @@
 ssize_t ngx_aio_read_chain(ngx_connection_t *c, ngx_chain_t *cl)
 {
     int           n;
-    char         *buf, *prev;
+    u_char       *buf, *prev;
     size_t        size, total;
     ngx_err_t     err;
 
index 113196165a10003220dafdcf5f9202c18900b302..319af12614f07ad44840e24c7445807e7f565705 100644 (file)
@@ -17,7 +17,7 @@
  *                               timeout, aio_cancel(), aio_error()
  */
 
-ssize_t ngx_aio_write(ngx_connection_t *c, char *buf, size_t size)
+ssize_t ngx_aio_write(ngx_connection_t *c, u_char *buf, size_t size)
 {
     int           n;
     ngx_event_t  *wev;
index c8108f3e01e58b115f9bf5a6053d666a4d488b9b..f5e125e4f8319c62c1ab43e7b395125d7c35d656 100644 (file)
@@ -8,7 +8,7 @@
 ngx_chain_t *ngx_aio_write_chain(ngx_connection_t *c, ngx_chain_t *in)
 {
     int           n;
-    char         *buf, *prev;
+    u_char       *buf, *prev;
     off_t         sent;
     size_t        size;
     ngx_err_t     err;