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/include jk_msg.h
Date Thu, 02 May 2002 03:13:05 GMT
costin      02/05/01 20:13:05

  Modified:    jk/native2/common jk_channel_jni.c jk_msg_ajp.c jk_shm.c
                        jk_worker_status.c
               jk/native2/include jk_msg.h
  Log:
  Added some more debugging code the shm ( now it can dump the content
  in a file and display some more or less usefull information ).
  
  Started to add code to serialize/deserialize a map ( it's very
  common ).
  
  Few more checks, remove few verbose messages.
  
  Revision  Changes    Path
  1.13      +4 -1      jakarta-tomcat-connectors/jk/native2/common/jk_channel_jni.c
  
  Index: jk_channel_jni.c
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-connectors/jk/native2/common/jk_channel_jni.c,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- jk_channel_jni.c	1 May 2002 23:10:17 -0000	1.12
  +++ jk_channel_jni.c	2 May 2002 03:13:05 -0000	1.13
  @@ -466,7 +466,10 @@
   
       /* XXX Don't detach if worker is reused per thread */
       endpoint->endpoint_private=NULL;
  -    we->vm->detach( env, we->vm ); 
  +    if( we==NULL || we->vm==NULL ) {
  +        return JK_OK;
  +    }
  +    /* we->vm->detach( env, we->vm );  */
       
       env->l->jkLog(env, env->l, JK_LOG_INFO, 
                     "channelJni.afterRequest() ok\n");
  
  
  
  1.8       +67 -21    jakarta-tomcat-connectors/jk/native2/common/jk_msg_ajp.c
  
  Index: jk_msg_ajp.c
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-connectors/jk/native2/common/jk_msg_ajp.c,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- jk_msg_ajp.c	25 Apr 2002 19:17:22 -0000	1.7
  +++ jk_msg_ajp.c	2 May 2002 03:13:05 -0000	1.8
  @@ -60,7 +60,7 @@
    * Author:      Costin Manolache
    * Author:      Gal Shachor <shachor@il.ibm.com>                           *
    * Author:      Henri Gomez <hgomez@slib.fr>                               *
  - * Version:     $Revision: 1.7 $                                           *
  + * Version:     $Revision: 1.8 $                                           *
    ***************************************************************************/
   
   #include "jk_pool.h"
  @@ -83,7 +83,7 @@
       int i=0;
       env->l->jkLog( env, env->l, JK_LOG_INFO,
                      "%s pos=%d len=%d max=%d \n",
  -                err, _this->pos, _this->len, _this->maxlen );
  +                   err, _this->pos, _this->len, _this->maxlen );
       
       env->l->jkLog( env, env->l, JK_LOG_INFO,
                   "%2x %2x %2x %2x:%2x %2x %2x %2x:%2x %2x %2x %2x:%2x %2x %2x %2x \n", 
  @@ -169,6 +169,21 @@
       return JK_OK;
   }
   
  +static int jk2_msg_ajp_appendMap(jk_env_t *env, jk_msg_t *msg, 
  +                                 jk_map_t *map) 
  +{
  +
  +    return JK_OK;
  +}
  +
  +static int jk2_msg_ajp_getMap(jk_env_t *env, jk_msg_t *msg, 
  +                              jk_map_t *map) 
  +{
  +
  +    return JK_OK;
  +}
  +
  +
   static int jk2_msg_ajp_appendString(jk_env_t *env, jk_msg_t *msg, 
                                       const char *param) 
   {
  @@ -413,25 +428,8 @@
       return len;
   }
   
  -
  -jk_msg_t *jk2_msg_ajp_create(jk_env_t *env, jk_pool_t *pool, int buffSize) 
  +static void jk2_msg_ajp_init(jk_env_t *env, jk_msg_t *msg, int buffSize) 
   {
  -    jk_msg_t *msg = 
  -        (jk_msg_t *)pool->calloc(env, pool, sizeof(jk_msg_t));
  -
  -    if( buffSize==0 )
  -        buffSize=DEF_BUFFER_SZ;
  -    if(!msg) {
  -        return NULL;
  -    }
  -    msg->pool = pool;
  -
  -    msg->buf= (unsigned char *)msg->pool->alloc(env, msg->pool, buffSize);
  -    
  -    if(msg->buf==NULL) {
  -        return NULL;
  -    }
  -    
       msg->maxlen=buffSize;
       msg->len=0;
   
  @@ -446,6 +444,7 @@
       msg->appendInt=jk2_msg_ajp_appendInt;
       msg->appendLong=jk2_msg_ajp_appendLong;
       msg->appendString=jk2_msg_ajp_appendString;
  +    msg->appendMap=jk2_msg_ajp_appendMap;
   
       msg->appendFromServer=jk2_msg_ajp_appendFromServer;
   
  @@ -454,10 +453,57 @@
       msg->peekInt=jk2_msg_ajp_peekInt;
       msg->getLong=jk2_msg_ajp_getLong;
       msg->getString=jk2_msg_ajp_getString;
  +    msg->getMap=jk2_msg_ajp_getMap;
       msg->getBytes=jk2_msg_ajp_getBytes;
   
       msg->checkHeader=jk2_msg_ajp_checkHeader;
  -                       
  +}
  +
  +
  +jk_msg_t *jk2_msg_ajp_create2(jk_env_t *env, jk_pool_t *pool, char *buf, int buffSize)
  +{
  +    jk_msg_t *msg = 
  +        (jk_msg_t *)pool->calloc(env, pool, sizeof(jk_msg_t));
  +
  +    if( buffSize==0 )
  +        buffSize=DEF_BUFFER_SZ;
  +    if(!msg) {
  +        return NULL;
  +    }
  +    msg->pool = pool;
  +
  +    msg->buf= buf;
  +    
  +    if(msg->buf==NULL) {
  +        return NULL;
  +    }
  +
  +    jk2_msg_ajp_init( env, msg, buffSize );
  +
  +    return msg;
  +}
  +
  +
  +jk_msg_t *jk2_msg_ajp_create(jk_env_t *env, jk_pool_t *pool, int buffSize) 
  +{
  +    jk_msg_t *msg = 
  +        (jk_msg_t *)pool->calloc(env, pool, sizeof(jk_msg_t));
  +
  +    if( buffSize==0 )
  +        buffSize=DEF_BUFFER_SZ;
  +    if(!msg) {
  +        return NULL;
  +    }
  +    msg->pool = pool;
  +
  +    msg->buf= (unsigned char *)msg->pool->alloc(env, msg->pool, buffSize);
  +    
  +    if(msg->buf==NULL) {
  +        return NULL;
  +    }
  +
  +    jk2_msg_ajp_init( env, msg, buffSize );
  +
       return msg;
   }
   
  
  
  
  1.10      +112 -35   jakarta-tomcat-connectors/jk/native2/common/jk_shm.c
  
  Index: jk_shm.c
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-connectors/jk/native2/common/jk_shm.c,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- jk_shm.c	1 May 2002 23:10:17 -0000	1.9
  +++ jk_shm.c	2 May 2002 03:13:05 -0000	1.10
  @@ -99,6 +99,9 @@
   #define SHM_WRITE_SLOT 2
   #define SHM_ATTACH 3
   #define SHM_DETACH 4
  +#define SHM_RESET 5
  +#define SHM_DUMP 6
  +#define SHM_DESTROY 7
   
   
   static int jk2_shm_destroy(jk_env_t *env, jk_shm_t *shm)
  @@ -120,6 +123,65 @@
       return apr_shm_attach((apr_shm_t **)&shm->privateData, shm->fname, globalShmPool
);
   }
   
  +/** Reset the scoreboard, in case it gets corrupted.
  + *  Will remove all slots and set the head in the original state.
  + */
  +static int jk2_shm_reset(jk_env_t *env, jk_shm_t *shm)
  +{
  +    if( shm->head == NULL ) {
  +        return JK_ERR;
  +    }
  +    memset(shm->image, 0, shm->size);
  +
  +    shm->head->slotSize = shm->slotSize;
  +    shm->head->slotMaxCount = shm->slotMaxCount;
  +    shm->head->lastSlot = 1;
  +    
  +    env->l->jkLog(env, env->l, JK_LOG_INFO, 
  +                  "shm.init() Initalized %s %p\n",
  +                  shm->fname, shm->image);
  +
  +    return JK_OK;
  +}
  +
  +static int jk2_shm_dump(jk_env_t *env, jk_shm_t *shm, char *name)
  +{
  +    FILE *f;
  +    int i;
  +
  +    env->l->jkLog(env, env->l, JK_LOG_INFO, "shm.dump(): Struct Size=%d slotSize=%d
slotCnt=%d head=%p\n",
  +                  shm->size, shm->slotSize, shm->slotMaxCount, shm->head );
  +
  +    if( shm->head==NULL ) return JK_ERR;
  +
  +    env->l->jkLog(env, env->l, JK_LOG_INFO, "shm.dump(): shmem  slotSize=%d slotCnt=%d
lastSlot=%d ver=%d\n",
  +                  shm->head->slotSize, shm->head->slotMaxCount, shm->head->lastSlot,
shm->head->lbVer );
  +
  +    for( i=1; i< shm->head->lastSlot; i++ ) {
  +        jk_shm_slot_t *slot=shm->getSlot( env, shm, i );
  +        jk_msg_t *msg;
  +
  +        if( slot==NULL ) continue;
  +        msg=jk2_msg_ajp_create2( env, env->tmpPool, slot->data, slot->size);
  +
  +        env->l->jkLog(env, env->l, JK_LOG_INFO, "shm.dump(): slot %d ver=%d size=%d
name=%s\n",
  +                      i, slot->ver, slot->size, slot->name );
  +
  +        msg->dump( env, msg, "Slot content ");
  +    }
  +    
  +    if( name==NULL ) return JK_ERR;
  +    
  +    f=fopen(name, "a+");
  +    fwrite( shm->head, 1, shm->size, f ); 
  +    fclose( f );
  +
  +    env->l->jkLog(env, env->l, JK_LOG_INFO, "shm.dump(): Dumped %d in %s\n",
  +                  shm->size, name);
  +    
  +    return JK_OK;
  +}
  +
   
   /* Create or reinit an existing scoreboard. The MPM can control whether
    * the scoreboard is shared across multiple processes or not
  @@ -230,16 +292,8 @@
                         shm->fname);
           return JK_ERR;
       }
  -    
  -    memset(shm->image, 0, shm->size);
   
  -    shm->head->slotSize = shm->slotSize;
  -    shm->head->slotMaxCount = shm->slotMaxCount;
  -    shm->head->lastSlot = 1;
  -    
  -    env->l->jkLog(env, env->l, JK_LOG_INFO, 
  -                  "shm.init() Initalized %s %p\n",
  -                  shm->fname, shm->image);
  +    jk2_shm_reset( env, shm );
   
       return JK_OK;
   }
  @@ -307,8 +361,41 @@
   
   }
   
  -/* ==================== Dispatch messages from java ==================== */
  +/** Copy a chunk of data into a named slot
  + */
  +static int jk2_shm_writeSlot( jk_env_t *env, jk_shm_t *shm,
  +                              char *instanceName, char *buf, int len )
  +{
  +    jk_shm_slot_t *slot;
  +    
  +    env->l->jkLog(env, env->l, JK_LOG_INFO, 
  +                  "shm.writeSlot() %s %d\n", instanceName, len );
  +    if( len > shm->slotSize ) {
  +        env->l->jkLog(env, env->l, JK_LOG_ERROR, 
  +                      "shm.writeSlot() Packet too large %d %d\n",
  +                      shm->slotSize, len );
  +        return JK_ERR;
  +    }
  +    if( shm->head == NULL ) {
  +        env->l->jkLog(env, env->l, JK_LOG_ERROR, 
  +                      "shm.writeSlot() No head - shm was not initalized\n");
  +        return JK_ERR;
  +    }
  +    slot=shm->createSlot( env, shm, instanceName, 0 );
  +    
  +    /*  Copy the body in the slot */
  +    memcpy( slot->data, buf, len );
  +    slot->size=len;
  +    slot->ver++;
  +    /* Update the head lb version number - that would triger
  +       reconf on the next request */
  +    shm->head->lbVer++;
  +
  +    return JK_OK;
  +}
   
  +/* ==================== Dispatch messages from java ==================== */
  +    
   /** Called by java. Will call the right shm method.
    */
   static int jk2_shm_dispatch(jk_env_t *env, void *target, jk_endpoint_t *ep, jk_msg_t *msg)
  @@ -343,31 +430,20 @@
       }
       case SHM_WRITE_SLOT: {
           char *instanceName=msg->getString( env, msg );
  -        jk_shm_slot_t *slot;
  -        
  -        env->l->jkLog(env, env->l, JK_LOG_INFO, 
  -                      "shm.writeSlot() %s %d\n",
  -                      instanceName, msg->len );
  -        if( msg->len > shm->slotSize ) {
  -            env->l->jkLog(env, env->l, JK_LOG_ERROR, 
  -                          "shm.writeSlot() Packet too large %d %d\n",
  -                          shm->slotSize, msg->len );
  -            return JK_ERR;
  -        }
  -        if( shm->head == NULL ) {
  -            env->l->jkLog(env, env->l, JK_LOG_ERROR, 
  -                          "shm.writeSlot() No head - shm was not initalized\n");
  -            return JK_ERR;
  -        }
  -        slot=shm->createSlot( env, shm, instanceName, 0 );
  -        
  -        /*  Copy the body in the slot */
  -        memcpy( slot->data, msg->buf, msg->len );
  -        slot->size=msg->len;
  -        slot->ver++;
  -        /* Update the head lb version number - that would triger
  -           reconf on the next request */
  -        shm->head->lbVer++;
  +        char *buf=msg->buf;
  +        int len=msg->len;
  +
  +        return jk2_shm_writeSlot( env, shm, instanceName, buf, len );
  +    }
  +    case SHM_RESET: {
  +        jk2_shm_reset( env, shm );
  +
  +        return JK_OK;
  +    }
  +    case SHM_DUMP: {
  +        char *name=msg->getString( env, msg );
  +
  +        jk2_shm_dump( env, shm, name );
           return JK_OK;
       }
       }/* switch */
  @@ -393,6 +469,7 @@
       if( shm == NULL )
           return JK_ERR;
   
  +    shm->pool=pool;
       shm->privateData=NULL;
   
       shm->slotSize=DEFAULT_SLOT_SIZE;
  
  
  
  1.15      +0 -2      jakarta-tomcat-connectors/jk/native2/common/jk_worker_status.c
  
  Index: jk_worker_status.c
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-connectors/jk/native2/common/jk_worker_status.c,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- jk_worker_status.c	25 Apr 2002 19:22:19 -0000	1.14
  +++ jk_worker_status.c	2 May 2002 03:13:05 -0000	1.15
  @@ -191,7 +191,6 @@
       s->msg="OK";
       s->headers_out->put(env, s->headers_out,
                           "Content-Type", "text/html", NULL);
  -    fprintf(stderr, "Writing head \n");
       s->head(env, s );
   
       /** Process the query string.
  @@ -206,7 +205,6 @@
       jk2_worker_status_displayRuntimeProperties(env, s, s->workerEnv );
       
       s->afterRequest( env, s);
  -    fprintf(stderr, "After req %s \n", s);
       return JK_OK;
   }
   
  
  
  
  1.6       +12 -0     jakarta-tomcat-connectors/jk/native2/include/jk_msg.h
  
  Index: jk_msg.h
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-connectors/jk/native2/include/jk_msg.h,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- jk_msg.h	21 Feb 2002 11:15:51 -0000	1.5
  +++ jk_msg.h	2 May 2002 03:13:05 -0000	1.6
  @@ -145,6 +145,9 @@
       int (*appendString)(struct jk_env *env, struct jk_msg *_this, 
                            const char *param);
   
  +    int (*appendMap)(struct jk_env *env, struct jk_msg *_this, 
  +                     struct jk_map map);
  +
       unsigned char (*getByte)(struct jk_env *env, struct jk_msg *_this);
   
       unsigned short (*getInt)(struct jk_env *env, struct jk_msg *_this);
  @@ -169,6 +172,12 @@
                                  struct jk_msg *_this,
                                  int *len);
   
  +    /** Read a map structure from the message. The map is encoded
  +        as an int count and then the NV pairs
  +    */
  +    int (*getMap)(struct jk_env *env, struct jk_msg *_this, 
  +                  struct jk_map map);
  +
       /** 
        * Special method. Will read data from the server and add them as
        * bytes. It is equivalent with jk2_requtil_readFully() in a buffer
  @@ -198,6 +207,9 @@
   /* Temp */
   jk_msg_t *jk2_msg_ajp_create(struct jk_env *env, struct jk_pool *p,
                               int buffSize);
  +    
  +jk_msg_t *jk2_msg_ajp_create2(struct jk_env *env, struct jk_pool *pool,
  +                              char *buf, int buffSize);
       
   #ifdef __cplusplus
   }
  
  
  

--
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