You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by Dean Gaudet <dg...@arctic.org> on 1998/05/10 09:46:01 UTC

non-blocking pipe on win32

It's not possible to get a non-blocking pipe on win32, right?  I'm
inferring this from the NSPR docs, and from something I recall here... 
ISTR the unbuffered CGI stuff in 1.3 on NT doesn't work at all.  [why is
microsoft so dense?]

I'm trying to figure out how to do the non-blocking stuff for CGIs in
NSPR... looks like I'm going to have to use multiple threads and
synchronize between them.

Dean



Re: non-blocking pipe on win32

Posted by Wan-Teh Chang <wt...@netscape.com>.
Out of curiosity, I looked at the mailslot docs a little more.
There are at least two gotchas:
- It is an unreliable datagram service.  Of course, one could argue
  that on a local machine there is no reason to lose mailslot datagrams.

  But this needs to be clarified.
- It is message-based.  This means if you read from it with too small
  a buffer, read will fail.  You must supply a buffer large enough to
hold
  the incoming message.

   What does this mean?  This means that the CGI program's stdin
   cannot be a mailslot handle, otherwise the CGI program may fail
   if it reads from stdin one byte at a time.

So it appears that you would need a setup like this:
    server  ===> CGI stdin: an unamed pipe
    server <===  CGI stdout: a mailslot, so that server reads can time
out.

Anyway, just some random thoughts.  I have never used mailslots
before, so I don't even know what the performance implications
are.

WTC


Re: non-blocking pipe on win32

Posted by Ben Laurie <be...@algroup.co.uk>.
Wan-Teh Chang wrote:
> 
> Dean Gaudet wrote:
> 
> > So is there any way that we'll be able to get timeouts on reads
> > from/writes to CGIs under WIN32?  That's my main concern.  If there is a
> > way, then I will add the unix code for it and leave the win32 code for
> > someone else.  If there isn't a way... I'll have to bang my head against
> > the wall or something.
> 
> How about "mail slots"?  It is message-based, one-way IPC.
> CreateMailslot() can specify a "read timeout" argument.
> 
> I guess you can ignore the message boundaries and use it
> as you would use a pipe.
> 
> I have never used this thing though.  Just found it in the Microsoft
> docs.

Nor me, but it does look like it might do the job. Just.

Cheers,

Ben.

-- 
Ben Laurie            |Phone: +44 (181) 735 0686|  Apache Group member
Freelance Consultant  |Fax:   +44 (181) 735 0689|http://www.apache.org
and Technical Director|Email: ben@algroup.co.uk |
A.L. Digital Ltd,     |Apache-SSL author    http://www.apache-ssl.org/
London, England.      |"Apache: TDG" http://www.ora.com/catalog/apache

Re: non-blocking pipe on win32

Posted by Wan-Teh Chang <wt...@netscape.com>.

Dean Gaudet wrote:

> So is there any way that we'll be able to get timeouts on reads
> from/writes to CGIs under WIN32?  That's my main concern.  If there is a
> way, then I will add the unix code for it and leave the win32 code for
> someone else.  If there isn't a way... I'll have to bang my head against
> the wall or something.

How about "mail slots"?  It is message-based, one-way IPC.
CreateMailslot() can specify a "read timeout" argument.

I guess you can ignore the message boundaries and use it
as you would use a pipe.

I have never used this thing though.  Just found it in the Microsoft
docs.

WTC


Re: non-blocking pipe on win32

Posted by Dean Gaudet <dg...@arctic.org>.
So is there any way that we'll be able to get timeouts on reads
from/writes to CGIs under WIN32?  That's my main concern.  If there is a
way, then I will add the unix code for it and leave the win32 code for
someone else.  If there isn't a way... I'll have to bang my head against
the wall or something.

Dean

On Mon, 11 May 1998, Ben Laurie wrote:

