You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by GOMEZ Henri <hg...@slib.fr> on 2001/09/15 00:50:27 UTC

[J-T-C] Apache 2.0 code review required

Hi to all,

I've just commited updated code for Apache 1.3/2.0
 
I will need a serious code review on Apache 2.0 part
and particulary the ws_read() which was grabbed from
1.3 and works (at least on Apache 2.0.24) but may 
be optimized...

===>

static int JK_METHOD ws_read(jk_ws_service_t *s,
                             void *b,
                             unsigned len,
                             unsigned *actually_read)
{
    if(s && s->ws_private && b && actually_read) {
        apache_private_data_t *p = s->ws_private;
        if(!p->read_body_started) {
           if(ap_should_client_block(p->r)) {
                p->read_body_started = JK_TRUE;
            }
        }

        if(p->read_body_started) {
            long rv;
            if ((rv = ap_get_client_block(p->r, b, len)) < 0) {
                *actually_read = 0;
            } else {
                *actually_read = (unsigned) rv;
            }
            return JK_TRUE;
        }
    }
    return JK_FALSE;
}

also is jk_handler we now use :

    /* Set up r->read_chunked flags for chunked encoding, if present */
    if(rc = ap_setup_client_block(r, REQUEST_CHUNKED_DECHUNK)) {
    return rc;
    }

ws_write() could need also a serious cleanup and see if the 
CHUNK_SIZE of 4k is still valid.

/* Works with 4096, fails with 8192 */
#define CHUNK_SIZE 4096

static int JK_METHOD ws_write(jk_ws_service_t *s,
                              const void *b,
                              unsigned l)
{
    if(s && s->ws_private && b) {
        apache_private_data_t *p = s->ws_private;

        if(l) {
            /* BUFF *bf = p->r->connection->client; */
            size_t w = (size_t)l;
            size_t r = 0;
            long ll=l;
            char *bb=(char *)b;
            
            if(!p->response_started) {
                if(!s->start_response(s, 200, NULL, NULL, NULL, 0)) {
                    return JK_FALSE;
                }
            }
            
            /* Debug - try to get around rwrite */
            while( ll > 0 ) {
                long toSend=(ll>CHUNK_SIZE) ? CHUNK_SIZE : ll;
                r = ap_rwrite((const char *)bb, toSend, p->r );
                /* DEBUG */
#ifdef JK_DEBUG
                ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, 
                             NULL, "mod_jk: writing %ld (%ld) out of %ld
\n",
                             toSend, r, ll );
#endif
                ll-=CHUNK_SIZE;
                bb+=CHUNK_SIZE;
                
                if(toSend != r) { 
                    return JK_FALSE; 
                } 
                
                /*
                 * To allow server push.
                 */
                if(ap_rflush(p->r) != APR_SUCCESS) {
                    ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO,
0, 
                                 NULL, "mod_jk: Error flushing \n"  );
                    return JK_FALSE;
                }
            }
        }
        
        return JK_TRUE;
    }
    return JK_FALSE;
}

I'm sure that our residents AP2.0 hackers, Ryan and JF, will
handle the task brillament :)

-
Henri Gomez                 ___[_]____
EMAIL : hgomez@slib.fr        (. .)                     
PGP KEY : 697ECEDD    ...oOOo..(_)..oOOo...
PGP Fingerprint : 9DF8 1EA8 ED53 2F39 DC9B 904A 364F 80E6 

Re: [J-T-C] Apache 2.0 code review required

Posted by cm...@yahoo.com.
On Fri, 14 Sep 2001, Justin Erenkrantz wrote:

> Since you have a "common" infrastructure via callbacks, I don't think
> you can take advantage of a lot of the new features in Apache 2.0.
> Oh, well.  -- justin

Well, we should be able to. We can just add more callbacks - and make sure
the code that is using them checks if the callback is implemented and
degrades gracefully.

I don't think keeping everything as dumb as the dumbest server is a good
idea - but the big problem is making sure those features don't interfere
too much with the servlet spec ( see the mod_rewrite discussion ).



Costin


Re: [J-T-C] Apache 2.0 code review required

Posted by Justin Erenkrantz <je...@ebuilt.com>.
On Sat, Sep 15, 2001 at 12:50:27AM +0200, GOMEZ Henri wrote:
> Hi to all,
> 
> I've just commited updated code for Apache 1.3/2.0
>  
> I will need a serious code review on Apache 2.0 part
> and particulary the ws_read() which was grabbed from
> 1.3 and works (at least on Apache 2.0.24) but may 
> be optimized...
<snip, snip>
> ws_write() could need also a serious cleanup and see if the 
> CHUNK_SIZE of 4k is still valid.
> 
> /* Works with 4096, fails with 8192 */
> #define CHUNK_SIZE 4096

Should be no need for this chunking.  Just pass it all to 
ap_rwrite.  If that doesn't work, then we have problem on our end
that we need to fix.

Since you have a "common" infrastructure via callbacks, I don't think
you can take advantage of a lot of the new features in Apache 2.0.
Oh, well.  -- justin