nginx-0.0.1-2003-04-14-21:04:58 import
diff --git a/src/core/ngx_connection.h b/src/core/ngx_connection.h
index bbb6a3b..b5c8c88 100644
--- a/src/core/ngx_connection.h
+++ b/src/core/ngx_connection.h
@@ -85,6 +85,7 @@
                                         (ngx_connection_t *c, ngx_chain_t *in);
 
 
+ssize_t ngx_recv_chain(ngx_connection_t *c, ngx_chain_t *ce);
 ngx_chain_t *ngx_write_chain(ngx_connection_t *c, ngx_chain_t *in, off_t flush);
 
 
diff --git a/src/core/ngx_file.c b/src/core/ngx_file.c
index b053722..7576c9b 100644
--- a/src/core/ngx_file.c
+++ b/src/core/ngx_file.c
@@ -28,7 +28,7 @@
 
     for ( ;; ) {
         snprintf(file->name.data + path->name.len + 1 + path->len, 11,
-                 "%010d", num);
+                 "%010u", num);
 
         ngx_create_hashed_filename(file, path);
 
@@ -49,6 +49,8 @@
 
         file->fd = ngx_open_tempfile(file->name.data, persistent);
 
+ngx_log_debug(file->log, "temp fd: %d" _ file->fd);
+
         if (file->fd != NGX_INVALID_FILE) {
             return NGX_OK;
         }
@@ -56,7 +58,7 @@
         err = ngx_errno;
 
         if (err == NGX_EEXIST) {
-            num *= step;
+            num = (num + 1) * step;
             continue;
         }
 
diff --git a/src/core/ngx_hunk.h b/src/core/ngx_hunk.h
index de691f8..ddf4d04 100644
--- a/src/core/ngx_hunk.h
+++ b/src/core/ngx_hunk.h
@@ -11,26 +11,27 @@
 /* hunk type */
 
 /* the hunk is in memory */
-#define NGX_HUNK_IN_MEMORY  0x0001
+#define NGX_HUNK_IN_MEMORY    0x0001
 /* the hunk's content can be changed */
-#define NGX_HUNK_TEMP       0x0002
+#define NGX_HUNK_TEMP         0x0002
 /* the hunk's content is in cache and can not be changed */
-#define NGX_HUNK_MEMORY     0x0004
+#define NGX_HUNK_MEMORY       0x0004
 /* the hunk's content is mmap()ed and can not be changed */
-#define NGX_HUNK_MMAP       0x0008
+#define NGX_HUNK_MMAP         0x0008
 
-#define NGX_HUNK_RECYCLED   0x0010
+#define NGX_HUNK_RECYCLED     0x0010
 
 /* the hunk is in file */
-#define NGX_HUNK_FILE       0x0100
+#define NGX_HUNK_FILE         0x0100
 
 /* hunk flags */
 
 /* in thread state flush means to write the hunk completely before return */
 /* in event state flush means to start to write the hunk */
-#define NGX_HUNK_FLUSH      0x1000
+#define NGX_HUNK_FLUSH        0x1000
 /* last hunk */
-#define NGX_HUNK_LAST       0x2000
+#define NGX_HUNK_LAST         0x2000
+#define NGX_HUNK_LAST_SHADOW  0x4000
 
 
 
@@ -69,7 +70,12 @@
 ngx_hunk_t *ngx_create_temp_hunk(ngx_pool_t *pool, int size,
                                  int before, int after);
 
+#define ngx_alloc_hunk(pool) ngx_palloc(pool, sizeof(ngx_hunk_t))
+#define ngx_alloc_chain_entry(pool) ngx_palloc(pool, sizeof(ngx_chain_t))
+
+/* STUB */
 #define ngx_create_chain_entry(pool) ngx_palloc(pool, sizeof(ngx_chain_t))
+/**/
 
 #define ngx_add_hunk_to_chain(chain, h, pool, error)                         \
             do {                                                             \