tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cos...@apache.org
Subject cvs commit: jakarta-tomcat-connectors/jk/native2/server/apache13 jk_service_apache13.c mod_jk2.c
Date Thu, 16 May 2002 20:56:08 GMT
costin      02/05/16 13:56:08

  Modified:    jk/native2/server/apache13 jk_service_apache13.c mod_jk2.c
  Log:
  Filter debugging, fix head, add support for the shm.
  
  It should work now reasonably well.
  
  Revision  Changes    Path
  1.5       +75 -76    jakarta-tomcat-connectors/jk/native2/server/apache13/jk_service_apache13.c
  
  Index: jk_service_apache13.c
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-connectors/jk/native2/server/apache13/jk_service_apache13.c,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- jk_service_apache13.c	25 Apr 2002 19:25:10 -0000	1.4
  +++ jk_service_apache13.c	16 May 2002 20:56:08 -0000	1.5
  @@ -105,33 +105,36 @@
       headers=s->headers_out;
       numheaders = headers->size(env, headers);
       /* XXX As soon as we switch to jk_map_apache13, this will not be needed ! */
  -    env->l->jkLog(env, env->l, JK_LOG_INFO, 
  -                  "service.head() %d %d\n", s->status,
  -                  numheaders);
  +    if( s->uriEnv->mbean->debug > 0 ) 
  +        env->l->jkLog(env, env->l, JK_LOG_INFO, 
  +                      "service.head() %d %d\n", s->status,
  +                      numheaders);
       
       for(h = 0 ; h < numheaders; h++) {
           char *name=headers->nameAt( env, headers, h );
           char *val=headers->valueAt( env, headers, h );
   
  -        env->l->jkLog(env, env->l, JK_LOG_INFO, 
  -                      "service.head() %s: %s %d %d\n", name, val, h, headers->size(
env, headers ));
  +        if( s->uriEnv->mbean->debug > 0 ) 
  +            env->l->jkLog(env, env->l, JK_LOG_INFO, 
  +                          "service.head() %s: %s %d %d\n",
  +                          name, val, h, headers->size( env, headers ));
   
           /* the cmp can also be avoided in we do this earlier and use
              the header id */
  -        if(!strcasecmp(name, "Content-type")) {
  +        if( strcasecmp(name, "Content-type") == 0 ) {
               /* XXX should be done in handler ! */
               char *tmp = ap_pstrdup(r->pool, val);
               ap_content_type_tolower(tmp); 
               r->content_type = tmp;
               ap_table_set(r->headers_out, name, val);
  -        } else if(!strcasecmp(name, "Location")) {
  +        } else if(strcasecmp(name, "Location") == 0 ) {
               /* XXX setn */
               ap_table_set(r->headers_out, name, val);
  -        } else if(!strcasecmp(name, "Content-Length")) {
  +        } else if(strcasecmp(name, "Content-Length") == 0) {
               ap_table_set(r->headers_out, name, val );
  -        } else if(!strcasecmp(name, "Transfer-Encoding")) {
  +        } else if(strcasecmp(name, "Transfer-Encoding") == 0 ) {
               ap_table_set(r->headers_out,name, val);
  -        } else if(!strcasecmp(name, "Last-Modified")) {
  +        } else if(strcasecmp(name, "Last-Modified") == 0 ) {
               /*
                * If the script gave us a Last-Modified header, we can't just
                * pass it on blindly because of restrictions on future values.
  @@ -140,13 +143,12 @@
               ap_set_last_modified(r);
               ap_table_set(r->headers_out, name, val);
           } else {                
  -            /* ap_table_add(r->headers_out, name, val); */
  -               ap_table_set(r->headers_out, name, val);
  +            ap_table_add(r->headers_out, name, val);
  +            /* ap_table_set(r->headers_out, name, val); */
           }
       }
   
  -    /* this NOP function was removed in apache 2.0 alpha14 */
  -    /* ap_send_http_header(r); */
  +    ap_send_http_header(r);
       s->response_started = JK_TRUE;
       
       return JK_OK;
  @@ -165,25 +167,26 @@
                                                 void *b, unsigned len,
                                                 unsigned *actually_read)
   {
  -    if(s && s->ws_private && b && actually_read) {
  -        if(!s->read_body_started) {
  -           if(ap_should_client_block(s->ws_private)) {
  -                s->read_body_started = JK_TRUE;
  -            }
  -        }
  +    long rv;
   
  -        if(s->read_body_started) {
  -            long rv;
  -            if ((rv = ap_get_client_block(s->ws_private, b, len)) < 0) {
  -                *actually_read = 0;
  -            } else {
  -                *actually_read = (unsigned) rv;
  -            }
  -            return JK_OK;
  +    if(s==NULL  || s->ws_private==NULL  || b==NULL || actually_read==NULL ) {
  +        return JK_ERR;
  +    }
  +
  +    if(!s->read_body_started) {
  +        if(ap_should_client_block(s->ws_private)) {
  +            s->read_body_started = JK_TRUE;
           }
       }
  -    return JK_ERR;
  -}
  +    rv = ap_get_client_block(s->ws_private, b, len);
  +    
  +    if( rv < 0) {
  +        *actually_read = 0;
  +    } else {
  +        *actually_read = (unsigned) rv;
  +    }
  +    return JK_OK;
  +} 
   
   /*
    * Write a chunk of response data back to the browser.  If the headers
  @@ -196,67 +199,61 @@
    * the jk_ws_service class.  Think of the *s param as a "this" or "self"
    * pointer.
    */
  +
   /* Works with 4096, fails with 8192 */
   #ifndef CHUNK_SIZE
   #define CHUNK_SIZE 4096
   #endif
   
   static int JK_METHOD jk2_service_apache13_write(jk_env_t *env, jk_ws_service_t *s,
  -                                               const void *b, int len)
  +                                                const void *b, int len)
   {
  -    if(s && s->ws_private && b) {
  -        if(len) {
  -            /* BUFF *bf = p->r->connection->client; */
  -            /* size_t w = (size_t)l; */
  -            size_t r = 0;
  -            long ll=len;
  -            char *bb=(char *)b;
  -            request_rec *rr=s->ws_private;
  +    int rc;
  +    
  +    if(s==NULL || s->ws_private == NULL || b==NULL )
  +        return JK_ERR;
  +    
  +    {
  +        /* BUFF *bf = p->r->connection->client; */
  +        /* size_t w = (size_t)l; */
  +        size_t rd = 0;
  +        long ll=len;
  +        char *bb=(char *)b;
  +        request_rec *rr=s->ws_private;
               
  -            if(!s->response_started) {
  +        if(!s->response_started) {
  +            if( s->uriEnv->mbean->debug > 0 ) 
                   env->l->jkLog(env, env->l, JK_LOG_INFO, 
                                 "service.write() default head\n");
  -                if(!s->head(env, s)) {
  -                    return JK_ERR;
  -                }
  -                {
  -                    array_header *t = ap_table_elts(rr->headers_out);
  -                    if(t && t->nelts) {
  -                        int i;
  -                        
  -                        table_entry *elts = (table_entry *)t->elts;
  -                        
  -                        for(i = 0 ; i < t->nelts ; i++) {
  -                            env->l->jkLog(env, env->l, JK_LOG_INFO, "OutHeaders
%s: %s\n",
  -                                          elts[i].key, elts[i].val);
  -                        }
  -                    }
  -                }
  +
  +            rc=s->head(env, s);
  +            if( rc != JK_OK ) {
  +                return rc;
               }
  -            
  -            /* Debug - try to get around rwrite */
  -            while( ll > 0 ) {
  -                unsigned long toSend=(ll>CHUNK_SIZE) ? CHUNK_SIZE : ll;
  -                r = ap_rwrite((const char *)bb, toSend, s->ws_private );
  +        }
  +        
  +        /* Debug - try to get around rwrite */
  +        while( ll > 0 ) {
  +            unsigned long toSend=(ll>CHUNK_SIZE) ? CHUNK_SIZE : ll;
  +            rd = ap_rwrite((const char *)bb, toSend, s->ws_private );
  +            if( s->uriEnv->mbean->debug > 0 ) 
                   env->l->jkLog(env, env->l, JK_LOG_INFO, 
  -                              "service.write()  %ld (%ld) out of %ld \n",toSend, r, ll
);
  -                ll-=CHUNK_SIZE;
  -                bb+=CHUNK_SIZE;
  -                
  -                if(toSend != r) { 
  -                    return JK_ERR; 
  -                } 
  +                              "service.write()  %ld (%ld) out of %ld \n",toSend, rd, ll
);
  +            ll-=CHUNK_SIZE;
  +            bb+=CHUNK_SIZE;
  +            
  +            if(toSend != rd) { 
  +                return JK_ERR; 
  +            } 
                   
  -            }
  -
  -            /*
  -             * To allow server push. After writing full buffers
  -             */
  -            ap_bflush(s->ws_private);
           }
  -        return JK_OK;
  +
  +        /*
  +         * To allow server push. After writing full buffers
  +         */
  +        ap_bflush(s->ws_private);
       }
  -    return JK_ERR;
  +    return JK_OK;
   }
   
   /* ========================================================================= */
  @@ -298,6 +295,8 @@
       s->response_started = JK_FALSE;
       s->read_body_started = JK_FALSE;
       s->workerEnv=workerEnv;
  +
  +    workerEnv->childId = r->connection->child_num;
   
       s->jvm_route        = NULL;    /* Used for sticky session routing */
   
  
  
  
  1.13      +13 -11    jakarta-tomcat-connectors/jk/native2/server/apache13/mod_jk2.c
  
  Index: mod_jk2.c
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-connectors/jk/native2/server/apache13/mod_jk2.c,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- mod_jk2.c	3 May 2002 18:44:03 -0000	1.12
  +++ mod_jk2.c	16 May 2002 20:56:08 -0000	1.13
  @@ -59,7 +59,7 @@
    * Description: Apache 1.3 plugin for Jakarta/Tomcat                         *
    * Author:      Gal Shachor <shachor@il.ibm.com>                           *
    *                 Henri Gomez <hgomez@slib.fr>                               *
  - * Version:     $Revision: 1.12 $                                           *
  + * Version:     $Revision: 1.13 $                                           *
    ***************************************************************************/
   
   /*
  @@ -122,7 +122,7 @@
       jk_env_t *env=workerEnv->globalEnv;
       int rc;
       
  -    rc=workerEnv->config->setPropertyString( env, workerEnv->config, name, value
);
  +    rc=workerEnv->config->setPropertyString( env, workerEnv->config, (char *)name,
value );
       if( rc!=JK_OK ) {
           fprintf( stderr, "mod_jk2: Unrecognized option %s %s\n", name, value);
       }
  @@ -136,10 +136,9 @@
   static int jk2_create_workerEnv(ap_pool *p, const server_rec *s)
   {
       jk_env_t *env;
  -    jk_logger_t *l;
       jk_pool_t *globalPool;
       jk_bean_t *jkb;
  -    
  +
       /** First create a pool. We use the default ( jk ) pool impl,
        *  other choices are apr or native.
        */
  @@ -162,7 +161,7 @@
           fprintf(stderr, "Error creating logger ");
           return JK_ERR;
       }
  -    env->l=l;
  +    env->l=jkb->object;
       env->alias( env, "logger.file:", "logger");
       
       /* Create the workerEnv
  @@ -175,7 +174,7 @@
       workerEnv= jkb->object;
       env->alias( env, "workerEnv:", "workerEnv");
   
  -    if( workerEnv==NULL || l== NULL  ) {
  +    if( workerEnv==NULL || env->l == NULL  ) {
           fprintf( stderr, "Error initializing jk, NULL objects \n");
           return JK_ERR;
       }
  @@ -255,7 +254,7 @@
   /** Standard apache callback, initialize jk. This is called after all
       the settings took place.
    */
  -static void jk2_init(server_rec *s, ap_pool *pconf)
  +static int jk2_init(server_rec *s, ap_pool *pconf)
   {
       jk_uriEnv_t *serverEnv=(jk_uriEnv_t *)
           ap_get_module_config(s->module_config, &jk2_module);
  @@ -277,6 +276,8 @@
           env->l->jkLog(env, env->l, JK_LOG_INFO,
                         "mod_jk.post_config() init worker env\n");
   
  +        workerEnv->parentInit(env, workerEnv );
  +
           workerEnv->init(env, workerEnv );
           
           workerEnv->server_name   = (char *)ap_get_server_version();
  @@ -362,19 +363,20 @@
           rPool= worker->rPoolCache->get( env, worker->rPoolCache );
   
           if( rPool == NULL ) {
  -            rPool=worker->pool->create( env, worker->pool, HUGE_POOL_SIZE );
  +            rPool=worker->mbean->pool->create( env, worker->mbean->pool,
HUGE_POOL_SIZE );
               env->l->jkLog(env, env->l, JK_LOG_INFO,
                             "mod_jk.handler(): new rpool\n");
           }
   
           jk2_service_apache13_init(env, s);
           s->pool = rPool;
  -        s->uriEnv = uriEnv;
  -        s->is_recoverable_error = JK_FALSE;
           s->init( env, s, worker, r );
           
  +        s->is_recoverable_error = JK_FALSE;
  +        s->uriEnv = uriEnv;
  +
           env->l->jkLog(env, env->l, JK_LOG_INFO, 
  -                      "modjk.handler() Calling %s\n", worker->mbean->name); 
  +                      "modjk.handler() Calling %s %p\n", worker->mbean->name, uriEnv);

   
           rc = worker->service(env, worker, s);
           
  
  
  

--
To unsubscribe, e-mail:   <mailto:tomcat-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:tomcat-dev-help@jakarta.apache.org>


Mime
View raw message