httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Randy Terbush <ra...@zyzzyva.com>
Subject Re: HostAlias...
Date Mon, 01 Apr 1996 18:21:13 GMT

This is the code I was refering to in previous mail. I think this
could be what is causing the problem on the Solaris machine. The
aborted partial write will return a positive value.


> 
> > 
> > 
> > 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