www-apache-bugdb mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Vladislav Malyshkin <...@mail1.nai.net>
Subject Re: mod_jserv/5755: mod_jserv and httpd -HUP restarting problem
Date Tue, 15 Feb 2000 15:30:00 GMT
The following reply was made to PR mod_jserv/5755; it has been noted by GNATS.

From: Vladislav Malyshkin <mal@mail1.nai.net>
To: Ed Korthof <ed@cloudfactory.org>, apbugs@apache.org
Cc:  
Subject: Re: mod_jserv/5755: mod_jserv and httpd -HUP restarting problem
Date: Tue, 15 Feb 2000 10:23:39 -0500

 This is a new patch which also fixes a problem
 with races when a signal is delivered during processing a signal.
 (It leaded to error messages in log that JSern is not responding)
 Vladislav
 
  diff -u jserv_wrapper_unix.c.orig jserv_wrapper_unix.c
 --- jserv_wrapper_unix.c.orig   Mon Feb 14 16:16:11 2000
 +++ jserv_wrapper_unix.c        Tue Feb 15 10:15:27 2000
 @@ -98,10 +98,12 @@
  /* this is also used from the loop to kill JVM                               */
  void kill_hung_jvm(int signum) {
    int counter = 0;
 +  const int jvm_pid_local=jvm_pid;
 
    /* Is jvm is really started? If not - do nothing */
 -  if( jvm_pid == 0)
 +  if( jvm_pid_local == 0)
      return;
 +  jvm_pid=0;
 
    if( signum == 0) {
      jserv_error(JSERV_LOG_INFO, wrapper_data->config,
 @@ -112,18 +114,17 @@
    }
    /* IF JVM is not responding to connections, we can't do   *
     * anything but kill it.                                  */
 -  kill(jvm_pid, SIGTERM);
 +  kill(jvm_pid_local, SIGTERM);
 
    /* give the VM as long as five seconds to die gracefully */
    while (counter++ < 5) {
 -    if (waitpid(jvm_pid, NULL, WNOHANG) > 0)
 +    if (waitpid(jvm_pid_local, NULL, WNOHANG) > 0)
        break;
      sleep(1);
    }
 -  if( waitpid(jvm_pid,NULL,WNOHANG)==0 ) {
 -    kill(jvm_pid, SIGKILL);
 +  if( waitpid(jvm_pid_local,NULL,WNOHANG)==0 ) {
 +    kill(jvm_pid_local, SIGKILL);
    }
 -  jvm_pid=0;
  }
 
 
 @@ -362,6 +363,12 @@
                             jvm_pid = 0;
                         }
 
 +    /* If we get a TERM signal, shut down the JVM nicely, then exit.
 +     */
 +    signal(SIGTERM, wrapper_shutdown);
 +    signal(SIGHUP, wrapper_shutdown);
 +
 +
 
                         /* install SIGALARM handler to implement a timeout in communication
*/
                         /* NOTE: As it is installed in each loop, it should work with SYSV
signal()*/
 @@ -477,30 +484,32 @@
  /* ========================================================================= */
  /* This does the actual cleanup */
  int wrapper_shutdown_core(wrapper_config *cfg) {
 -    if (jvm_pid != 0) {
 +  const int jvm_pid_local=jvm_pid;
 +    if (jvm_pid_local != 0) {
          int counter = 0;
 +        jvm_pid=0;
          jserv_error(JSERV_LOG_INFO,wrapper_data->config,
                      "wrapper: Terminating JServ (PID=%d, VM PID=%d)",
 -                    getpid(), jvm_pid);
 +                    getpid(), jvm_pid_local);
          /* Send shutdown function */
          jserv_protocol_function(cfg->config->protocol,cfg->config,
                                  JSERV_SHUTDOWN,NULL);
          /* Wait for child to go down */
 -        while (waitpid(jvm_pid,NULL,WNOHANG)==0) {
 +        while (waitpid(jvm_pid_local,NULL,WNOHANG)==0) {
              /* give it a little while to shut down gracefully. Then kill it. */
              if (++counter > cfg->config->vmtimeout) {
                  jserv_error(JSERV_LOG_EMERG, wrapper_data->config,
                              "wrapper: JServ (%d) didn't die nicely, killing it",
 -                            jvm_pid);
 -                kill(jvm_pid, SIGTERM); /* give the process a chance to die */
 +                            jvm_pid_local);
 +                kill(jvm_pid_local, SIGTERM); /* give the process a chance to die */
                  counter = 0;
                  while (counter++ < 3) {
 -                    if (waitpid(jvm_pid, NULL, WNOHANG) > 0)
 +                    if (waitpid(jvm_pid_local, NULL, WNOHANG) > 0)
                          return 0;
                      sleep(1);
                  }
 -                if( waitpid(jvm_pid,NULL,WNOHANG)==0 ) {
 -                    kill(jvm_pid, SIGKILL);
 +                if( waitpid(jvm_pid_local,NULL,WNOHANG)==0 ) {
 +                    kill(jvm_pid_local, SIGKILL);
                  }
              }
              sleep(1);
 
 

Mime
View raw message