apr-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Eric Covener" <cove...@gmail.com>
Subject Re: PR43563 patch for writes to non-blocking pipes on Windows
Date Tue, 09 Oct 2007 02:32:46 GMT
On 10/8/07, Jeff Trawick <trawick@gmail.com> wrote:
> On 10/8/07, Eric Covener <covener@gmail.com> wrote:
> > On 10/6/07, Jeff Trawick <trawick@gmail.com> wrote:
> > > http://issues.apache.org/bugzilla/show_bug.cgi?id=43563
> > >
> > > This patch looks reasonable to me; any thoughts from the Windows crowd?
> > >
> >
> > 43522 is a close cousin:
> >
> > http://issues.apache.org/bugzilla/show_bug.cgi?id=43522
>
> plz save me some time and help me understand why this first part of
> this patch checks APR_READ_BLOCK and APR_WRITE_BLOCK, whereas the part
> of the patch for the other two handles checks APR_PARENT_BLOCK and
> APR_CHILD_BLOCK (the Unix code checks ...PARENT... and ...CHILD... for
> all three handles)
>
> @@ -95,27 +95,75 @@
>
>          if (in == APR_NO_FILE)
>              attr->child_in = &no_file;
> -        else
> +        else {
>              stat = apr_create_nt_pipe(&attr->child_in, &attr->parent_in,
>                                        in, attr->pool);
> +            if (stat == APR_SUCCESS) {
> +                switch (in) {
> +                    case APR_FULL_BLOCK:
> +                        break;
> +                    case APR_READ_BLOCK:
> +                        apr_file_pipe_timeout_set(attr->parent_in, 0);
> +                        break;
> +                    case APR_WRITE_BLOCK:
> +                        apr_file_pipe_timeout_set(attr->child_in, 0);
> +                        break;
>
> Thanks!
>

The stdin parameter is transposed early in this routine for subsequent
calls to apr_create_nt_pipe() who only speaks in terms of
APR_READ_BLOCK/APR_WRITE_BLOCK and not parent/child.

(and I wanted the patch to be as minimal as possible)

        /* APR_CHILD_BLOCK maps to APR_WRITE_BLOCK, while
         * APR_PARENT_BLOCK maps to APR_READ_BLOCK, so we
         * must transpose the CHILD/PARENT blocking flags
         * only for the stdin pipe.  stdout/stderr naturally
         * map to the correct mode.
         */
        if (in == APR_CHILD_BLOCK)
            in = APR_READ_BLOCK;
        else if (in == APR_PARENT_BLOCK)
            in = APR_WRITE_BLOCK;

For stdin, APR_CHILD_BLOCK becomes APR_READ_BLOCK which means the
parent/writer is non-blocking:

> +                    case APR_READ_BLOCK:
> +                        apr_file_pipe_timeout_set(attr->parent_in, 0);

For stderr/stdout, APR_CHILD_BLOCK is mapped directly  and the
parent/reader is non-blocking:
+                    case APR_CHILD_BLOCK:
+                        apr_file_pipe_timeout_set(attr->parent_out, 0);

-- 
Eric Covener
covener@gmail.com

Mime
View raw message