httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dean Gaudet <dgau...@arctic.org>
Subject Re: IOL and send_fb
Date Mon, 16 Aug 1999 19:52:40 GMT


On Mon, 16 Aug 1999, Ben Laurie wrote:

> Errr ... why? AFAICS the loop you outline below has an ap_bread that
> never gets called. It sets the timeout to zero and then back to the
> timeout value, and reads from the CGI, then repeats.
> 

yeah the loop has bugs.

> Why not just set the timeout value once and be done with it?

because you want a non-blocking read, which you need to be 0.  then when
you get an EAGAIN you want to bflush the client, and then you want
to block until the CGI read completes -- and to block you want to set
the timeout.

try this:

    timeout = 0;
    ap_bsetopt(fb, BO_TIMEOUT, &timeout);
    for (;;) {
	rc = ap_bread(fb, buf, sizeof(buf));
	if (rc <= 0) {
	    if (rc == 0) { 
		done, flush, return;
	    }
	    if (rc == -1 && errno != EAGAIN) {
		error handling, return;
	    }
	    /* next read will block, so flush the client now */
	    rc = ap_bflush(conn->client);
	    /* deal with rc errors here */
            timeout = value of Timeout for this request;
            ap_bsetopt(fb, BO_TIMEOUT, &timeout);
	    rc = ap_bread(fb, buf, sizeof(buf));
	    if (rc <= 0) {
		if (rc == 0) {
		    done, flush, return;
		}
		error handling, return;
	    }
	    timeout = 0;
	    ap_bsetopt(fb, BO_TIMEOUT, &timeout);
	}
	loop writing rc bytes from buf;
    }
	    
Dean


Mime
View raw message