You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@apr.apache.org by rb...@apache.org on 2002/12/12 01:51:09 UTC

Tests hanging on Windows

The tests currently hang in testpipe on Windows.  The problem is the test
that tries to read from the pipe with a timeout.  The test doesn't write
anything to the pipe before reading, although it does set a 1 second
timeout.  However, on Windows, the pipe timeout is never popping.  I
haven't had much time to debug, so if another Windows person wants to look
at it.  This should be an easy one to debug quickly.

Ryan


Re: Tests hanging on Windows

Posted by rb...@apache.org.

On Thu, 12 Dec 2002, [UTF-8] Branko Čibej wrote:

> rbb@apache.org wrote:
>
> >I've done more research.  Wow, this is ugly.  Basically, Windows doesn't
> >allow you to open anonymous pipes in a non-blocking mode.  That means that
> >it is impossible to timeout a pipe read/write.  Now for the good news.
> >There are two possible solutions.
> >
> >1)  Switch to using named pipes for platforms that support them.  This has
> >the advantage that we can open the pipe in overlapped mode, but it won't
> >work on older versions of Windows (9x, ME specifically).  This also means
> >that APR itself will have a need to get a temporary filename, because we
> >will need to have a name for the named pipe, but we can essentially forget
> >the name of the pipe immediately.
> >
> On NT-class systems (NT, 2000, XP), anonymous pipes are implemented on
> top of named pipes, using a unique pipe name. So there'd really be no
> difference if APR used this approach.

I actually knew that, but there is one difference.  When opening a named
pipe, you can pass in the overlapped flag, which you can't do when opening
an anonymous pipe.  :-(

> DOS-based Windows don't support named pipes, of course. Maybe it would
> be acceptable to return APR_ENOTIMPL if someone tried to open a
> non-blocking pipe on Win9x?

I could accept that.

BTW, I did more research still, and for apr_proc_create, we use named
pipes, so those can be non-blocking.  That essentially means that we have
the ability to do something inside APR that we aren't exposing to our
users.

Ryan


Re: Tests hanging on Windows

Posted by Branko Čibej <br...@xbc.nu>.
rbb@apache.org wrote:

>I've done more research.  Wow, this is ugly.  Basically, Windows doesn't
>allow you to open anonymous pipes in a non-blocking mode.  That means that
>it is impossible to timeout a pipe read/write.  Now for the good news.
>There are two possible solutions.
>
>1)  Switch to using named pipes for platforms that support them.  This has
>the advantage that we can open the pipe in overlapped mode, but it won't
>work on older versions of Windows (9x, ME specifically).  This also means
>that APR itself will have a need to get a temporary filename, because we
>will need to have a name for the named pipe, but we can essentially forget
>the name of the pipe immediately.
>
On NT-class systems (NT, 2000, XP), anonymous pipes are implemented on
top of named pipes, using a unique pipe name. So there'd really be no
difference if APR used this approach.

DOS-based Windows don't support named pipes, of course. Maybe it would
be acceptable to return APR_ENOTIMPL if someone tried to open a
non-blocking pipe on Win9x?


-- 
Brane Čibej   <br...@xbc.nu>   http://www.xbc.nu/brane/


RE: Tests hanging on Windows

Posted by rb...@apache.org.

On Thu, 12 Dec 2002, Bill Stoddard wrote:

> > On Wed, 11 Dec 2002 rbb@apache.org wrote:
> >
> > >
> > > The tests currently hang in testpipe on Windows.  The problem is the test
> > > that tries to read from the pipe with a timeout.  The test doesn't write
> > > anything to the pipe before reading, although it does set a 1 second
> > > timeout.  However, on Windows, the pipe timeout is never popping.  I
> > > haven't had much time to debug, so if another Windows person wants to look
> > > at it.  This should be an easy one to debug quickly.
> >
> > I've done more research.  Wow, this is ugly.  Basically, Windows doesn't
> > allow you to open anonymous pipes in a non-blocking mode.  That means that
> > it is impossible to timeout a pipe read/write.  Now for the good news.
> > There are two possible solutions.
> >
> > 1)  Switch to using named pipes for platforms that support them.  This has
> > the advantage that we can open the pipe in overlapped mode, but it won't
> > work on older versions of Windows (9x, ME specifically).  This also means
> > that APR itself will have a need to get a temporary filename, because we
> > will need to have a name for the named pipe, but we can essentially forget
> > the name of the pipe immediately.
> >
> > 2)  The second option is to do what cygwin does.  Namely, instead of
> > calling ReadFile on the pipe, call PeekNamedPipe repeatedly until there is
> > data or the timeout pops.  This is moderately ugly, because it means that
> > we won't see the data as soon as it is available to be read.  It also
> > means that an idle process that is just reading on the pipe will actually
> > take some resources occaisionally (I would assume once every second or so)
> > to check if there has been any activity.
> >
> > Does anybody have any opinions?  I can't believe that we have gone this
> > long without timeouts working on pipes on Windows.
>
> Take a look at file_io/win32/readwrite.c. Search for PeekNamedPipe.  Then take a
> peek at apr_create_nt_pipe in pipe.c.  This is the function that you are looking
> for and it needs to be exposed in a more generally useful and portable way.

