nginx-0.0.1-2003-10-27-11:53:49 import
diff --git a/src/core/ngx_file.c b/src/core/ngx_file.c
index 2383e5c..84e86ff 100644
--- a/src/core/ngx_file.c
+++ b/src/core/ngx_file.c
@@ -7,6 +7,27 @@
 static int ngx_random;
 
 
+int ngx_write_chain_to_temp_file(ngx_temp_file_t *tf, ngx_chain_t *chain)
+{
+    int  rc;
+
+    if (tf->file.fd == NGX_INVALID_FILE) {
+        rc = ngx_create_temp_file(&tf->file, &tf->path, tf->pool,
+                                  tf->persistent);
+    
+        if (rc == NGX_ERROR || rc == NGX_AGAIN) {
+            return rc;
+        }
+
+        if (!tf->persistent && tf->warn) {
+            ngx_log_error(NGX_LOG_WARN, tf->file.log, 0, tf->warn);
+        }
+    }
+
+    return ngx_write_chain_to_file(&tf->file, chain, tf->file.offset, tf->pool);
+}
+
+
 int ngx_create_temp_file(ngx_file_t *file, ngx_path_t *path,
                          ngx_pool_t *pool, int persistent)
 {