Re: CVS update [cvs1-11-x-branch]: /ccvs/src/
Derek Robert Price <[email protected]> Thu, 02 Sep 2004 11:40:16 -0400
| Newsgroups | gmane.comp.lib.gnulib.bugs,gmane.comp.version-control.cvs.bugs |
|---|---|
| Organization | Ximbiot <http://ximbiot.com> |
| Message-ID | <[email protected]> |
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Paul Eggert wrote: >Derek Robert Price <[email protected]> writes: > >>The alternative would seem to be a fix at the OS level to prevent >>stdout & stderr from being set nonblock, > > >That sounds unlikely. Among other things, I don't think POSIX >allows it. > >I recall proposing a less-intrusive solution; see ><http://lists.gnu.org/archive/html/bug-cvs/2002-08/msg00032.html>. >You demurred because it involves a separate process to copy stderr and >you were worried about the inefficiencies involved. Can you quantify >these inefficiencies? Perhaps they're not worth worrying about, in >practice. If so, the extra-process solution may be the way to go, >despite its minor inefficiencies. I think we recently settled in this thread that a wrapper around the fwrite() function would prove as effective and is almost certainly more efficient. Why would the extra-process be preferrable to an fwrite() wrapper that watched for incomplete writes and looped until all the data was written? >>Perhaps having a substitute for the stdio routines is still the best >>preventative measure for this sort of problem. > > >But this would require rewriting/auditing every part of CVS that can >write to the affected descriptors, no? A thankless and error/prone >job. No wonder nobody wants to do it. It'd likely introduce bugs. A function like: size_t fwrite_block (const void *ptr, size_t size, size_t nmemb, FILE *stream) { size_t nwritten = 0; size_t nbytes = 0; while (nmemb > nwritten) { /* Convert to bytes since the system fwrite() is not guaranteed to return * an object count we can equate to our file position for any other SIZE. * Also, write a maximum of SIZE_MAX bytes each pass. This is also * a limitation of the POSIX fwrite(). */ size_t towrite = xtimes (nmemb - nwritten, size) - nbytes; size_t written; select (FILENO(stream)+1, ...); /* Pseudocode select here */ written = fwrite (ptr, 1, towrite, stream); ptr += written; nwritten += (written + nbytes) / size; nbytes = (written + nbytes) % size; if (ferror (stream)) break; } return nwritten; } and a: #define fwrite fwrite_block seems as effective and even less bug-prone than the extra-process. I've already volunteered to write it. I just wanted to get some feedback on it, like if anyone else could spot problems I'd missed and whether it sounded like a viable GNULIB module, before I did. Cheers, Derek - -- *8^) Email: [email protected] Get CVS support at <http://ximbiot.com>! -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.3 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFBNz7dLD1OTBfyMaQRAhTOAJ9WZ65nFNvIBlL2R7rq3j7/26he/QCcDdSW 3axDyAsi2BDcq2ANSDFhoko= =ndyj -----END PGP SIGNATURE-----