curl-users
Re: setvbuf considered dangerous
Date: Thu, 26 Jun 2003 03:28:10 -0500
Actually, I now see better what the problem is. The current code will
not let you set no buffering (-N) mode on stdout. Since the file is
already open, the code that checks to see if you want no buffering
mode will never get executed.
My fix below still applies, and makes curl less dependandant on
whether setvbuf() exists or is/isnot broken.
-Rick
On Thu, Jun 26, 2003 at 12:43:01AM -0500, Rick Richardson wrote:
>
> I've been having trouble with getting unbuffered output from curl.
> I guess old versions forgot to call setvbuf(). So I tried 7.10.5
> on Redhat 9. Here we have the trouble that setvbuf() doesn't seem
> to work.
>
> setvbuf() has been broken so many ways in various Unixes over the
> years (calling args reversed, etc). that I think its best to avoid it
> altogether.
>
> I made this change at the end of my_fwrite() in main.c
> and now it works fine...
>
> int rc;
>
> rc = fwrite(buffer, size, nmemb, out->stream);
> if (config->nobuffer)
> fflush(out->stream);
> return rc;
>
> For safeties sake, I urge adoption of this change.
>
> -Rick
>
> --
> Rick Richardson rickr@mn.rr.com http://home.mn.rr.com/richardsons/
> Stock information at your fingertips: http://linuxtrade.0catch.com/
>
> "Trees grow, we use them." -- Daxxx
-- Rick Richardson rickr@mn.rr.com http://home.mn.rr.com/richardsons/ Stock information at your fingertips: http://linuxtrade.0catch.com/ Important data should not be entrusted to Fisher, as it may eat it and make loud belching noises. -- RH 7.1 beta release notes. ------------------------------------------------------- This SF.Net email is sponsored by: INetU Attention Web Developers & Consultants: Become An INetU Hosting Partner. Refer Dedicated Servers. We Manage Them. You Get 10% Monthly Commission! INetU Dedicated Managed Hosting http://www.inetu.net/partner/index.phpReceived on 2003-06-26