cvs commit: jakarta-tomcat-connectors/jk/native2/common jk_channel_jni.c

2003-01-23 Thread mturk
mturk   2003/01/23 04:13:03

  Modified:jk/native2/common jk_channel_jni.c
  Log:
  Use the macro instead of strdup. We don't need to dupe the
  strings on non EBCID machines.
  
  Revision  ChangesPath
  1.39  +13 -14jakarta-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.38
  retrieving revision 1.39
  diff -u -r1.38 -r1.39
  --- jk_channel_jni.c  21 Nov 2002 09:03:17 -  1.38
  +++ jk_channel_jni.c  23 Jan 2003 12:13:03 -  1.39
  @@ -112,16 +112,15 @@
   /*
  Duplicate string and convert it to ASCII on EBDIC based systems
  Needed for at least AS/400 and BS2000 but what about other EBDIC systems ?
  +   Implement as macro cause:   
  +   we don't need to duplicate the strings if they are const on non EBDIS systems 
   */
  -static void *strdup_ascii(jk_env_t *env, 
  -  char *s)
  -{
  +
   #if defined(AS400) || defined(_OSD_POSIX)
  - return (env-tmpPool-pstrdup2ascii(env, env-tmpPool, s));
  +#define SSTRDUP_ASCII(e, s) ((e)-tmpPool-pstrdup2ascii(env, env-tmpPool, s)) 
   #else
  - return (env-tmpPool-pstrdup(env, env-tmpPool, s));
  +#define SSTRDUP_ASCII(e, s) (s) 
   #endif
  -}
   
   static int JK_METHOD jk2_channel_jni_init(jk_env_t *env,
 jk_bean_t *jniWB)
  @@ -207,7 +206,7 @@
   endpoint-channelData=epData;
   
   /* AS400/BS2000 need EBCDIC to ASCII conversion for JNI */
  -jniCh-jniBridge = (*jniEnv)-FindClass(jniEnv, strdup_ascii(env, 
jniCh-className) );
  +jniCh-jniBridge = (*jniEnv)-FindClass(jniEnv, SSTRDUP_ASCII(env, 
jniCh-className) );
   
   if( jniCh-jniBridge == NULL ) {
   env-l-jkLog(env, env-l, JK_LOG_ERROR,
  @@ -235,8 +234,8 @@
   
   /* AS400/BS2000 need EBCDIC to ASCII conversion for JNI */
   jmethod=(*jniEnv)-GetStaticMethodID(jniEnv, jniCh-jniBridge,
  - strdup_ascii(env, createJavaContext), 
  - strdup_ascii(env, (Ljava/lang/String;J)Ljava/lang/Object;));
  + SSTRDUP_ASCII(env, createJavaContext), 
  + SSTRDUP_ASCII(env, (Ljava/lang/String;J)Ljava/lang/Object;));
   
   if( jmethod == NULL ) {
   env-l-jkLog(env, env-l, JK_LOG_ERROR,
  @@ -250,7 +249,7 @@
   }
   
   /* AS400/BS2000 need EBCDIC to ASCII conversion for JNI */
  -jstr=(*jniEnv)-NewStringUTF(jniEnv, strdup_ascii(env, channelJni ));
  +jstr=(*jniEnv)-NewStringUTF(jniEnv, SSTRDUP_ASCII(env, channelJni ));
   
   jobj=(*jniEnv)-CallStaticObjectMethod( jniEnv, jniCh-jniBridge,
   jmethod,
  @@ -276,8 +275,8 @@
   
   /* AS400/BS2000 need EBCDIC to ASCII conversion for JNI */
   jmethod=(*jniEnv)-GetStaticMethodID(jniEnv, jniCh-jniBridge,
  - strdup_ascii(env, getBuffer),
  - strdup_ascii(env, 
(Ljava/lang/Object;I)[B));
  + SSTRDUP_ASCII(env, getBuffer),
  + SSTRDUP_ASCII(env, 
(Ljava/lang/Object;I)[B));
   if( jmethod == NULL ) {
   env-l-jkLog(env, env-l, JK_LOG_ERROR,
 channel_jni.open() can't find getBuffer\n); 
  @@ -301,8 +300,8 @@
   /* AS400/BS2000 need EBCDIC to ASCII conversion for JNI */
   jniCh-writeMethod =
   (*jniEnv)-GetStaticMethodID(jniEnv, jniCh-jniBridge,
  - strdup_ascii(env, jniInvoke),
  - strdup_ascii(env, (JLjava/lang/Object;)I));
  + SSTRDUP_ASCII(env, jniInvoke),
  + SSTRDUP_ASCII(env, (JLjava/lang/Object;)I));
   
   if( jniCh-writeMethod == NULL ) {
   env-l-jkLog(env, env-l, JK_LOG_EMERG,
  
  
  

--
To unsubscribe, e-mail:   mailto:[EMAIL PROTECTED]
For additional commands, e-mail: mailto:[EMAIL PROTECTED]




cvs commit: jakarta-tomcat-connectors/jk/native2/common jk_channel_jni.c

2003-01-23 Thread mturk
mturk   2003/01/23 04:27:45

  Modified:jk/native2/common jk_channel_jni.c
  Log:
  Fix the SSTRDUP_ASCII macro for EBDIC systems.
  
  Revision  ChangesPath
  1.40  +2 -2  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.39
  retrieving revision 1.40
  diff -u -r1.39 -r1.40
  --- jk_channel_jni.c  23 Jan 2003 12:13:03 -  1.39
  +++ jk_channel_jni.c  23 Jan 2003 12:27:45 -  1.40
  @@ -113,11 +113,11 @@
  Duplicate string and convert it to ASCII on EBDIC based systems
  Needed for at least AS/400 and BS2000 but what about other EBDIC systems ?
  Implement as macro cause:   
  -   we don't need to duplicate the strings if they are const on non EBDIS systems 
  +   we don't need to duplicate the strings if they are const on non EBDIC systems 
   */
   
   #if defined(AS400) || defined(_OSD_POSIX)
  -#define SSTRDUP_ASCII(e, s) ((e)-tmpPool-pstrdup2ascii(env, env-tmpPool, s)) 
  +#define SSTRDUP_ASCII(e, s) ((e)-tmpPool-pstrdup2ascii(e, (e)-tmpPool, s)) 
   #else
   #define SSTRDUP_ASCII(e, s) (s) 
   #endif
  
  
  

--
To unsubscribe, e-mail:   mailto:[EMAIL PROTECTED]
For additional commands, e-mail: mailto:[EMAIL PROTECTED]




cvs commit: jakarta-tomcat-connectors/jk/native2/common jk_channel_jni.c

2002-09-26 Thread mturk

mturk   2002/09/26 03:39:57

  Modified:jk/native2/common jk_channel_jni.c
  Log:
  Some Henri's leftovers :)
  
  Revision  ChangesPath
  1.35  +2 -2  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.34
  retrieving revision 1.35
  diff -u -r1.34 -r1.35
  --- jk_channel_jni.c  25 Sep 2002 07:42:29 -  1.34
  +++ jk_channel_jni.c  26 Sep 2002 10:39:57 -  1.35
  @@ -232,7 +232,7 @@
   /* AS400/BS2000 need EBCDIC to ASCII conversion for JNI */
   jmethod=(*jniEnv)-GetStaticMethodID(jniEnv, jniCh-jniBridge,
strdup_ascii(env, createJavaContext), 
  - strdup_ascii(env, (Ljava/lang/String;J)Ljava/lang/Object;);
  + strdup_ascii(env, (Ljava/lang/String;J)Ljava/lang/Object;));
   
   if( jmethod == NULL ) {
   env-l-jkLog(env, env-l, JK_LOG_ERROR,
  @@ -298,7 +298,7 @@
   jniCh-writeMethod =
   (*jniEnv)-GetStaticMethodID(jniEnv, jniCh-jniBridge,
strdup_ascii(env, jniInvoke),
  - strdup_ascii(env, (JLjava/lang/Object;)I))s;
  + strdup_ascii(env, (JLjava/lang/Object;)I));
   
   if( jniCh-writeMethod == NULL ) {
   env-l-jkLog(env, env-l, JK_LOG_EMERG,
  
  
  

--
To unsubscribe, e-mail:   mailto:[EMAIL PROTECTED]
For additional commands, e-mail: mailto:[EMAIL PROTECTED]




Re: cvs commit: jakarta-tomcat-connectors/jk/native2/common jk_channel_jni.c

2002-09-26 Thread Henri Gomez

[EMAIL PROTECTED] wrote:
 mturk   2002/09/26 03:39:57
 
   Modified:jk/native2/common jk_channel_jni.c
   Log:
   Some Henri's leftovers :)
   
   Revision  ChangesPath
   1.35  +2 -2  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.34
   retrieving revision 1.35
   diff -u -r1.34 -r1.35
   --- jk_channel_jni.c25 Sep 2002 07:42:29 -  1.34
   +++ jk_channel_jni.c26 Sep 2002 10:39:57 -  1.35
   @@ -232,7 +232,7 @@
/* AS400/BS2000 need EBCDIC to ASCII conversion for JNI */
jmethod=(*jniEnv)-GetStaticMethodID(jniEnv, jniCh-jniBridge,
 strdup_ascii(env, createJavaContext), 
   - strdup_ascii(env, (Ljava/lang/String;J)Ljava/lang/Object;);
   + strdup_ascii(env, (Ljava/lang/String;J)Ljava/lang/Object;));

if( jmethod == NULL ) {
env-l-jkLog(env, env-l, JK_LOG_ERROR,
   @@ -298,7 +298,7 @@

Dam't copy paste thanks Mladen ;)



--
To unsubscribe, e-mail:   mailto:[EMAIL PROTECTED]
For additional commands, e-mail: mailto:[EMAIL PROTECTED]




cvs commit: jakarta-tomcat-connectors/jk/native2/common jk_channel_jni.c

2002-07-14 Thread mturk

mturk   2002/07/14 06:36:03

  Modified:jk/native2/common jk_channel_jni.c
  Log:
  Remove the jvm detaching from channel ajp to the service.
  
  Revision  ChangesPath
  1.33  +7 -3  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.32
  retrieving revision 1.33
  diff -u -r1.32 -r1.33
  --- jk_channel_jni.c  8 Jul 2002 13:41:46 -   1.32
  +++ jk_channel_jni.c  14 Jul 2002 13:36:03 -  1.33
  @@ -522,11 +522,15 @@
   {
   jk_workerEnv_t *we=worker-workerEnv;
   
  -/* XXX Don't detach if worker is reused per thread */
  -if( we==NULL || we-vm==NULL ) {
  +if( we==NULL || we-vm==NULL) {
   return JK_OK;
   }
  -we-vm-detach( env, we-vm );
  +/* 
  + * In case of not having the endpoint detach the jvm.
  + * XXX Remove calling this function from ajp13 worker?
  + */
  +if (endpoint == NULL)
  +we-vm-detach( env, we-vm );
   if( worker-mbean-debug  0 )
   env-l-jkLog(env, env-l, JK_LOG_DEBUG, 
 channelJni.afterRequest() ok\n);
  
  
  

--
To unsubscribe, e-mail:   mailto:[EMAIL PROTECTED]
For additional commands, e-mail: mailto:[EMAIL PROTECTED]




cvs commit: jakarta-tomcat-connectors/jk/native2/common jk_channel_jni.c

2002-07-08 Thread mturk

mturk   2002/07/08 06:41:47

  Modified:jk/native2/common jk_channel_jni.c
  Log:
  no message
  
  Revision  ChangesPath
  1.32  +9 -10 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.31
  retrieving revision 1.32
  diff -u -r1.31 -r1.32
  --- jk_channel_jni.c  2 Jul 2002 12:08:25 -   1.31
  +++ jk_channel_jni.c  8 Jul 2002 13:41:46 -   1.32
  @@ -367,7 +367,7 @@
   (jk_ch_jni_ep_private_t *)endpoint-channelData;
   
   if( _this-mbean-debug  0 )
  -env-l-jkLog(env, env-l, JK_LOG_INFO,channel_jni.send() %#lx\n, epData 
); 
  +env-l-jkLog(env, env-l, JK_LOG_DEBUG,channel_jni.send() %#lx\n, epData 
); 
   
   if( epData == NULL ) {
   jk2_channel_jni_open( env, _this, endpoint );
  @@ -388,7 +388,7 @@
   b=msg-buf;
   
   if( _this-mbean-debug  0 )
  -env-l-jkLog(env, env-l, JK_LOG_INFO,channel_jni.send() (1) %#lx\n, 
epData ); 
  +env-l-jkLog(env, env-l, JK_LOG_DEBUG,channel_jni.send() (1) %#lx\n, 
epData ); 
   
   jniEnv=NULL; /* epData-jniEnv; */
   jbuf=epData-jarray;
  @@ -409,7 +409,7 @@
   }
   
   if( _this-mbean-debug  0 )
  -env-l-jkLog(env, env-l, JK_LOG_INFO,
  +env-l-jkLog(env, env-l, JK_LOG_DEBUG,
 channel_jni.send() getting byte array \n );
   
   /* Copy the data in the ( recycled ) jbuf, then call the
  @@ -439,7 +439,7 @@
   (*jniEnv)-ReleaseByteArrayElements(jniEnv, jbuf, nbuf, 0);
   #endif
   if( _this-mbean-debug  0 )
  -env-l-jkLog(env, env-l, JK_LOG_INFO,
  +env-l-jkLog(env, env-l, JK_LOG_DEBUG,
 channel_jni.send() before send %#lx\n,
 (void *)(long)epData-jniJavaContext); 
   
  @@ -449,7 +449,7 @@
(jlong)(long)(void *)env,
epData-jniJavaContext );
   if( _this-mbean-debug  0 )
  -env-l-jkLog(env, env-l, JK_LOG_INFO,channel_jni.send() result %d\n,
  +env-l-jkLog(env, env-l, JK_LOG_DEBUG,channel_jni.send() result %d\n,
 sent); 
   return JK_OK;
   }
  @@ -507,7 +507,7 @@
   jk_workerEnv_t *we=worker-workerEnv;
   
   if( worker-mbean-debug  0 )
  -env-l-jkLog(env, env-l, JK_LOG_INFO, service() attaching to vm\n);
  +env-l-jkLog(env, env-l, JK_LOG_DEBUG, service() attaching to vm\n);
   
   return JK_OK;
   }
  @@ -527,9 +527,8 @@
   return JK_OK;
   }
   we-vm-detach( env, we-vm );
  -
   if( worker-mbean-debug  0 )
  -env-l-jkLog(env, env-l, JK_LOG_INFO, 
  +env-l-jkLog(env, env-l, JK_LOG_DEBUG, 
 channelJni.afterRequest() ok\n);
   return JK_OK;
   }
  @@ -567,13 +566,13 @@
   int rc=JK_OK;
   
   if( ch-mbean-debug  0 )
  -env-l-jkLog(env, env-l, JK_LOG_INFO, 
  +env-l-jkLog(env, env-l, JK_LOG_DEBUG, 
 ch.%d() \n, code);
   
   code = (int)msg-getByte(env, msg);
   
   if( ch-mbean-debug  0 )
  -env-l-jkLog(env, env-l, JK_LOG_INFO,channelJni.java2cInvoke() %d\n, 
code);
  +env-l-jkLog(env, env-l, JK_LOG_DEBUG,channelJni.java2cInvoke() %d\n, 
code);
   
   return ep-worker-workerEnv-dispatch( env, ep-worker-workerEnv,
   ep-currentRequest, ep, code, ep-reply 
);
  
  
  

--
To unsubscribe, e-mail:   mailto:[EMAIL PROTECTED]
For additional commands, e-mail: mailto:[EMAIL PROTECTED]




cvs commit: jakarta-tomcat-connectors/jk/native2/common jk_channel_jni.c

2002-07-02 Thread mturk

mturk   2002/07/02 05:08:25

  Modified:jk/native2/common jk_channel_jni.c
  Log:
  Call the vm detach on 'afterRequest' and on
  channel destoy.
  
  Revision  ChangesPath
  1.31  +5 -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.30
  retrieving revision 1.31
  diff -u -r1.30 -r1.31
  --- jk_channel_jni.c  29 Jun 2002 18:31:00 -  1.30
  +++ jk_channel_jni.c  2 Jul 2002 12:08:25 -   1.31
  @@ -329,6 +329,10 @@
   (*jniEnv)-DeleteGlobalRef( jniEnv, epData-jniJavaContext );
   }
   
  +jniCh-vm-detach( env, jniCh-vm );
  +env-l-jkLog(env, env-l, JK_LOG_INFO,
  +  channel_jni.close() ok\n ); 
  +
   endpoint-channelData=NULL;
   return JK_OK;
   
  @@ -522,7 +526,7 @@
   if( we==NULL || we-vm==NULL ) {
   return JK_OK;
   }
  -/* we-vm-detach( env, we-vm );  */
  +we-vm-detach( env, we-vm );
   
   if( worker-mbean-debug  0 )
   env-l-jkLog(env, env-l, JK_LOG_INFO, 
  
  
  

--
To unsubscribe, e-mail:   mailto:[EMAIL PROTECTED]
For additional commands, e-mail: mailto:[EMAIL PROTECTED]




cvs commit: jakarta-tomcat-connectors/jk/native2/common jk_channel_jni.c

2002-06-29 Thread mturk

mturk   2002/06/29 00:51:20

  Modified:jk/native2/common jk_channel_jni.c
  Log:
  Add 'init' param that if set disables the channel until the
  TC startup finishes, or lb timeout occurs.
  
  Revision  ChangesPath
  1.29  +38 -3 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.28
  retrieving revision 1.29
  diff -u -r1.28 -r1.29
  --- jk_channel_jni.c  26 Jun 2002 11:06:58 -  1.28
  +++ jk_channel_jni.c  29 Jun 2002 07:51:20 -  1.29
  @@ -80,6 +80,8 @@
   /* default only, is configurable now */
   #define JAVA_BRIDGE_CLASS_NAME (org/apache/jk/apr/AprImpl)
   
  +#define JNI_TOMCAT_STARTED 2
  +extern int jk_jni_status_code;
   
   /** Information specific for the socket channel
*/
  @@ -90,6 +92,8 @@
   jclass jniBridge;
   
   jmethodID writeMethod;
  +int status;
  +int wait_initialized;
   } jk_channel_jni_private_t;
   
   typedef struct {
  @@ -154,7 +158,7 @@
 channel_jni.open()  NullPointerException, no channel worker 
found\n); 
   return JK_ERR;
   }
  -
  +
   jniCh-vm=(jk_vm_t *)we-vm;
   if( jniCh-vm == NULL ) {
   env-l-jkLog(env, env-l, JK_LOG_ERROR,
  @@ -215,6 +219,10 @@
   env-l-jkLog(env, env-l, JK_LOG_ERROR,
 channel_jni.open() can't find createJavaContext\n); 
   _this-worker-mbean-disabled=JK_TRUE;
  +
  +if( (*jniEnv)-ExceptionCheck( jniEnv ) ) {
  +(*jniEnv)-ExceptionClear( jniEnv );
  +}
   return JK_ERR;
   }
   
  @@ -230,6 +238,9 @@
 channel_jni.open() Can't create java context\n ); 
   epData-jniJavaContext=NULL;
   _this-worker-mbean-disabled=JK_TRUE;
  +if( (*jniEnv)-ExceptionCheck( jniEnv ) ) {
  +(*jniEnv)-ExceptionClear( jniEnv );
  +}
   return JK_ERR;
   }
   epData-jniJavaContext=(*jniEnv)-NewGlobalRef( jniEnv, jobj );
  @@ -297,6 +308,12 @@
   JNIEnv *jniEnv;
   jk_channel_jni_private_t *jniCh=_this-_privatePtr;
   epData=(jk_ch_jni_ep_private_t *)endpoint-channelData;
  +
  +if (epData == NULL) {
  +env-l-jkLog(env, env-l, JK_LOG_INFO,
  +  channel_jni.close() no channel data\n ); 
  +return JK_ERR;
  +}
   jniEnv = (JNIEnv *)jniCh-vm-attach( env, jniCh-vm );
   
   if( jniEnv == NULL ) {
  @@ -524,6 +541,10 @@
   if( strcmp( class, name ) == 0 ) {
   jniInfo-className=value;
   }
  +else if( strcmp( init, name ) == 0 ) {
  +jniInfo-wait_initialized=atoi(value);
  +}
  +
   /* TODO: apache protocol hooks
   else if( strcmp( , name ) == 0 ) {
   jniInfo-=value;
  @@ -557,6 +578,19 @@
   ep-currentRequest, ep, code, ep-reply 
);
   }
   
  +static int JK_METHOD jk2_channel_jni_status(jk_env_t *env,
  +jk_channel_t *_this)
  +{
  +
  +jk_channel_jni_private_t *jniCh=_this-_privatePtr;
  +if ( jniCh-status != JNI_TOMCAT_STARTED  jniCh-wait_initialized) {
  +jniCh-status = jk_jni_status_code;
  +if (jniCh-status != JNI_TOMCAT_STARTED)
  +return JK_ERR;
  +}
  +return JK_OK;
  +}
  +
   
   int JK_METHOD jk2_channel_jni_factory(jk_env_t *env, jk_pool_t *pool, 
 jk_bean_t *result,
  @@ -565,7 +599,7 @@
   jk_channel_t *ch=result-object;
   jk_workerEnv_t *wEnv;
   jk_channel_jni_private_t *jniPrivate;
  -
  +
   ch=(jk_channel_t *)pool-calloc(env, pool, sizeof( jk_channel_t));
   
   ch-recv= jk2_channel_jni_recv;
  @@ -575,7 +609,8 @@
   
   ch-beforeRequest= jk2_channel_jni_beforeRequest;
   ch-afterRequest= jk2_channel_jni_afterRequest;
  -
  +ch-status = jk2_channel_jni_status;
  +
   ch-_privatePtr=jniPrivate=(jk_channel_jni_private_t *)pool-calloc(env, pool,
   sizeof(jk_channel_jni_private_t));
   
  
  
  

--
To unsubscribe, e-mail:   mailto:[EMAIL PROTECTED]
For additional commands, e-mail: mailto:[EMAIL PROTECTED]




cvs commit: jakarta-tomcat-connectors/jk/native2/common jk_channel_jni.c

2002-06-29 Thread mturk

mturk   2002/06/29 11:31:01

  Modified:jk/native2/common jk_channel_jni.c
  Log:
  Make default 60 second initialization.
  
  Revision  ChangesPath
  1.30  +7 -8  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.29
  retrieving revision 1.30
  diff -u -r1.29 -r1.30
  --- jk_channel_jni.c  29 Jun 2002 07:51:20 -  1.29
  +++ jk_channel_jni.c  29 Jun 2002 18:31:00 -  1.30
  @@ -93,7 +93,6 @@
   
   jmethodID writeMethod;
   int status;
  -int wait_initialized;
   } jk_channel_jni_private_t;
   
   typedef struct {
  @@ -119,8 +118,10 @@
   if( wEnv-vm == NULL ) {
   env-l-jkLog(env, env-l, JK_LOG_INFO,
 channel_jni.init() no VM found\n );
  -if( jniW-worker != NULL )
  +if( jniW-worker != NULL ) {
   jniW-worker-mbean-disabled=JK_TRUE;
  +jniW-worker-mbean-initialize=60;
  +}
   return JK_ERR;
   }
   return JK_OK;
  @@ -541,10 +542,6 @@
   if( strcmp( class, name ) == 0 ) {
   jniInfo-className=value;
   }
  -else if( strcmp( init, name ) == 0 ) {
  -jniInfo-wait_initialized=atoi(value);
  -}
  -
   /* TODO: apache protocol hooks
   else if( strcmp( , name ) == 0 ) {
   jniInfo-=value;
  @@ -579,11 +576,12 @@
   }
   
   static int JK_METHOD jk2_channel_jni_status(jk_env_t *env,
  +struct jk_worker *worker,
   jk_channel_t *_this)
   {
   
   jk_channel_jni_private_t *jniCh=_this-_privatePtr;
  -if ( jniCh-status != JNI_TOMCAT_STARTED  jniCh-wait_initialized) {
  +if ( jniCh-status != JNI_TOMCAT_STARTED  worker-mbean-initialize) {
   jniCh-status = jk_jni_status_code;
   if (jniCh-status != JNI_TOMCAT_STARTED)
   return JK_ERR;
  @@ -628,7 +626,8 @@
   wEnv-addChannel( env, wEnv, ch );
   
   result-invoke=jk2_channel_jni_invoke;
  -
  +ch-worker-mbean-initialize = 60;
  +
   return JK_OK;
   }
   
  
  
  

--
To unsubscribe, e-mail:   mailto:[EMAIL PROTECTED]
For additional commands, e-mail: mailto:[EMAIL PROTECTED]




cvs commit: jakarta-tomcat-connectors/jk/native2/common jk_channel_jni.c

2002-06-26 Thread mturk

mturk   2002/06/26 04:06:58

  Modified:jk/native2/common jk_channel_jni.c
  Log:
  Fix the multithreading bug in channel open, setting worker to the
  disabled state, that caused already opened enpoint to fail.
  
  Revision  ChangesPath
  1.28  +27 -18jakarta-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.27
  retrieving revision 1.28
  diff -u -r1.27 -r1.28
  --- jk_channel_jni.c  10 Jun 2002 23:57:24 -  1.27
  +++ jk_channel_jni.c  26 Jun 2002 11:06:58 -  1.28
  @@ -146,20 +146,28 @@
   
   env-l-jkLog(env, env-l, JK_LOG_INFO,channel_jni.open():  \n );
   
  -if( _this-worker != NULL )
  -_this-worker-mbean-disabled=JK_TRUE;
  -
  +/* It is useless to continue if the channel worker 
  +   does not exist.
  + */
  +if( _this-worker == NULL ) {
  +env-l-jkLog(env, env-l, JK_LOG_ERROR,
  +  channel_jni.open()  NullPointerException, no channel worker 
found\n); 
  +return JK_ERR;
  +}
  +
   jniCh-vm=(jk_vm_t *)we-vm;
   if( jniCh-vm == NULL ) {
  -env-l-jkLog(env, env-l, JK_LOG_INFO,
  +env-l-jkLog(env, env-l, JK_LOG_ERROR,
 channel_jni.open() no VM found\n ); 
  +_this-worker-mbean-disabled=JK_TRUE;
   return JK_ERR;
   }
   
   jniEnv = (JNIEnv *)jniCh-vm-attach( env, jniCh-vm );
   if( jniEnv == NULL ) {
  -env-l-jkLog(env, env-l, JK_LOG_INFO,
  +env-l-jkLog(env, env-l, JK_LOG_ERROR,
 channel_jni.open() can't attach\n ); 
  +_this-worker-mbean-disabled=JK_TRUE;
   return JK_ERR;
   }
   /* Create the buffers used by the write method. We allocate a
  @@ -174,24 +182,22 @@
  sizeof( jk_ch_jni_ep_private_t ));
   
   endpoint-channelData=epData;
  -/** XXX make it customizable */
  -jniCh-className=JAVA_BRIDGE_CLASS_NAME;
  -
  -jniCh-jniBridge =
  -(*jniEnv)-FindClass(jniEnv, jniCh-className );
   
  +jniCh-jniBridge = (*jniEnv)-FindClass(jniEnv, jniCh-className );
   
   if( jniCh-jniBridge == NULL ) {
  -env-l-jkLog(env, env-l, JK_LOG_INFO,
  +env-l-jkLog(env, env-l, JK_LOG_ERROR,
 channel_jni.open() can't find %s\n,jniCh-className ); 
  +_this-worker-mbean-disabled=JK_TRUE;
   return JK_ERR;
   }
   
   jniCh-jniBridge=(*jniEnv)-NewGlobalRef( jniEnv, jniCh-jniBridge);
   
   if( jniCh-jniBridge == NULL ) {
  -env-l-jkLog(env, env-l, JK_LOG_INFO,
  +env-l-jkLog(env, env-l, JK_LOG_ERROR,
 channel_jni.open() Unable to allocate globalref for 
%s\n,jniCh-className ); 
  +_this-worker-mbean-disabled=JK_TRUE;
   return JK_ERR;
   }
   
  @@ -206,8 +212,9 @@
   jmethod=(*jniEnv)-GetStaticMethodID(jniEnv, jniCh-jniBridge,
createJavaContext, (Ljava/lang/String;J)Ljava/lang/Object;);
   if( jmethod == NULL ) {
  -env-l-jkLog(env, env-l, JK_LOG_INFO,
  +env-l-jkLog(env, env-l, JK_LOG_ERROR,
 channel_jni.open() can't find createJavaContext\n); 
  +_this-worker-mbean-disabled=JK_TRUE;
   return JK_ERR;
   }
   
  @@ -222,6 +229,7 @@
   env-l-jkLog(env, env-l, JK_LOG_ERROR,
 channel_jni.open() Can't create java context\n ); 
   epData-jniJavaContext=NULL;
  +_this-worker-mbean-disabled=JK_TRUE;
   return JK_ERR;
   }
   epData-jniJavaContext=(*jniEnv)-NewGlobalRef( jniEnv, jobj );
  @@ -235,8 +243,9 @@
getBuffer,
(Ljava/lang/Object;I)[B);
   if( jmethod == NULL ) {
  -env-l-jkLog(env, env-l, JK_LOG_INFO,
  +env-l-jkLog(env, env-l, JK_LOG_ERROR,
 channel_jni.open() can't find getBuffer\n); 
  +_this-worker-mbean-disabled=JK_TRUE;
   return JK_ERR;
   }
   
  @@ -259,17 +268,17 @@
(JLjava/lang/Object;)I);
   
   if( jniCh-writeMethod == NULL ) {
  -env-l-jkLog(env, env-l, JK_LOG_EMERG,
  +env-l-jkLog(env, env-l, JK_LOG_EMERG,
 channel_jni.open() can't find jniInvoke\n); 
  +
  +_this-worker-mbean-disabled=JK_TRUE;
   return JK_ERR;
   }
   
   env-l-jkLog(env, env-l, JK_LOG_INFO,
 channel_jni.open() found write method, open ok\n ); 
   
  -
  -if( _this-worker != NULL )
  -_this-worker-mbean-disabled=JK_FALSE;
  +_this-worker-mbean-disabled=JK_FALSE;
   
   /* Don't detach ( XXX Need to 

cvs commit: jakarta-tomcat-connectors/jk/native2/common jk_channel_jni.c

2002-06-10 Thread costin

costin  2002/06/10 16:57:24

  Modified:jk/native2/common jk_channel_jni.c
  Log:
  Remove the dispatch ( which remains to be used only for incoming AJP messages,
  until we finish merging the 2 mechanisms ).
  
  Invoke() will be used instead - that's the new mechanism, used to support
  all new jk components.
  
  Revision  ChangesPath
  1.27  +24 -20jakarta-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.26
  retrieving revision 1.27
  diff -u -r1.26 -r1.27
  --- jk_channel_jni.c  10 Jun 2002 21:55:06 -  1.26
  +++ jk_channel_jni.c  10 Jun 2002 23:57:24 -  1.27
  @@ -503,22 +503,6 @@
   return JK_OK;
   }
   
  -/** Called by java. Will take the rest of the message and dispatch again to the 
real target.
  - */
  -static int JK_METHOD jk2_channel_jni_dispatch(jk_env_t *env, void *target, 
jk_endpoint_t *ep, jk_msg_t *msg)
  -{
  -jk_bean_t *jniChB=(jk_bean_t *)target;
  -jk_channel_t *jniCh=(jk_channel_t *)jniChB-object;
  -int code;
  -
  -if( jniCh-mbean-debug  0 )
  -env-l-jkLog(env, env-l, JK_LOG_INFO,channelJni.java2cInvoke() ok\n);
  -
  -code = (int)msg-getByte(env, msg);
  -return ep-worker-workerEnv-dispatch( env, ep-worker-workerEnv,
  -ep-currentRequest, ep, code, ep-reply 
);
  -}
  -
   static int JK_METHOD jk2_channel_jni_setProperty(jk_env_t *env,
   jk_bean_t *mbean, 
   char *name, void *valueP)
  @@ -542,6 +526,29 @@
   return JK_OK;
   }
   
  +/** Called by java. Will take the msg and dispatch it to workerEnv, as if it would
  + *  be if received via socket
  + */
  +int JK_METHOD jk2_channel_jni_invoke(jk_env_t *env, jk_bean_t *bean, jk_endpoint_t 
*ep, int code,
  + jk_msg_t *msg, int raw)
  +{
  +jk_channel_t *ch=(jk_channel_t *)bean-object;
  +int rc=JK_OK;
  +
  +if( ch-mbean-debug  0 )
  +env-l-jkLog(env, env-l, JK_LOG_INFO, 
  +  ch.%d() \n, code);
  +
  +code = (int)msg-getByte(env, msg);
  +
  +if( ch-mbean-debug  0 )
  +env-l-jkLog(env, env-l, JK_LOG_INFO,channelJni.java2cInvoke() %d\n, 
code);
  +
  +return ep-worker-workerEnv-dispatch( env, ep-worker-workerEnv,
  +ep-currentRequest, ep, code, ep-reply 
);
  +}
  +
  +
   int JK_METHOD jk2_channel_jni_factory(jk_env_t *env, jk_pool_t *pool, 
 jk_bean_t *result,
 const char *type, const char *name)
  @@ -576,10 +583,7 @@
   ch-workerEnv=wEnv;
   wEnv-addChannel( env, wEnv, ch );
   
  -wEnv-registerHandler( env, wEnv, type,
  -   sendResponse, JK_HANDLE_JNI_DISPATCH,
  -   jk2_channel_jni_dispatch, NULL );
  -
  +result-invoke=jk2_channel_jni_invoke;
   
   return JK_OK;
   }
  
  
  

--
To unsubscribe, e-mail:   mailto:[EMAIL PROTECTED]
For additional commands, e-mail: mailto:[EMAIL PROTECTED]




cvs commit: jakarta-tomcat-connectors/jk/native2/common jk_channel_jni.c

2002-05-19 Thread nacho

nacho   02/05/19 14:41:25

  Modified:jk/native2/common jk_channel_jni.c
  Log:
  * Better close, try to release memory and Java Objects..
  
  Revision  ChangesPath
  1.21  +34 -9 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.20
  retrieving revision 1.21
  diff -u -r1.20 -r1.21
  --- jk_channel_jni.c  16 May 2002 23:48:27 -  1.20
  +++ jk_channel_jni.c  19 May 2002 21:41:25 -  1.21
  @@ -192,7 +192,6 @@
   jniCh-jniBridge =
   (*jniEnv)-FindClass(jniEnv, jniCh-className );
   
  -jniCh-jniBridge=(*jniEnv)-NewGlobalRef( jniEnv, jniCh-jniBridge);
   
   if( jniCh-jniBridge == NULL ) {
   env-l-jkLog(env, env-l, JK_LOG_INFO,
  @@ -200,6 +199,13 @@
   return JK_ERR;
   }
   
  +jniCh-jniBridge=(*jniEnv)-NewGlobalRef( jniEnv, jniCh-jniBridge);
  +
  +if( jniCh-jniBridge == NULL ) {
  +env-l-jkLog(env, env-l, JK_LOG_INFO,
  +  channel_jni.open() Unable to allocate globalref for 
%s\n,jniCh-className ); 
  +return JK_ERR;
  +}
   
   /* Interface to the callback mechansim. The idea is simple ( is it ? ) - we
  use a similar pattern with java, trying to do as little as possible
  @@ -291,12 +297,27 @@
  jk_endpoint_t *endpoint)
   {
   jk_ch_jni_ep_private_t *epData;
  -
  +JNIEnv *jniEnv;
  +jk_channel_jni_private_t *jniCh=_this-_privatePtr;
   epData=(jk_ch_jni_ep_private_t *)endpoint-channelData;
  -
  -/* (*jniEnv)-DeleteGlobalRef( jniEnv, epData-msgJ ); */
  -/* (*jniEnv)-DeleteGlobalRef( jniEnv, epData-jniJavaContext ); */
  -
  +jniEnv = (JNIEnv *)jniCh-vm-attach( env, jniCh-vm );
  +
  +if( jniEnv == NULL ) {
  +env-l-jkLog(env, env-l, JK_LOG_INFO,
  +  channel_jni.close() can't attach\n ); 
  +return JK_ERR;
  +}
  +if( epData-jarray != NULL ){
  +(*jniEnv)-DeleteGlobalRef( jniEnv, epData-jarray );
  +}
  +if( epData-jniJavaContext != NULL){
  +(*jniEnv)-DeleteGlobalRef( jniEnv, epData-jniJavaContext );
  +}
  +endpoint-mbean-pool-realloc(env,endpoint-mbean-pool,0,
  +epData-carray,epData-arrayLen);
  +endpoint-mbean-pool-realloc(env,endpoint-mbean-pool,0,
  +epData,sizeof( jk_ch_jni_ep_private_t ));
  +endpoint-channelData=NULL;
   return JK_OK;
   
   }
  @@ -327,7 +348,7 @@
   JNIEnv *jniEnv;
   jk_channel_jni_private_t *jniCh=_this-_privatePtr;
   jk_ch_jni_ep_private_t *epData=
  -(jk_ch_jni_ep_private_t *)endpoint-channelData;;
  +(jk_ch_jni_ep_private_t *)endpoint-channelData;
   
   if( _this-mbean-debug  0 )
   env-l-jkLog(env, env-l, JK_LOG_INFO,channel_jni.send() %p\n, epData ); 
  @@ -336,9 +357,13 @@
   jk2_channel_jni_open( env, _this, endpoint );
   epData=(jk_ch_jni_ep_private_t *)endpoint-channelData;
   }
  -if( epData == NULL || epData-jniJavaContext == NULL ) {
  +if( epData == NULL ){
  +env-l-jkLog(env, env-l, JK_LOG_ERROR,channel_jni.send() error opening 
channel\n ); 
  +return JK_ERR;
  +}
  +if( epData-jniJavaContext == NULL ) {
   env-l-jkLog(env, env-l, JK_LOG_ERROR,channel_jni.send() no java 
context\n ); 
  -
  +jk2_channel_jni_close( env, _this, endpoint );
   return JK_ERR;
   }
   
  
  
  

--
To unsubscribe, e-mail:   mailto:[EMAIL PROTECTED]
For additional commands, e-mail: mailto:[EMAIL PROTECTED]




cvs commit: jakarta-tomcat-connectors/jk/native2/common jk_channel_jni.c

2002-05-10 Thread costin

costin  02/05/10 17:02:53

  Modified:jk/native2/common jk_channel_jni.c
  Log:
  Display a small warning if getArray() doesn't pin, it's an indication
  of possible performance problems.
  
  Revision  ChangesPath
  1.17  +14 -4 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.16
  retrieving revision 1.17
  diff -u -r1.16 -r1.17
  --- jk_channel_jni.c  10 May 2002 00:01:37 -  1.16
  +++ jk_channel_jni.c  11 May 2002 00:02:53 -  1.17
  @@ -317,7 +317,7 @@
   jbyte *nbuf;
   jbyteArray jbuf;
   int jlen;
  -jboolean iscommit=0;
  +jboolean iscopy=0;
   JNIEnv *jniEnv;
   jk_channel_jni_private_t *jniCh=_this-_privatePtr;
   jk_ch_jni_ep_private_t *epData=
  @@ -369,8 +369,15 @@
*  write method. XXX We could try 'pining' if the vm supports
*  it, this is a looong lived object.
*/
  -nbuf = (*jniEnv)-GetByteArrayElements(jniEnv, jbuf, iscommit);
  -
  +#ifdef JK_JNI_CRITICAL
  +nbuf = (*jniEnv)-GetPrimitiveArrayCritical(jniEnv, jbuf, iscopy);
  +#else
  +nbuf = (*jniEnv)-GetByteArrayElements(jniEnv, jbuf, iscopy);
  +#endif
  +if( iscopy )
  +env-l-jkLog(env, env-l, JK_LOG_INFO,
  +  channelJni.send() get java bytes iscopy %d\n, iscopy);
  +
   if(nbuf==NULL ) {
   env-l-jkLog(env, env-l, JK_LOG_ERROR,
 channelJni.send() Can't get java bytes);
  @@ -384,8 +391,11 @@
   
   memcpy( nbuf, b, len );
   
  +#ifdef JK_JNI_CRITICAL
  +(*jniEnv)-ReleasePrimitiveArrayCritical(jniEnv, jbuf, nbuf, 0);
  +#else
   (*jniEnv)-ReleaseByteArrayElements(jniEnv, jbuf, nbuf, 0);
  -
  +#endif
   if( _this-mbean-debug  0 )
   env-l-jkLog(env, env-l, JK_LOG_INFO,
 channel_jni.send() before send %p\n,
  
  
  

--
To unsubscribe, e-mail:   mailto:[EMAIL PROTECTED]
For additional commands, e-mail: mailto:[EMAIL PROTECTED]




cvs commit: jakarta-tomcat-connectors/jk/native2/common jk_channel_jni.c

2002-04-25 Thread costin

costin  02/04/25 11:48:13

  Modified:jk/native2/common jk_channel_jni.c
  Log:
  Fix error handling.
  
  Remove duplicated code ( now all dispatching is done consistently in jni/ ).
  
  Revision  ChangesPath
  1.10  +48 -160   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.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- jk_channel_jni.c  15 Apr 2002 23:52:41 -  1.9
  +++ jk_channel_jni.c  25 Apr 2002 18:48:13 -  1.10
  @@ -104,14 +104,14 @@
jk_bean_t *mbean, 
char *name, void *value)
   {
  -return JK_TRUE;
  +return JK_OK;
   }
   
   static int JK_METHOD jk2_channel_jni_init(jk_env_t *env,
 jk_channel_t *_this)
   {
   
  -return JK_TRUE;
  +return JK_OK;
   }
   
   /** Assume the jni-worker or someone else started
  @@ -133,7 +133,7 @@
   if( endpoint-channelData != NULL ) {
   env-l-jkLog(env, env-l, JK_LOG_INFO,
 channel_jni.open() already open, nothing else to do\n); 
  -return JK_TRUE;
  +return JK_OK;
   }
   
   env-l-jkLog(env, env-l, JK_LOG_INFO,channel_jni.init():  \n );
  @@ -142,14 +142,14 @@
   if( jniCh-vm == NULL ) {
   env-l-jkLog(env, env-l, JK_LOG_INFO,
 channel_jni.open() no VM found\n ); 
  -return JK_FALSE;
  +return JK_ERR;
   }
   
   jniEnv = (JNIEnv *)jniCh-vm-attach( env, jniCh-vm );
   if( jniEnv == NULL ) {
   env-l-jkLog(env, env-l, JK_LOG_INFO,
 channel_jni.open() can't attach\n ); 
  -return JK_FALSE;
  +return JK_ERR;
   }
   /* Create the buffers used by the write method. We allocate a
  byte[] and jbyte[] - I have no idea what's more expensive,
  @@ -174,7 +174,7 @@
   if( jniCh-jniBridge == NULL ) {
   env-l-jkLog(env, env-l, JK_LOG_INFO,
 channel_jni.open() can't find %s\n,jniCh-className ); 
  -return JK_FALSE;
  +return JK_ERR;
   }
   
   
  @@ -191,7 +191,7 @@
   if( jmethod == NULL ) {
   env-l-jkLog(env, env-l, JK_LOG_INFO,
 channel_jni.open() can't find createJavaContext\n); 
  -return JK_FALSE;
  +return JK_ERR;
   }
   
   jstr=(*jniEnv)-NewStringUTF(jniEnv, channelJni );
  @@ -199,13 +199,13 @@
   jobj=(*jniEnv)-CallStaticObjectMethod( jniEnv, jniCh-jniBridge,
   jmethod,
   jstr, 
  -(jlong)(long)(void *)endpoint );
  +(jlong)(long)(void *)endpoint-mbean );
   
   if( jobj  == NULL ) {
   env-l-jkLog(env, env-l, JK_LOG_ERROR,
 channel_jni.open() Can't create java context\n ); 
   epData-jniJavaContext=NULL;
  -return JK_FALSE;
  +return JK_ERR;
   }
   epData-jniJavaContext=(*jniEnv)-NewGlobalRef( jniEnv, jobj );
   
  @@ -220,7 +220,7 @@
   if( jmethod == NULL ) {
   env-l-jkLog(env, env-l, JK_LOG_INFO,
 channel_jni.open() can't find getBuffer\n); 
  -return JK_FALSE;
  +return JK_ERR;
   }
   
   epData-jarray=(*jniEnv)-CallStaticObjectMethod( jniEnv, jniCh-jniBridge,
  @@ -244,7 +244,7 @@
   if( jniCh-writeMethod == NULL ) {
env-l-jkLog(env, env-l, JK_LOG_EMERG,
 channel_jni.open() can't find jniInvoke\n); 
  -return JK_FALSE;
  +return JK_ERR;
   }
   
   env-l-jkLog(env, env-l, JK_LOG_INFO,
  @@ -255,7 +255,7 @@
*  closing in order for this to work )
*/
   /* jniCh-vm-detach( env, jniCh-vm ); */
  -return JK_TRUE;
  +return JK_OK;
   }
   
   
  @@ -271,7 +271,7 @@
   /* (*jniEnv)-DeleteGlobalRef( jniEnv, epData-msgJ ); */
   /* (*jniEnv)-DeleteGlobalRef( jniEnv, epData-jniJavaContext ); */
   
  -return JK_TRUE;
  +return JK_OK;
   
   }
   
  @@ -313,7 +313,7 @@
   if( epData-jniJavaContext == NULL ) {
   env-l-jkLog(env, env-l, JK_LOG_ERROR,channel_jni.send() no java 
context\n ); 
   
  -return JK_FALSE;
  +return JK_ERR;
   }
   
   msg-end( env, msg );
  @@ -328,7 +328,7 @@
   if( jniCh-writeMethod == NULL ) {
   env-l-jkLog(env, env-l, JK_LOG_EMERG,
 channel_jni.send() no write method\n ); 
  -return JK_FALSE;
  +return JK_ERR;
   }
   if( jniEnv==NULL ) {
   /* Try first getEnv, then 

cvs commit: jakarta-tomcat-connectors/jk/native2/common jk_channel_jni.c

2002-04-15 Thread costin

costin  02/04/15 16:52:41

  Modified:jk/native2/common jk_channel_jni.c
  Log:
  Use a more consistent and flexible mechanism for callbacks from C to java.
  Also 'consolidate' all native code in one class, to simplify loading of the .so
  and avoid ClassLoader problems ( yes, there are problems even in native code ).
  
  Revision  ChangesPath
  1.9   +56 -37jakarta-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.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- jk_channel_jni.c  12 Apr 2002 23:07:11 -  1.8
  +++ jk_channel_jni.c  15 Apr 2002 23:52:41 -  1.9
  @@ -72,7 +72,7 @@
   #include jni.h
   
   /* default only, is configurable now */
  -#define JAVA_BRIDGE_CLASS_NAME (org/apache/jk/common/ChannelJni)
  +#define JAVA_BRIDGE_CLASS_NAME (org/apache/jk/apr/AprImpl)
   
   
   /** Information specific for the socket channel
  @@ -94,8 +94,8 @@
   char *carray;
   int arrayLen;
   
  -jobject epJ;
  -jobject msgJ;
  +jobject jniJavaContext;
  +/* jobject msgJ; */
   } jk_ch_jni_ep_private_t;
   
   
  @@ -126,6 +126,7 @@
   jk_ch_jni_ep_private_t *epData;
   jmethodID jmethod;
   jobject jobj;
  +jstring jstr;
   
   jk_channel_jni_private_t *jniCh=_this-_privatePtr;
   
  @@ -176,44 +177,56 @@
   return JK_FALSE;
   }
   
  +
  +/* Interface to the callback mechansim. The idea is simple ( is it ? ) - we
  +   use a similar pattern with java, trying to do as little as possible
  +   in C and pass minimal information to allow this.
  +
  +   The pattern used for callback works for our message forwarding but also for
  +   other things - like singnals, etc
  +*/
  +
   jmethod=(*jniEnv)-GetStaticMethodID(jniEnv, jniCh-jniBridge,
  - createEndpointStatic, (JJ)Lorg/apache/jk/core/MsgContext;);
  + createJavaContext, (Ljava/lang/String;J)Ljava/lang/Object;);
   if( jmethod == NULL ) {
   env-l-jkLog(env, env-l, JK_LOG_INFO,
  -  channel_jni.open() can't find createEndpointStatic\n); 
  +  channel_jni.open() can't find createJavaContext\n); 
   return JK_FALSE;
   }
  +
  +jstr=(*jniEnv)-NewStringUTF(jniEnv, channelJni );
  +
   jobj=(*jniEnv)-CallStaticObjectMethod( jniEnv, jniCh-jniBridge,
  -   jmethod,
  -   (jlong)(long)(void *)env,
  -   (jlong)(long)(void *)endpoint );
  -epData-epJ=(*jniEnv)-NewGlobalRef( jniEnv, jobj );
  +jmethod,
  +jstr, 
  +(jlong)(long)(void *)endpoint );
   
  -jmethod=(*jniEnv)-GetStaticMethodID(jniEnv, jniCh-jniBridge,
  - createMessage,
  - ()Lorg/apache/jk/common/MsgAjp;);
  -if( jmethod == NULL ) {
  -env-l-jkLog(env, env-l, JK_LOG_INFO,
  -  channel_jni.open() can't find createMessage\n); 
  +if( jobj  == NULL ) {
  +env-l-jkLog(env, env-l, JK_LOG_ERROR,
  +  channel_jni.open() Can't create java context\n ); 
  +epData-jniJavaContext=NULL;
   return JK_FALSE;
   }
  -jobj=(*jniEnv)-CallStaticObjectMethod( jniEnv, jniCh-jniBridge,
  -jmethod );
  -epData-msgJ=(*jniEnv)-NewGlobalRef( jniEnv, jobj );
  +epData-jniJavaContext=(*jniEnv)-NewGlobalRef( jniEnv, jobj );
  +
  +env-l-jkLog(env, env-l, JK_LOG_INFO,
  +  channel_jni.open() Got ep %p %p\n, jobj, epData-jniJavaContext 
); 
   
   /* XXX Destroy them in close */
   
   jmethod=(*jniEnv)-GetStaticMethodID(jniEnv, jniCh-jniBridge,
getBuffer,
  - (Lorg/apache/jk/common/MsgAjp;)[B);
  + (Ljava/lang/Object;I)[B);
   if( jmethod == NULL ) {
   env-l-jkLog(env, env-l, JK_LOG_INFO,
 channel_jni.open() can't find getBuffer\n); 
   return JK_FALSE;
   }
  +
   epData-jarray=(*jniEnv)-CallStaticObjectMethod( jniEnv, jniCh-jniBridge,
  -   jmethod, epData-msgJ );
  -/*epData-jarray=(*jniEnv)-NewByteArray(jniEnv, 1 ); */
  +  jmethod,
  +  epData-jniJavaContext, 0);
  +
   epData-jarray=(*jniEnv)-NewGlobalRef( jniEnv, 

cvs commit: jakarta-tomcat-connectors/jk/native2/common jk_channel_jni.c

2002-04-12 Thread costin

costin  02/04/12 16:07:11

  Modified:jk/native2/common jk_channel_jni.c
  Log:
  Upgrade the jni channel.
  
  Revision  ChangesPath
  1.8   +9 -8  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.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- jk_channel_jni.c  12 Apr 2002 21:49:03 -  1.7
  +++ jk_channel_jni.c  12 Apr 2002 23:07:11 -  1.8
  @@ -110,12 +110,6 @@
   static int JK_METHOD jk2_channel_jni_init(jk_env_t *env,
 jk_channel_t *_this)
   {
  -/* the channel is init-ed during a worker validation. If a jni worker
  -   is not already defined... well, not good. But on open we should
  -   have it.
  -*/
  -env-l-jkLog(env, env-l, JK_LOG_INFO,channel_jni.init():  %s\n, 
  -  _this-worker-mbean-name );
   
   return JK_TRUE;
   }
  @@ -141,7 +135,14 @@
   return JK_TRUE;
   }
   
  +env-l-jkLog(env, env-l, JK_LOG_INFO,channel_jni.init():  \n );
  +
   jniCh-vm=(jk_vm_t *)we-vm;
  +if( jniCh-vm == NULL ) {
  +env-l-jkLog(env, env-l, JK_LOG_INFO,
  +  channel_jni.open() no VM found\n ); 
  +return JK_FALSE;
  +}
   
   jniEnv = (JNIEnv *)jniCh-vm-attach( env, jniCh-vm );
   if( jniEnv == NULL ) {
  @@ -176,7 +177,7 @@
   }
   
   jmethod=(*jniEnv)-GetStaticMethodID(jniEnv, jniCh-jniBridge,
  - createEndpointStatic, (JJ)Lorg/apache/jk/core/Endpoint;);
  + createEndpointStatic, (JJ)Lorg/apache/jk/core/MsgContext;);
   if( jmethod == NULL ) {
   env-l-jkLog(env, env-l, JK_LOG_INFO,
 channel_jni.open() can't find createEndpointStatic\n); 
  @@ -225,7 +226,7 @@
   jniCh-writeMethod =
   (*jniEnv)-GetStaticMethodID(jniEnv, jniCh-jniBridge,
receiveRequest,
  - (JJLorg/apache/jk/core/Endpoint;
  + (JJLorg/apache/jk/core/MsgContext;
Lorg/apache/jk/common/MsgAjp;)I);
   
   if( jniCh-writeMethod == NULL ) {
  
  
  

--
To unsubscribe, e-mail:   mailto:[EMAIL PROTECTED]
For additional commands, e-mail: mailto:[EMAIL PROTECTED]




cvs commit: jakarta-tomcat-connectors/jk/native2/common jk_channel_jni.c jk_channel_socket.c

2002-04-11 Thread costin

costin  02/04/11 12:30:24

  Modified:jk/native2/common jk_channel_jni.c jk_channel_socket.c
  Log:
  Fix initialization.
  
  Revision  ChangesPath
  1.6   +17 -14jakarta-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.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- jk_channel_jni.c  18 Mar 2002 18:25:05 -  1.5
  +++ jk_channel_jni.c  11 Apr 2002 19:30:23 -  1.6
  @@ -592,26 +592,29 @@
 jk_bean_t *result,
 const char *type, const char *name)
   {
  -jk_channel_t *_this=result-object;
  +jk_channel_t *ch=result-object;
   
  -_this=(jk_channel_t *)pool-calloc(env, pool, sizeof( jk_channel_t));
  +ch=(jk_channel_t *)pool-calloc(env, pool, sizeof( jk_channel_t));
   
  -_this-recv= jk2_channel_jni_recv;
  -_this-send= jk2_channel_jni_send; 
  -_this-init= jk2_channel_jni_init; 
  -_this-open= jk2_channel_jni_open; 
  -_this-close= jk2_channel_jni_close; 
  +ch-recv= jk2_channel_jni_recv;
  +ch-send= jk2_channel_jni_send; 
  +ch-init= jk2_channel_jni_init; 
  +ch-open= jk2_channel_jni_open; 
  +ch-close= jk2_channel_jni_close; 
   
  -_this-beforeRequest= jk2_channel_jni_beforeRequest;
  -_this-afterRequest= jk2_channel_jni_afterRequest;
  +ch-beforeRequest= jk2_channel_jni_beforeRequest;
  +ch-afterRequest= jk2_channel_jni_afterRequest;
   
  -_this-_privatePtr=(jk_channel_jni_private_t *)pool-calloc(env, pool,
  +ch-_privatePtr=(jk_channel_jni_private_t *)pool-calloc(env, pool,
   sizeof(jk_channel_jni_private_t));
  -_this-is_stream=JK_FALSE;
  +ch-is_stream=JK_FALSE;
   
   result-setAttribute= jk2_channel_jni_setProperty;
  -_this-mbean=result;
  -result-object= _this;
  -
  +ch-mbean=result;
  +result-object= ch;
  +
  +ch-workerEnv=env-getByName( env, workerEnv );
  +ch-workerEnv-addChannel( env, ch-workerEnv, ch );
  +
   return JK_TRUE;
   }
  
  
  
  1.18  +6 -23 jakarta-tomcat-connectors/jk/native2/common/jk_channel_socket.c
  
  Index: jk_channel_socket.c
  ===
  RCS file: /home/cvs/jakarta-tomcat-connectors/jk/native2/common/jk_channel_socket.c,v
  retrieving revision 1.17
  retrieving revision 1.18
  diff -u -r1.17 -r1.18
  --- jk_channel_socket.c   26 Mar 2002 02:58:30 -  1.17
  +++ jk_channel_socket.c   11 Apr 2002 19:30:23 -  1.18
  @@ -162,7 +162,7 @@
   socketInfo-port=atoi( portIdx );
   }
   if( socketInfo-host==NULL ) {
  -socketInfo-host=ch-pool-calloc( env, ch-pool, strlen( localName 
) + 1 );
  +socketInfo-host=ch-mbean-pool-calloc( env, ch-mbean-pool, 
strlen( localName ) + 1 );
   if( portIdx==NULL ) {
   strcpy( socketInfo-host, localName );
   } else {
  @@ -185,26 +185,8 @@
 can't resolve %s:%d errno=%d\n, socketInfo-host, 
socketInfo-port, errno );
   }
   
  -if( ch-worker == NULL ) {
  -jk_bean_t *jkb;
  -
  -env-l-jkLog(env, env-l, JK_LOG_INFO,
  -  channel_socket.init(): create default worker for %s\n, 
ch-mbean-name );
  -
  -jkb=env-createBean2(env, ch-pool, worker.ajp13, ch-mbean-localName );
  -ch-worker=jkb-object;
  -ch-worker-channelName=ch-mbean-name;
  -ch-worker-channel=ch;
  -
  -/* XXX Set additional parameters - use defaults otherwise */
  -
  -ch-worker-init( env, ch-worker);
  -}
  -
   env-l-jkLog(env, env-l, JK_LOG_INFO,
  -  channel_socket.init(): %s:%d for %s\n, socketInfo-host,
  -  socketInfo-port, ch-worker-mbean-name );
  -
  +  channel_socket.init(): %s:%d \n, socketInfo-host, 
socketInfo-port );
   
   return rc;
   }
  @@ -502,7 +484,6 @@
   ch-_privatePtr= (jk_channel_socket_private_t *)
pool-calloc( env, pool, sizeof( jk_channel_socket_private_t));
   
  -ch-pool=pool;
   ch-recv= jk2_channel_socket_recv; 
   ch-send= jk2_channel_socket_send; 
   ch-init= jk2_channel_socket_init; 
  @@ -511,10 +492,12 @@
   
   ch-is_stream=JK_TRUE;
   
  -
   result-setAttribute= jk2_channel_socket_setAttribute; 
   result-object= ch;
   ch-mbean=result;
  -
  +
  +ch-workerEnv=env-getByName( env, workerEnv );
  +ch-workerEnv-addChannel( env, ch-workerEnv, ch );
  +
   return JK_TRUE;
   }
  
  
  

--
To unsubscribe, e-mail:   mailto:[EMAIL PROTECTED]
For additional commands, e-mail: mailto:[EMAIL 

cvs commit: jakarta-tomcat-connectors/jk/native2/common jk_channel_jni.c

2002-01-25 Thread costin

costin  02/01/25 22:55:17

  Modified:jk/native2/common jk_channel_jni.c
  Log:
  A number of bug fixes - make sure we save the global ref, not the ref.
  We now get an Endpoint from the java side - and cache/reuse it with the
  jni endpoint.
  
  The jni channel is 'interesting' - it's the first non-stream channel. It could
  be treated as a stream, by using 2 threads ( so send/receive model will work ),
  but I wanted to preserve 'single thread, no sync' model from the previous
  jni worker.
  
  It may seem a bit complicated - and it adds some limitations on the model, but
  I think it's worth it.
  
  The idea is that, as before, the first message ( containing the request ) gives
  control to tomcat who may send back messages ( and get back responses to it's
  messages ). The send() method in channel is doing exactly this first step.
  
  Tomcat will use a native method to send messages ( that replaces receive(),
  which is not used ), which are dispatched. The response is actually put in
  the same buffer - a single jarray pin is needed.
  
  We must make sure we don't run into buffer problems - but that can be resolved.
  
  Revision  ChangesPath
  1.2   +359 -52   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.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- jk_channel_jni.c  12 Jan 2002 04:59:19 -  1.1
  +++ jk_channel_jni.c  26 Jan 2002 06:55:17 -  1.2
  @@ -79,7 +79,7 @@
*/
   typedef struct {
   jk_vm_t *vm;
  -
  +
   char *className;
   jclass jniBridge;
   
  @@ -87,8 +87,15 @@
   } jk_channel_jni_private_t;
   
   typedef struct {
  -JNIEnv *env;
  +JNIEnv *jniEnv;
  +
  +int len;
  +jbyteArray jarray;
  +char *carray;
  +int arrayLen;
   
  +jobject epJ;
  +jobject msgJ;
   } jk_ch_jni_ep_private_t;
   
   
  @@ -105,6 +112,12 @@
   {
   int err;
   char *tmp;
  +
  +/* the channel is init-ed during a worker validation. If a jni worker
  +   is not already defined... well, not good. But on open we should
  +   have it.
  +*/
  +
   
   _this-worker=worker;
   _this-properties=props;
  @@ -113,7 +126,7 @@
 channel_jni.init():  %s\n, 
 worker-name );
   
  -return err;
  +return JK_TRUE;
   }
   
   /** Assume the jni-worker or someone else started
  @@ -125,12 +138,18 @@
   {
   jk_workerEnv_t *we=endpoint-worker-workerEnv;
   JNIEnv *jniEnv;
  +jk_ch_jni_ep_private_t *epData;
  +jmethodID jmethod;
  +jobject jobj;
   
   jk_channel_jni_private_t *jniCh=_this-_privatePtr;
  -
  -/** XXX make it customizable */
  -jniCh-className=JAVA_BRIDGE_CLASS_NAME;
   
  +if( endpoint-channelData != NULL ) {
  +env-l-jkLog(env, env-l, JK_LOG_INFO,
  +  channel_jni.open() already open, nothing else to do\n); 
  +return JK_TRUE;
  +}
  +
   jniCh-vm=(jk_vm_t *)we-vm;
   
   jniEnv = (JNIEnv *)jniCh-vm-attach( env, jniCh-vm );
  @@ -139,19 +158,84 @@
 channel_jni.open() can't attach\n ); 
   return JK_FALSE;
   }
  +/* Create the buffers used by the write method. We allocate a
  +   byte[] and jbyte[] - I have no idea what's more expensive,
  +   to copy a buffer or to 'pin' the jbyte[] for copying.
  +
  +   This will be tuned if needed, for now it seems the easiest
  +   solution
  +*/
  +epData=(jk_ch_jni_ep_private_t *)
  +endpoint-pool-calloc( env,endpoint-pool,
  +sizeof( jk_ch_jni_ep_private_t ));
   
  +endpoint-channelData=epData;
  +/** XXX make it customizable */
  +jniCh-className=JAVA_BRIDGE_CLASS_NAME;
  +
   jniCh-jniBridge =
   (*jniEnv)-FindClass(jniEnv, jniCh-className );
   
  +jniCh-jniBridge=(*jniEnv)-NewGlobalRef( jniEnv, jniCh-jniBridge);
  +
   if( jniCh-jniBridge == NULL ) {
   env-l-jkLog(env, env-l, JK_LOG_INFO,
 channel_jni.open() can't find %s\n,jniCh-className ); 
   return JK_FALSE;
   }
  -
  - jniCh-writeMethod =
  +
  +jmethod=(*jniEnv)-GetStaticMethodID(jniEnv, jniCh-jniBridge,
  + createEndpointStatic, (JJ)Lorg/apache/jk/core/Endpoint;);
  +if( jmethod == NULL ) {
  +env-l-jkLog(env, env-l, JK_LOG_INFO,
  +  channel_jni.open() can't find createEndpointStatic\n); 
  +return JK_FALSE;
  +}
  +jobj=(*jniEnv)-CallStaticObjectMethod( jniEnv, jniCh-jniBridge,
  +   jmethod,
  +   (jlong)(long)(void *)env,
  +

cvs commit: jakarta-tomcat-connectors/jk/native2/common jk_channel_jni.c

2002-01-11 Thread costin

costin  02/01/11 20:59:19

  Added:   jk/native2/common jk_channel_jni.c
  Log:
  I'm changing the way the jni worker operates, to use the same code
  as ajp.
  
  Making enhancements to jni and ajp in parallel is too difficult, and the current
  jni code has some problems - it's using strings ( possible with the wrong encoding,
  the right one might be in the session or some headers ). It's also difficult
  to recycle, etc.
  
  In future we can go back to using method calls, but just sending buffers
  is much simpler and may be much faster too.
  
  ( not working yet )
  
  Revision  ChangesPath
  1.1  jakarta-tomcat-connectors/jk/native2/common/jk_channel_jni.c
  
  Index: jk_channel_jni.c
  ===
  /* = *
   *   *
   * The Apache Software License,  Version 1.1 *
   *   *
   *  Copyright (c) 1999-2001 The Apache Software Foundation.  *
   *   All rights reserved.*
   *   *
   * = *
   *   *
   * Redistribution and use in source and binary forms,  with or without modi- *
   * fication, are permitted provided that the following conditions are met:   *
   *   *
   * 1. Redistributions of source code  must retain the above copyright notice *
   *notice, this list of conditions and the following disclaimer.  *
   *   *
   * 2. Redistributions  in binary  form  must  reproduce the  above copyright *
   *notice,  this list of conditions  and the following  disclaimer in the *
   *documentation and/or other materials provided with the distribution.   *
   *   *
   * 3. The end-user documentation  included with the redistribution,  if any, *
   *must include the following acknowlegement: *
   *   *
   *   This product includes  software developed  by the Apache  Software *
   *Foundation http://www.apache.org/.  *
   *   *
   *Alternately, this acknowlegement may appear in the software itself, if *
   *and wherever such third-party acknowlegements normally appear. *
   *   *
   * 4. The names  The  Jakarta  Project,  Jk,  and  Apache  Software *
   *Foundation  must not be used  to endorse or promote  products derived *
   *from this  software without  prior  written  permission.  For  written *
   *permission, please contact [EMAIL PROTECTED].*
   *   *
   * 5. Products derived from this software may not be called Apache nor may *
   *Apache appear in their names without prior written permission of the *
   *Apache Software Foundation.*
   *   *
   * THIS SOFTWARE IS PROVIDED AS IS AND ANY EXPRESSED OR IMPLIED WARRANTIES *
   * INCLUDING, BUT NOT LIMITED TO,  THE IMPLIED WARRANTIES OF MERCHANTABILITY *
   * AND FITNESS FOR  A PARTICULAR PURPOSE  ARE DISCLAIMED.  IN NO EVENT SHALL *
   * THE APACHE  SOFTWARE  FOUNDATION OR  ITS CONTRIBUTORS  BE LIABLE  FOR ANY *
   * DIRECT,  INDIRECT,   INCIDENTAL,  SPECIAL,  EXEMPLARY,  OR  CONSEQUENTIAL *
   * DAMAGES (INCLUDING,  BUT NOT LIMITED TO,  PROCUREMENT OF SUBSTITUTE GOODS *
   * OR SERVICES;  LOSS OF USE,  DATA,  OR PROFITS;  OR BUSINESS INTERRUPTION) *
   * HOWEVER CAUSED AND  ON ANY  THEORY  OF  LIABILITY,  WHETHER IN  CONTRACT, *
   * STRICT LIABILITY, OR TORT  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN *
   * ANY  WAY  OUT OF  THE  USE OF  THIS  SOFTWARE,  EVEN  IF  ADVISED  OF THE *
   * POSSIBILITY OF SUCH DAMAGE.   *
   *   *
   * = *
   *   *
   * This software  consists of voluntary  contributions made  by many indivi- *