You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by pi...@apache.org on 2001/06/26 05:24:54 UTC

cvs commit: jakarta-tomcat-4.0/service/native java.c java.h jsvc-unix.c

pier        01/06/25 20:24:54

  Modified:    service/native java.c java.h jsvc-unix.c
  Log:
  Fixed bug preventing LINUX to executing a clean shutdown/reload.
  
  Revision  Changes    Path
  1.2       +23 -2     jakarta-tomcat-4.0/service/native/java.c
  
  Index: java.c
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-4.0/service/native/java.c,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- java.c	2001/06/26 01:37:06	1.1
  +++ java.c	2001/06/26 03:24:52	1.2
  @@ -55,7 +55,7 @@
    *                                                                           *
    * ========================================================================= */
   
  -/* @version $Id: java.c,v 1.1 2001/06/26 01:37:06 pier Exp $ */
  +/* @version $Id: java.c,v 1.2 2001/06/26 03:24:52 pier Exp $ */
   #include "jsvc.h"
   
   #include <jni.h>
  @@ -227,8 +227,29 @@
   }
   
   /* Destroy the Java VM */
  -bool java_destroy(void) {
  +bool java_destroy(int exit) {
  +    jclass system=NULL;
  +    jmethodID method;
  +
  +    system=(*env)->FindClass(env,"java/lang/System");
  +    if (system==NULL) {
  +        log_error("Cannot find class java/lang/System");
  +        return(false);
  +    }
  +
  +    method=(*env)->GetStaticMethodID(env,system,"exit","(I)V");
  +    if (method==NULL) {
  +        log_error("Cannot found \"System.exit(int)\" entry point");
  +        return(false);
  +    }
  +
  +    log_debug("Calling System.exit(%d)",exit);
  +    (*env)->CallStaticVoidMethod(env,cls,method,(jint)exit);
  +
  +    /* We shouldn't get here, but just in case... */
  +    log_debug("Destroying the Java VM");
       if ((*jvm)->DestroyJavaVM(jvm)!=0) return(false);
  +    log_debug("Java VM destroyed");
       return(true);
   }
   
  
  
  
  1.2       +2 -2      jakarta-tomcat-4.0/service/native/java.h
  
  Index: java.h
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-4.0/service/native/java.h,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- java.h	2001/06/26 01:37:16	1.1
  +++ java.h	2001/06/26 03:24:53	1.2
  @@ -55,13 +55,13 @@
    *                                                                           *
    * ========================================================================= */
   
  -/* @version $Id: java.h,v 1.1 2001/06/26 01:37:16 pier Exp $ */
  +/* @version $Id: java.h,v 1.2 2001/06/26 03:24:53 pier Exp $ */
   
   #define LOADER "org/apache/service/support/ServiceLoader"
   
   char *java_library(arg_data *args, home_data *data);
   bool java_init(arg_data *args, home_data *data);
  -bool java_destroy(void);
  +bool java_destroy(int exit);
   bool java_load(arg_data *args);
   bool java_start(void);
   bool java_stop(void);
  
  
  
  1.2       +8 -8      jakarta-tomcat-4.0/service/native/jsvc-unix.c
  
  Index: jsvc-unix.c
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-4.0/service/native/jsvc-unix.c,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- jsvc-unix.c	2001/06/26 01:37:25	1.1
  +++ jsvc-unix.c	2001/06/26 03:24:53	1.2
  @@ -55,7 +55,7 @@
    *                                                                           *
    * ========================================================================= */
   
  -/* @version $Id: jsvc-unix.c,v 1.1 2001/06/26 01:37:25 pier Exp $ */
  +/* @version $Id: jsvc-unix.c,v 1.2 2001/06/26 03:24:53 pier Exp $ */
   #include "jsvc.h"
   
   #include <signal.h>
  @@ -189,6 +189,7 @@
   static int child(arg_data *args, home_data *data, uid_t uid, gid_t gid) {
       FILE *pidf=fopen(args->pidf,"w");
       pid_t pidn=getpid();
  +    int ret=0;
   
       if (pidf!=NULL) {
           fprintf(pidf,"%d\n",(int)pidn);
  @@ -243,14 +244,13 @@
       /* Start the service */
       if (java_stop()!=true) return(6);
   
  -    /* Destroy the Java VM */
  -    if (java_destroy()!=true) return(7);
  +    if (doreload==true) ret=123;
  +    else ret=0;
   
  -    /* Remove PID file */
  -    unlink(args->pidf);
  +    /* Destroy the Java VM */
  +    if (java_destroy(ret)!=true) return(7);
   
  -    if (doreload==true) return(123);
  -    else return(0);
  +    return(ret);
   }
   
   int main(int argc, char *argv[]) {
  @@ -330,7 +330,7 @@
          will be the child */
       while ((pid=fork())!=-1) {
           /* We forked (again), if this is the child, we go on normally */
  -        if (pid==0) return(child(args,data,uid,gid));
  +        if (pid==0) exit(child(args,data,uid,gid));
   
           /* We are in the controller, we have to forward all interesting signals
              to the child, and wait for it to die */