[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: CVS update [cvs1-11-x-branch]: /ccvs/src/
From: |
Derek Robert Price |
Subject: |
Re: CVS update [cvs1-11-x-branch]: /ccvs/src/ |
Date: |
Thu, 02 Sep 2004 11:40:16 -0400 |
User-agent: |
Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7) Gecko/20040616 |
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Paul Eggert wrote:
>Derek Robert Price <derek@ximbiot.com> 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: derek@ximbiot.com
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-----
- Re: CVS update [cvs1-11-x-branch]: /ccvs/src/, Derek Robert Price, 2004/09/02
- Re: CVS update [cvs1-11-x-branch]: /ccvs/src/, Paul Eggert, 2004/09/02
- Re: CVS update [cvs1-11-x-branch]: /ccvs/src/, Simon Josefsson, 2004/09/02
- Re: CVS update [cvs1-11-x-branch]: /ccvs/src/,
Derek Robert Price <=
- Re: CVS update [cvs1-11-x-branch]: /ccvs/src/, Paul Eggert, 2004/09/02
- Re: CVS update [cvs1-11-x-branch]: /ccvs/src/, Derek Robert Price, 2004/09/03
- Re: CVS update [cvs1-11-x-branch]: /ccvs/src/, Paul Eggert, 2004/09/03
- Re: [Bug-gnulib] Re: CVS update [cvs1-11-x-branch]: /ccvs/src/, Bruno Haible, 2004/09/04
- Re: [Bug-gnulib] Re: CVS update [cvs1-11-x-branch]: /ccvs/src/, Derek Robert Price, 2004/09/04
- Re: [Bug-gnulib] Re: CVS update [cvs1-11-x-branch]: /ccvs/src/, Bruno Haible, 2004/09/06
- Re: [Bug-gnulib] Re: CVS update [cvs1-11-x-branch]: /ccvs/src/, Derek Robert Price, 2004/09/07
- Re: [Bug-gnulib] Re: CVS update [cvs1-11-x-branch]: /ccvs/src/, Bruno Haible, 2004/09/04
- Re: [Bug-gnulib] Re: CVS update [cvs1-11-x-branch]: /ccvs/src/, Derek Robert Price, 2004/09/04
- Message not available
- Re: CVS update [cvs1-11-x-branch]: /ccvs/src/, Stefan Monnier, 2004/09/02