Menu

#49 wrapper hangs after ctrl-c

v3.1.0
closed-fixed
5
2004-07-21
2004-05-17
No

The wrapper is launched via WrapperManager.start() in
my Main class (see below). After pressing CTRL-c my
shutdown processing code gets called nicely, then the
Wrapper says "Wrapper Manager: Unable to unregister
shutdown hook: null" and hangs.

Debug session follows (the lines marked by * were
printed by me):
================
*(some messages from my code)
returned from listener.start()
Send a packet STARTED :
Got Control Signal 0->200
Handled signal
Processing control event(WRAPPER_CTRL_C_EVENT)
WrapperManager.stop(0) called by thread: Wrapper-
Control-Event-Monitor
Send a packet STOP : 0
Thread, Wrapper-Control-Event-Monitor, handling the
shutdown process.
calling listener.stop()
*(some shutdown messages from my code)
Wrapper Manager: ShutdownHook started
16:47:40.710 EVENT Stopped
org.mortbay.http.HttpServer@186fab
WrapperManager.stop(0) called by thread: Wrapper-
Shutdown-Hook
returned from listener.stop()
Wrapper Manager: Unable to unregister shutdown hook:
null
Send a packet STOPPED : 0
calling System.exit(0)
Thread, Wrapper-Shutdown-Hook, waiting for the JVM to
exit.
===================

The code from my Main.java

public static void main(String[] args){
WrapperManager.start(new WrapperListener(){
public void controlEvent(int event){
Main.controlEvent(event);
}
public Integer start(String[] args){
return Main.start(args);
}
public int stop(int exitCode){
return Main.stop(exitCode);
}
}, args);
}

private static Integer start( String[] args ){
try{
app=Application.instance();
return null;
}
catch(Exception e){
e.printStackTrace();
return new Integer(1);
}
}

private static int stop(int exitCode){
try{
app.shutdown();
return exitCode;
}
catch(Exception e){
e.printStackTrace();
return 1;
}
}

private static void controlEvent(int event){
if(WrapperManager.isControlledByNativeWrapper()){
//The Wrapper will take care of this event
}
else{
//We are not being controlled by the Wrapper, so
//handle the event ourselves.
if
((event==WrapperManager.WRAPPER_CTRL_C_EVENT) ||
(event ==
WrapperManager.WRAPPER_CTRL_CLOSE_EVENT) ||
(event ==
WrapperManager.WRAPPER_CTRL_SHUTDOWN_EVENT)){
WrapperManager.stop(0);
}
}
}

Discussion

  • Sergey A. Samokhodkin

    Logged In: YES
    user_id=367459

    Forgot to say: this happens about 2 times of 3. Looks like a
    thread synchronization issue.

     
  • Leif Mortenson

    Leif Mortenson - 2004-06-15
    • milestone: 335160 -->
     
  • Leif Mortenson

    Leif Mortenson - 2004-06-15
    • labels: --> Integration
    • milestone: --> v3.1.0
    • assigned_to: nobody --> mortenson
    • status: open --> open-fixed
     
  • Leif Mortenson

    Leif Mortenson - 2004-06-15

    Logged In: YES
    user_id=228081

    I was finally able to reproduce this by calling System.exit
    from a thread launched within a call to
    WrapperListener.stop. I am not sure what is happening in
    your call to app.shutdown(). But is it possible that that
    is what is happening.

    The problem is that the call to System.exit was causing the
    Wrapper's shutdown hook to be triggered after
    WrapperListener.stop was called. The Wrapper was not
    expecting this and continued on to unregister the shutdown
    hook. It is not possible to do so once a shutdown hook has
    been started.

    The fix here was to rework the way shutdown hooks are
    handled on shutdown. I also went through and cleaned up
    the error messages a bit so that they will provide more
    useful information should something like this be encountered
    again.

    I need to get another issue cleaned up first, but I will
    post back again with a link to a development build. If
    possible, I would appreciate it if you could test it out
    before the next release.

    Cheers,
    Leif

     
  • Leif Mortenson

    Leif Mortenson - 2004-07-21

    Logged In: YES
    user_id=228081

    Never heard back from you so closing this off. 3.1.1 was
    released today with this fix. Please let me know if you are
    still experiencing problems.

    Cheers,
    Leif

     
  • Leif Mortenson

    Leif Mortenson - 2004-07-21
    • status: open-fixed --> closed-fixed
     

Log in to post a comment.

MongoDB Logo MongoDB