Java Solaris Communities Sun Store Join SDN My Profile Why Join?
 
Bug Database
Bug Detail
Quick Lists
Top 25 Bugs
Top 25 RFE's
Recently Closed Bugs
Printable Page Printable Page


Bug Database
Bug ID: 4770518
Votes 1
Synopsis Windows service terminates on logout
Category jmq:broker
Reported Against 3.0.1
Release Fixed 3.0.1sp2, 3.5(raptor_dev1) (Bug ID:2060464)
State 11-Closed, Unverified, bug
Priority: 4-Low
Related Bugs 4323062 , 4780224 , 6157943
Submit Date 29-OCT-2002
Description
Logon as administrator. Start the service. Log off. Log back on.
Service is no longer running.
Work Around
  xxxxx@xxxxx   2003-01-07
Stop the service. 
Then remove it and install it specifying "-vmargs -Xrs":

cd <install location>\bin
imqsvcadmin remove
imqsvcadmin install -vmargs -Xrs

You can then use "imqsvcadmin query" to verify that VM Args is -Xrs

Start the service.

You should now be able to log out and the service stays up.
Evaluation
We've reproduced this on Windows 2000 and NT.

Here is what we know:

- We run the broker's JVM in a process external to the service wrapper.
- When a system is booted the MQ service is started as expected
  and all is well.
- When administrator logs in all is still AOK
- When administrator logs off it looks like:
    1. The service is NOT notified with a STOP or SHUTDOWN.
       This is as expected.
    2. The JVM is terminated (the broker's JVM shutdown hooks are called).
       This is not expected.

So it looks to me like Windows 2000 is killing the JVM process when
administrator logs off -- probably because it doesn't think it is a
"service", even though it is the child of a service process.

One tip we've heard from another project is that the service should
call 

SetConsoleCtrlHandler(LogOffHandler, TRUE);

Where LogOffHandler looks something like:

// Handles the logoff, crtl+c, and ctrl+break signals
// For now always return true if logoff event.
// Doing so bypasses the default behavior (kill -9) 
BOOL WINAPI LogOffHandler(DWORD dwCtrlType) {
    switch(dwCtrlType)
    {
        case CTRL_LOGOFF_EVENT:
            LogError("Got CTRL_LOGOFF_EVENT");
            return TRUE;
        case CTRL_C_EVENT:
        case CTRL_BREAK_EVENT:
        case CTRL_CLOSE_EVENT:
        case CTRL_SHUTDOWN_EVENT:
        default:
            return FALSE;
            break;
    }
}

Unfortunately we've been told this may only prevent shutdown if the process
is running as an NT service. Since our JVM is forked, even if we added native
code to do the above, it may get terminated anyway.

The write answer here is to embed the JVM in the service using JNI.

  xxxxx@xxxxx   2003-01-07
Turns out most of this problem is caused by NOT passing the -Xrs flag to the
JVM. See JVM bug 4323062. A quick test I tried verified that if I set this
(using the -vmargs option to imqsvcadmin -- see Work Around) the broker
does not exit. We need to fix this in the code. We don't need to embed the
JVM to fix this (although there may be other reasons to do so). I need to 
verify if setting the ConsoleCtrlHandler is really necessary -- it doesn't
appear to be at first glance.


  xxxxx@xxxxx   2003-02-04
I've changed the service wrapper to pass -Xrs to the JVM when we are started
as a service. Registering a ConsoleCtrlHandler does not appear to be 
necessary. This has been checked into Raptor (3.5), and appears to take
care of the problem.




Comments
  
  Include a link with my name & email   

Submitted On 12-DEC-2002
chris.rimmer
See also Bug Id 4323062, and the -Xrs flag.



PLEASE NOTE: JDK6 is formerly known as Project Mustang