httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ben Laurie <...@gonzo.ben.algroup.co.uk>
Subject Re: HostAlias...
Date Mon, 01 Apr 1996 15:34:28 GMT
> 
> 
> On the subject of write() and fwrite(), one catch
> might be that the first one returns -1 on a fail whereas the
> latter returns 0 I think, so a loop like
> 
>       while(n && !r->connection->aborted) {
>             w=fwrite(&buf[o],sizeof(char),n,c->client);
>             n-=w;
>             o+=w;
>             };
> 
> goes OK, but this goes bang

No it doesn't ... you need something more like:

	 do
             {
             w=fwrite(&buf[o],sizeof(char),n,c->client);
             n-=w;
             o+=w;
             }
         while(w && n && !r->connection->aborted);



> 
>       while(n && !r->connection->aborted) {
>             w=write(....; /* returns -1 on a fail ! */
>             n-=w;
>             o+=w;
> 	    };
> 
> I got caught by that recently.
> 

And in this case:

	 do
             {
             w=write(...
             n-=w;
             o+=w;
             }
         while(w > 0 && n && !r->connection->aborted);

Cheers,

Ben.

> Dw.

-- 
Ben Laurie                  Phone: +44 (181) 994 6435
Freelance Consultant and    Fax:   +44 (181) 994 6472
Technical Director          Email: ben@algroup.co.uk
A.L. Digital Ltd,           URL: http://www.algroup.co.uk
London, England.

Mime
View raw message