This is the function that should be used for apr_create_pipe on NT-based
platforms.  That would have solved this problem cleanly.  I'll try to
create a patch sometime tonight.

Ryan


RE: Tests hanging on Windows

Posted by Bill Stoddard <bi...@wstoddard.com>.
> On Wed, 11 Dec 2002 rbb@apache.org wrote:
>
> >
> > The tests currently hang in testpipe on Windows.  The problem is the test
> > that tries to read from the pipe with a timeout.  The test doesn't write
> > anything to the pipe before reading, although it does set a 1 second
> > timeout.  However, on Windows, the pipe timeout is never popping.  I
> > haven't had much time to debug, so if another Windows person wants to look
> > at it.  This should be an easy one to debug quickly.
>
> I've done more research.  Wow, this is ugly.  Basically, Windows doesn't
> allow you to open anonymous pipes in a non-blocking mode.  That means that
> it is impossible to timeout a pipe read/write.  Now for the good news.
> There are two possible solutions.
>
> 1)  Switch to using named pipes for platforms that support them.  This has
> the advantage that we can open the pipe in overlapped mode, but it won't
> work on older versions of Windows (9x, ME specifically).  This also means
> that APR itself will have a need to get a temporary filename, because we
> will need to have a name for the named pipe, but we can essentially forget
> the name of the pipe immediately.
>
> 2)  The second option is to do what cygwin does.  Namely, instead of
> calling ReadFile on the pipe, call PeekNamedPipe repeatedly until there is
> data or the timeout pops.  This is moderately ugly, because it means that
> we won't see the data as soon as it is available to be read.  It also
> means that an idle process that is just reading on the pipe will actually
> take some resources occaisionally (I would assume once every second or so)
> to check if there has been any activity.
>
> Does anybody have any opinions?  I can't believe that we have gone this
> long without timeouts working on pipes on Windows.

Take a look at file_io/win32/readwrite.c. Search for PeekNamedPipe.  Then take a
peek at apr_create_nt_pipe in pipe.c.  This is the function that you are looking
for and it needs to be exposed in a more generally useful and portable way.

Bill


Re: Tests hanging on Windows

Posted by rb...@apache.org.

On Wed, 11 Dec 2002 rbb@apache.org wrote:

>
> The tests currently hang in testpipe on Windows.  The problem is the test
> that tries to read from the pipe with a timeout.  The test doesn't write
> anything to the pipe before reading, although it does set a 1 second
> timeout.  However, on Windows, the pipe timeout is never popping.  I
> haven't had much time to debug, so if another Windows person wants to look
> at it.  This should be an easy one to debug quickly.

I've done more research.  Wow, this is ugly.  Basically, Windows doesn't
allow you to open anonymous pipes in a non-blocking mode.  That means that
it is impossible to timeout a pipe read/write.  Now for the good news.
There are two possible solutions.

1)  Switch to using named pipes for platforms that support them.  This has
the advantage that we can open the pipe in overlapped mode, but it won't
work on older versions of Windows (9x, ME specifically).  This also means
that APR itself will have a need to get a temporary filename, because we
will need to have a name for the named pipe, but we can essentially forget
the name of the pipe immediately.

2)  The second option is to do what cygwin does.  Namely, instead of
calling ReadFile on the pipe, call PeekNamedPipe repeatedly until there is
data or the timeout pops.  This is moderately ugly, because it means that
we won't see the data as soon as it is available to be read.  It also
means that an idle process that is just reading on the pipe will actually
take some resources occaisionally (I would assume once every second or so)
to check if there has been any activity.

Does anybody have any opinions?  I can't believe that we have gone this
long without timeouts working on pipes on Windows.

Ryan