diff --git a/patches/nginx-1.2.3-dtrace.patch b/patches/nginx-1.2.3-dtrace.patch
index b16ee61..2d4b08a 100644
--- a/patches/nginx-1.2.3-dtrace.patch
+++ b/patches/nginx-1.2.3-dtrace.patch
@@ -454,10 +454,10 @@ index efbc244..8d81aab 100644
  
 diff --git a/src/dtrace/nginx.stp b/src/dtrace/nginx.stp
 new file mode 100644
-index 0000000..3dde1be
+index 0000000..6420250
 --- /dev/null
 +++ b/src/dtrace/nginx.stp
-@@ -0,0 +1,199 @@
+@@ -0,0 +1,236 @@
 +/* tapset for nginx */
 +
 +/* retrieve the request uri string from the ngx_http_request_t pointer */
@@ -555,6 +555,24 @@ index 0000000..3dde1be
 +}
 +
 +
++function ngx_buf_last_buf(b)
++{
++    return @cast(b, "ngx_buf_t", "/home/agentzh/git/lua-nginx-module/work/nginx/sbin/nginx")->last_buf
++}
++
++
++function ngx_buf_sync(b)
++{
++    return @cast(b, "ngx_buf_t", "/home/agentzh/git/lua-nginx-module/work/nginx/sbin/nginx")->sync
++}
++
++
++function ngx_buf_flush(b)
++{
++    return @cast(b, "ngx_buf_t", "/home/agentzh/git/lua-nginx-module/work/nginx/sbin/nginx")->flush
++}
++
++
 +function ngx_buf_size(b)
 +{
 +    if (ngx_buf_in_memory(b)) {
@@ -587,7 +605,26 @@ index 0000000..3dde1be
 +    cl = input
 +    while (cl) {
 +        buf = ngx_chain_buf(cl)
-+        out .= sprintf("[%s]", text_str(ngx_buf_data(buf)))
++
++        if (ngx_buf_in_memory(buf)) {
++            out .= sprintf("[%s]", text_str(ngx_buf_data(buf)))
++
++        } else {
++            out .= "\"\""
++        }
++
++        if (ngx_buf_last_buf(buf)) {
++            out .= "<eof>"
++        }
++
++        if (ngx_buf_sync(buf)) {
++            out .= "<sync>"
++        }
++
++        if (ngx_buf_flush(buf)) {
++            out .= "<flush>"
++        }
++
 +        cl = ngx_chain_next(cl)
 +        if (cl) {
 +            out .= sprintf(" ")
diff --git a/patches/nginx-1.2.3-nonbuffered-upstream-truncation.patch b/patches/nginx-1.2.3-nonbuffered-upstream-truncation.patch
index bf4371d..7f66442 100644
--- a/patches/nginx-1.2.3-nonbuffered-upstream-truncation.patch
+++ b/patches/nginx-1.2.3-nonbuffered-upstream-truncation.patch
@@ -1,5 +1,5 @@
 --- nginx-1.2.3/src/http/ngx_http_upstream.c	2012-08-06 10:34:08.000000000 -0700
-+++ nginx-1.2.3-patched/src/http/ngx_http_upstream.c	2012-09-05 20:57:44.832566031 -0700
++++ nginx-1.2.3-patched/src/http/ngx_http_upstream.c	2012-09-09 11:37:23.672421961 -0700
 @@ -2383,7 +2383,7 @@
  
      if (c->read->timedout) {
@@ -9,15 +9,14 @@
          return;
      }
  
-@@ -2429,14 +2429,16 @@
- 
+@@ -2430,13 +2430,17 @@
              if (u->busy_bufs == NULL) {
  
--                if (u->length == 0
+                 if (u->length == 0
 -                    || upstream->read->eof
 -                    || upstream->read->error)
--                {
-+                if (u->length == 0) {
++                    || (upstream->read->eof && u->headers_in.content_length_n == -1))
+                 {
                      ngx_http_upstream_finalize_request(r, u, 0);
                      return;
                  }
@@ -30,7 +29,26 @@
                  b->pos = b->start;
                  b->last = b->start;
              }
-@@ -3073,6 +3075,13 @@
+@@ -2710,7 +2714,17 @@
+ #if 0
+             ngx_http_busy_unlock(u->conf->busy_lock, &u->busy_lock);
+ #endif
+-            ngx_http_upstream_finalize_request(r, u, 0);
++
++            if (p->upstream_done
++                || (p->upstream_eof && u->headers_in.content_length_n == -1))
++            {
++                ngx_http_upstream_finalize_request(r, u, 0);
++
++            } else {
++
++                ngx_http_upstream_finalize_request(r, u, NGX_HTTP_BAD_GATEWAY);
++            }
++
+             return;
+         }
+     }
+@@ -3073,6 +3087,13 @@
          && rc != NGX_HTTP_REQUEST_TIME_OUT
          && (rc == NGX_ERROR || rc >= NGX_HTTP_SPECIAL_RESPONSE))
      {
diff --git a/patches/nginx-1.3.4-dtrace.patch b/patches/nginx-1.3.4-dtrace.patch
index b16ee61..2d4b08a 100644
--- a/patches/nginx-1.3.4-dtrace.patch
+++ b/patches/nginx-1.3.4-dtrace.patch
@@ -454,10 +454,10 @@ index efbc244..8d81aab 100644
  
 diff --git a/src/dtrace/nginx.stp b/src/dtrace/nginx.stp
 new file mode 100644
-index 0000000..3dde1be
+index 0000000..6420250
 --- /dev/null
 +++ b/src/dtrace/nginx.stp
-@@ -0,0 +1,199 @@
+@@ -0,0 +1,236 @@
 +/* tapset for nginx */
 +
 +/* retrieve the request uri string from the ngx_http_request_t pointer */
@@ -555,6 +555,24 @@ index 0000000..3dde1be
 +}
 +
 +
++function ngx_buf_last_buf(b)
++{
++    return @cast(b, "ngx_buf_t", "/home/agentzh/git/lua-nginx-module/work/nginx/sbin/nginx")->last_buf
++}
++
++
++function ngx_buf_sync(b)
++{
++    return @cast(b, "ngx_buf_t", "/home/agentzh/git/lua-nginx-module/work/nginx/sbin/nginx")->sync
++}
++
++
++function ngx_buf_flush(b)
++{
++    return @cast(b, "ngx_buf_t", "/home/agentzh/git/lua-nginx-module/work/nginx/sbin/nginx")->flush
++}
++
++
 +function ngx_buf_size(b)
 +{
 +    if (ngx_buf_in_memory(b)) {
@@ -587,7 +605,26 @@ index 0000000..3dde1be
 +    cl = input
 +    while (cl) {
 +        buf = ngx_chain_buf(cl)
-+        out .= sprintf("[%s]", text_str(ngx_buf_data(buf)))
++
++        if (ngx_buf_in_memory(buf)) {
++            out .= sprintf("[%s]", text_str(ngx_buf_data(buf)))
++
++        } else {
++            out .= "\"\""
++        }
++
++        if (ngx_buf_last_buf(buf)) {
++            out .= "<eof>"
++        }
++
++        if (ngx_buf_sync(buf)) {
++            out .= "<sync>"
++        }
++
++        if (ngx_buf_flush(buf)) {
++            out .= "<flush>"
++        }
++
 +        cl = ngx_chain_next(cl)
 +        if (cl) {
 +            out .= sprintf(" ")