Re: cvs: php4 /ext/standard file.c
| From: | Sascha Schumann | Date: | Fri, 22 Dec 2000 17:02:07 +0000 |
| Subject: | Re: cvs: php4 /ext/standard file.c | ||
| References: | 1 | Groups: | php.cvs |
| Request: | Send a blank email to php-cvs+get-3229@lists.php.net to get a copy of this message | ||
On Fri, 22 Dec 2000, Andi Gutmans wrote:
> As you're doing the write() in one go now and the file could be very big
> you're best off checking the return value on how much has been written and
> call write() as many times as needed. Less change that the 8K buffer will
> fail although it should also be done if mmap() isn't being used.
> Probably best if we have full_write() and full_read() API functions which
> do it for you and change most places to use these.
Functions which are dealing with non-regular files might
benefit of such an API.
In this case though it does not matter, because we are
dealing with regular files. The only reason why write(2)
could write less bytes than requested is the shortage of
available space (i.e. limited through ulimit or physical
storage limitations). Trying to write more bytes in that
case will get us a SIGXFSZ signal and probably terminate the
process. So, that is even more harmful than the current
behaviour.
A possible improvement in this case is checking the return
value of write and setting ret only to SUCCESS, if the amount
of written bytes equals the size of the source file.
- Sascha