# Ngx\_write\_chain\_to\_temp\_file and NGX\_AGAIN

**URL:** <https://www.ruby-forum.com/t/ngx-write-chain-to-temp-file-and-ngx-again/121412>\
**Category:** NGINX\
**Created:** [November 27, 2007, 7:19pm UTC](https://www.ruby-forum.com/t/ngx-write-chain-to-temp-file-and-ngx-again/121412 "2007-11-27T19:19:05Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Manlio\_P](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/6f9a4e/32.png) [@Manlio\_P](https://www.ruby-forum.com/u/Manlio_P)\
**Post date:** [November 27, 2007, 7:19pm UTC](https://www.ruby-forum.com/t/ngx-write-chain-to-temp-file-and-ngx-again/121412/1 "2007-11-27T19:19:05Z")

</div>

Hi.

I’m reading the code for writing a temporary buffer in a temporary file,  
and I have noted something not very clear.

Here is the code (core/ngx\_file.c):  
ngx\_write\_chain\_to\_temp\_file(ngx\_temp\_file\_t \*tf, ngx\_chain\_t \*chain)  
{  
ngx\_int\_t rc;

```
 if (tf->file.fd == NGX_INVALID_FILE) {
     rc = ngx_create_temp_file(&tf->file, tf->path, tf->pool,
                               tf->persistent, tf->clean,
                               tf->access);

     if (rc == NGX_ERROR || rc == NGX_AGAIN) {
         return rc;
     }

```

However it seems that ngx\_create\_temp\_file never returns NGX\_AGAIN.

Moreover the functions ngx\_event\_pipe\_write\_chain\_to\_temp\_file  
(event/ngx\_event\_pipe.c) and ngx\_http\_write\_request\_body  
(http/ngx\_http\_request\_body) only check for NGX\_ERROR and not for  
NGX\_AGAIN.

So, should I check for NGX\_ERROR only?

Thanks Manlio P.

---

<div class="post-metadata">

**Author:** ![Manlio\_P](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/6f9a4e/32.png) [@Manlio\_P](https://www.ruby-forum.com/u/Manlio_P)\
**Post date:** [November 27, 2007, 9:46pm UTC](https://www.ruby-forum.com/t/ngx-write-chain-to-temp-file-and-ngx-again/121412/2 "2007-11-27T21:46:49Z")

</div>

On Tue, Nov 27, 2007 at 07:08:31PM +0100, Manlio P. wrote:

> ```
> tf->persistent, tf->clean,
> 
> ```
> 
> Moreover the functions ngx\_event\_pipe\_write\_chain\_to\_temp\_file  
> (event/ngx\_event\_pipe.c) and ngx\_http\_write\_request\_body  
> (http/ngx\_http\_request\_body) only check for NGX\_ERROR and not for NGX\_AGAIN.
> 
> So, should I check for NGX\_ERROR only?

Yes. This is artefact of times when I plan to do aync open() files using  
special threads.
