Re: cvs: php4 /ext/standard file.c

From: Date: Sat, 23 Dec 2000 12:29:09 +0000
Subject: Re: cvs: php4 /ext/standard file.c
References: 1 2 3  Groups: php.cvs 
Request: Send a blank email to php-cvs+get-3258@lists.php.net to get a copy of this message
At 14:43 23/12/2000, Michael Widenius wrote:
This code is a good example of the write() API problem. If write() does not return Count, the code assumes that errno was set by write(). If errno was not set by write(), the code will simply take the error code from a previous system call and reinterprete it in this context. That is pretty much wrong, considering the following three paragraphs:
The above is not really right; If you check the code of my_write(), it only uses errno if write() returns 0 or -1, in which case errno should contain the right error code.
I can't see how it does that... What if Count equals 1024, but write() returns only 512? It won't reach the 'break' statement, and will fall through and use errno. Sascha's main concern is this: (a) according to the documentation, errno is only set if write() returns -1 - a 'complete' error code. (b) when reaching the end of the disk space, we may have a situation where a write() will succeed partially, i.e., it will write bytes, but not as many as we asked. In this case, write() will return a positive integer, that is lower than the count we sent it. The big question is - whether errno will be set or not. The documentation says nothing about it. It's extremely odd if it won't be set though, because it would then essentially mean that there's no way to properly handle this situation. Question is - do you have real world experience with this? Zeev -- Zeev Suraski <zeev@zend.com> CTO & co-founder, Zend Technologies Ltd. http://www.zend.com/

« previous php.cvs (#3258) next »