httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Greg Stein <>
Subject Re: cvs commit: httpd-2.0/server log.c
Date Fri, 24 May 2002 01:36:04 GMT
On Thu, May 23, 2002 at 02:31:45PM -0700, Justin Erenkrantz wrote:
> On Thu, May 23, 2002 at 02:25:48PM -0700, Greg Stein wrote:
> > Oof... needlessly complicated. Just use apr_file_read_full(). It will return
> > all the bytes that you ask for, unless an error condition occurs (EOF).
> > There is no need to do any looping.
> You'd have to do a stat() on the file to get the file size as we
> don't know how much data we need.  
> According to the docs, it says that it is not possible for bytes
> to be read and an APR_EOF error to be returned.  That seems like
> it is conflict with the Unix impl though.  (The Unix impl could
> return bytes and APR_EOF.)  -- justin

The doc should probably match that of write_full:

    It is possible for both bytes to be written and an error to be
    returned.  And if *bytes_written is less than nbytes, an
    accompanying error is _always_ returned.

IOW, read_full should be: you get success and all-read, or you get an error
and some-read. But never EINTR or somesuch.

It means that you can avoid the stupid loops to ensure that you get
everything read or written.

In the case of the pidfile, you just read in BUFFER_SIZE. It will always
come back with some number read and APR_EOF. If you truly read that many
bytes, then something is wrong :-)


Greg Stein,

View raw message