You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@apr.apache.org by Greg Stein <gs...@lyra.org> on 2001/02/17 02:07:08 UTC
Re: cvs commit: apr/network_io/unix sendrecv.c
On Fri, Feb 16, 2001 at 09:34:09PM -0000, trawick@apache.org wrote:
>...
> + /* HP-UX can only send one header iovec and one footer iovec; try to
> + * only allocate storage to combine input iovecs when we really have to
> + */
>...
> + /* XXX: BUHHH? wow, what a memory leak! */
> + headerbuf = hdtrarray[0].iov_base = apr_palloc(sock->cntxt, headerlen);
Use a subpool. Create if/when you need to do this apr_palloc() (or the one
for the trailers). Toss on exit from the function (watch out for early exit).
>...
> do {
> + if (nbytes) { /* any bytes to send from the file? */
> + rc = sendfile(sock->socketdes, /* socket */
> + file->filedes, /* file descriptor to send */
> + *offset, /* where in the file to start */
> + nbytes, /* number of bytes to send from file */
> + hdtrarray, /* Headers/footers */
> + flags); /* undefined, set to 0 */
> + }
> + else { /* we can't call sendfile() for trailers only */
> + rc = write(sock->socketdes, hdtrarray[1].iov_base, hdtrarray[1].iov_len);
> + }
> + } while (rc == -1 && errno == EINTR);
If nbytes==0, then where/how are the headers sent? I just see the trailers.
Cheers,
-g
--
Greg Stein, http://www.lyra.org/
Re: cvs commit: apr/network_io/unix sendrecv.c
Posted by Jeff Trawick <tr...@bellsouth.net>.
Greg Stein <gs...@lyra.org> writes:
> On Fri, Feb 16, 2001 at 09:34:09PM -0000, trawick@apache.org wrote:
> >...
> > + /* HP-UX can only send one header iovec and one footer iovec; try to
> > + * only allocate storage to combine input iovecs when we really have to
> > + */
> >...
> > + /* XXX: BUHHH? wow, what a memory leak! */
> > + headerbuf = hdtrarray[0].iov_base = apr_palloc(sock->cntxt, headerlen);
>
> Use a subpool. Create if/when you need to do this apr_palloc() (or the one
> for the trailers). Toss on exit from the function (watch out for
> early exit).
good idea; I'll work it into the HP and other platform versions of
apr_sendfile()
> > do {
> > + if (nbytes) { /* any bytes to send from the file? */
> > + rc = sendfile(sock->socketdes, /* socket */
> > + file->filedes, /* file descriptor to send */
> > + *offset, /* where in the file to start */
> > + nbytes, /* number of bytes to send from file */
> > + hdtrarray, /* Headers/footers */
> > + flags); /* undefined, set to 0 */
> > + }
> > + else { /* we can't call sendfile() for trailers only */
> > + rc = write(sock->socketdes, hdtrarray[1].iov_base, hdtrarray[1].iov_len);
> > + }
> > + } while (rc == -1 && errno == EINTR);
>
> If nbytes==0, then where/how are the headers sent? I just see the
> trailers.
yeah, a built-in assumption that apr_sendfile() is used in an
"appropriate" manner; i.e., you never have headers followed by 0 bytes
from the file followed by trailers, though in a repeat call on a
non-blocking socket you might have no headers (already sent) followed
by 0 bytes from the file (already sent) followed by trailers
I'll add some simple quick failure path to the FreeBSD and HP-UX
flavors.
Thanks!
--
Jeff Trawick | trawickj@bellsouth.net | PGP public key at web site:
http://www.geocities.com/SiliconValley/Park/9289/
Born in Roswell... married an alien...