> Wan-Teh Chang wrote:
> > 
> > The basic, unnamed pipes on Win32 support blocking I/O only.
> > You can't make them non-blocking or do overlapped I/O (NT's
> > asynchronous I/O) on them.
> > 
> > Win32 also has named pipes, which I haven't played with.
> > You can do overlapped I/O on named pipes.  But similar
> > to unamed pipes, named pipes cannot be put into non-blocking
> > mode.
> 
> Named pipes don't work on Win95.
> 
> Cheers,
> 
> Ben.
> 
> -- 
> Ben Laurie            |Phone: +44 (181) 735 0686|  Apache Group member
> Freelance Consultant  |Fax:   +44 (181) 735 0689|http://www.apache.org
> and Technical Director|Email: ben@algroup.co.uk |
> A.L. Digital Ltd,     |Apache-SSL author    http://www.apache-ssl.org/
> London, England.      |"Apache: TDG" http://www.ora.com/catalog/apache
> 


Re: non-blocking pipe on win32

Posted by Ben Laurie <be...@algroup.co.uk>.
Wan-Teh Chang wrote:
> 
> The basic, unnamed pipes on Win32 support blocking I/O only.
> You can't make them non-blocking or do overlapped I/O (NT's
> asynchronous I/O) on them.
> 
> Win32 also has named pipes, which I haven't played with.
> You can do overlapped I/O on named pipes.  But similar
> to unamed pipes, named pipes cannot be put into non-blocking
> mode.

Named pipes don't work on Win95.

Cheers,

Ben.

-- 
Ben Laurie            |Phone: +44 (181) 735 0686|  Apache Group member
Freelance Consultant  |Fax:   +44 (181) 735 0689|http://www.apache.org
and Technical Director|Email: ben@algroup.co.uk |
A.L. Digital Ltd,     |Apache-SSL author    http://www.apache-ssl.org/
London, England.      |"Apache: TDG" http://www.ora.com/catalog/apache

Re: non-blocking pipe on win32

Posted by Wan-Teh Chang <wt...@netscape.com>.
The basic, unnamed pipes on Win32 support blocking I/O only.
You can't make them non-blocking or do overlapped I/O (NT's
asynchronous I/O) on them.

Win32 also has named pipes, which I haven't played with.
You can do overlapped I/O on named pipes.  But similar
to unamed pipes, named pipes cannot be put into non-blocking
mode.

Nonblocking i/o and select() are a BSD-socket compatilility
thing on Win32, so they are only applicable to sockets.

This means even if you use named pipes, they must be
handled separately from the sockets.

You can try using a loopback TCP socket to emulate a pipe.
But I suspect there will be some performance penalty.

Wan-Teh


Re: non-blocking pipe on win32

Posted by Dean Gaudet <dg...@arctic.org>.

On Sun, 10 May 1998, Rasmus Lerdorf wrote:

> > It's not possible to get a non-blocking pipe on win32, right?  I'm
> > inferring this from the NSPR docs, and from something I recall here... 
> > ISTR the unbuffered CGI stuff in 1.3 on NT doesn't work at all.  [why is
> > microsoft so dense?]
> > 
> > I'm trying to figure out how to do the non-blocking stuff for CGIs in
> > NSPR... looks like I'm going to have to use multiple threads and
> > synchronize between them.
> 
> A non-blocking pipe as in a socket?  

No... unless you can use a socket to talk between tasks.

Dean



Re: non-blocking pipe on win32

Posted by Rasmus Lerdorf <ra...@lerdorf.on.ca>.
> It's not possible to get a non-blocking pipe on win32, right?  I'm
> inferring this from the NSPR docs, and from something I recall here... 
> ISTR the unbuffered CGI stuff in 1.3 on NT doesn't work at all.  [why is
> microsoft so dense?]
> 
> I'm trying to figure out how to do the non-blocking stuff for CGIs in
> NSPR... looks like I'm going to have to use multiple threads and
> synchronize between them.

A non-blocking pipe as in a socket?  

#if WIN32|WINNT
        /* with ioctlsocket, a non-zero sets nonblocking, a zero sets blocking */
        flags=block;
        if(ioctlsocket(socketd,FIONBIO,&flags)==SOCKET_ERROR){
                php3_error(E_WARNING,"%s",WSAGetLastError());
                RETURN_FALSE;
        }else{
                RETURN_TRUE;
        }
#else

-Rasmus