Re: Redirector fgets error

From: Dancer <dancer@dont-contact.us>
Date: Wed, 28 Apr 1999 21:16:37 +1000

Jesus Redrado wrote:
>
> Hi,
>
> My redirector uses the following code to make standard output line buffered:
>
> if (setvbuf(stdout,NULL,_IOLBF,0) !=0)
> return -1;
>
> while ( fgets(buffer,BUFFER_SIZE,stdin ) != NULL){
> /*..........*/
> }
>
> Should it make standard input no buffered ?
>
> By example,
>
> if (setvbuf(stdout,NULL,_IOLBF,0) !=0)
> return -1;
>
> if (setvbuf(stdin,NULL,_IONBF,0) !=0)
> return -1;
>
> while ( fgets(buffer,BUFFER_SIZE,stdin ) != NULL){
> /*..........*/
> }
>
> However, my code works fine under Squid 1.1.22
>
> Thanks,
>
> Jesús Redrado
> EduNet
> jredrado@edunet.es
>
> -----Mensaje original-----
> De: Maciej Kozinski <Maciej.Kozinski@uck.uni.torun.pl>
> Para: Jesus Redrado <jredrado@edunet.es>
> CC: squid-users@ircache.net <squid-users@ircache.net>
> Fecha: Wednesday, April 28, 1999 11:47 AM
> Asunto: Re: Redirector fgets error
>
> >Jesus Redrado:
> >>
> >> I've developed a redirector program using C/C++.
> >>
> >> It works fine under Squid 1.1.22, but under Squid 2.1.PATCH2 and Squid
> >> 2.2.STABLE2 does not work.
> >>
> >> It uses the following code to read from Squid:
> >>
> >> while ( fgets(buffer,BUFFER_SIZE,stdin ) != NULL){
> >> /*..........*/
> >> }
> >
> >AFAIK redirector cannot use buffered i/o.

You can ignore buffering on stdin, pretty much. It's line-buffered, but
that's exactly what you want. As long as you fflush(stdout) after
writing each output url, you shouldn't have any problems with stream
buffering.

D
Received on Wed Apr 28 1999 - 06:11:10 MDT

This archive was generated by hypermail pre-2.1.9 : Tue Dec 09 2003 - 16:46:00 MST