You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by "Marc A. Saegesser" <sa...@platinum.com> on 1999/02/18 22:09:21 UTC

Response buffering on Win32

A couple questions regarding response buffering in Apache on Win32.

The basic logic of ap_send_fb_length() is as follows:

   while not finished
      Read from the input buffer but don't block
      If the read would have blocked
         Flush the output buffer
         Wait for data to arrive on the input buffer (select()).
      else
         Add the incoming data to the output buffer
      If the output buffer is full
         Flush the output buffer

In the case of CGI, Apache creates a set of anonymous pipes to communicate
with the child process.  Win32 stupidly doesn't support any way of
performing non-blocking I/O on anonymous pipes so the above algorithm ends
up buffering all the CGI output.

The only solution I see is to remove the use of anonymous pipes and replace
them with sockets or named pipes.  (Unfortunately, named pipe servers don't
work on Win95).  This is a non-trivial change.  What is the current
thinking within the Apache Group about this?  Is there a plan to implement
a fix for this?  If not I guess I'll have to take a crack at it myself
because I need to support a CGI application which generates a continuous
stream of data on Win32 platforms (I don't actually *want* to support
Win32, but...).

The other problem is related but has to do with the output from
mod_jserv.c.  In this case the connection between Apache and the Apache
JServ virtual machine is via a socket.  In the Win32 version the
buff_read() function calls recvwithtimeout() to read from B_SOCKET buffers.
 But recvwithtimeout() will block for the number of seconds returned by
ap_check_alarm() if there is no data to read.  Why?  This is one case where
the ap_send_fb_length() algorithm should be able to work on Win32 but the
blocking recvwithtimeout() call prevents it.  Again, why?

Marc Saegesser
--
The world has arrived at an age of cheap complex devices of great
reliability; and something is bound to come of it.
   Vannevar Bush, 1945


Re: Response buffering on Win32

Posted by "Marc A. Saegesser" <sa...@platinum.com>.
After spending more time in the source code I've got a better understanding
of the problem and I've also convinced myself that there really isn't any
way of shoe-horning the stupid Win32 I/O mechanism into UNIX style I/O used
in Apache.  The Win32 I/O subsystem is simply to limited.

The only alternative I've found so far is to make the client connection
unbuffered by calling

	ap_bsetflag(r->connection->client, B_WR, 0); 

I've done this in mod_cgi.c and also in the Apache JServ module and I am
now able to get a continuous data stream from my CGIs and servlets.

This isn't a great solution, but if it is only done for Win32 platforms
maybe its tolerable.

Comments?


Marc Saegesser
--
The world has arrived at an age of cheap complex devices of great
reliability; and something is bound to come of it.
   Vannevar Bush, 1945