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

From: Date: Sat, 23 Dec 2000 12:43:03 +0000
Subject: Re: cvs: php4 /ext/standard file.c
References: 1 2  Groups: php.cvs 
Request: Send a blank email to php-cvs+get-3257@lists.php.net to get a copy of this message
Hi! >>>>> "Zeev" == Zeev Suraski <zeev@zend.com> writes: Zeev> That's what I said in the subsequent letter. Zeev> I tend to believe that this code is correct, for one main reason - the guy Zeev> who wrote it has more real-world experience than all three of us combined Zeev> times 2. Zeev> Monty? Zeev> Zeev Zeev> At 20:29 22/12/2000, Sascha Schumann wrote: >> On Fri, 22 Dec 2000, Zeev Suraski wrote: >> >> > Take a look at my_write(). It appears to support just about everything, >> > and it takes care of the problems you stated. We even have it in our >> > source tree. >> >> 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 know that we do a check of ENOSCP for all cases, but as this error is not very likely and the only action we take is to sleep for a short time and then continue, this is not really fatal). my_write() also does a retry until all bytes are written or until write() returns -1, so it's not likely that it should miss to write anything. Can you give us a scenario when my_write() can fail? >> (Especially note the absence of errno in the first and third >> paragraphs.) >> >> "If a write() requests that more bytes be written than there >> is room for (for example, the ulimit or the physical end of a >> medium), only as many bytes as there is room for will be >> written. For example, suppose there is space for 20 bytes >> more in a file before reaching a limit. A write of 512 bytes >> will return 20. The next write of a non-zero number of bytes >> will give a failure return (except as noted below) and the >> implementation will generate a SIGXFSZ signal for the thread. >> >> "If write() is interrupted by a signal before it writes any >> data, it will return -1 with errno set to [EINTR]. >> >> "If write() is interrupted by a signal after it successfully >> writes some data, it will return the number of bytes written. The only thing that 'may' conflict with the above in the my_write() code is that we check errno if write() returns 0. This isn't covered by your cases, but this is something I have seen happening with threads on some systems (in which case errno was always set to EINTR). Anyway, I can't quickly see any scenario when my_write() would fail without having a correct my_errno/errno set. Sasha, if you could give us a scenario that proves me the current code wrong, then we will of course change it! Regards, Monty

« previous php.cvs (#3257) next »