Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [Dltk-dev] can somebody explain to me the 2 IDbgpTermination and IDbgpTerminationListener

Johan,

Yes, you are correct - all the "termination" logic looks strange.
We would like to fix it before 1.0 is released.

I believe we should move most of the logic into the DbgpTermination class and simplify code its descendants.

Alex


Johan Compagner wrote:
Because what method should exactly do what??

for example we have the DbgpDebugingEngine
that implements both

IDbgpTerminationListener:
  void objectTerminated(Object object, Exception e);


IDbgpTermination:
    void addTerminationListener(IDbgpTerminationListener listener);

    void removeTerminationListener(IDbgpTerminationListener listener);

    void requestTermination();

    void waitTerminated() throws InterruptedException;


The problem is that in DbgpDebugingEngine
the socket.close() is called in

    public void requestTermination() {
        synchronized (terminatedLock) {
            if (terminated) {
                return;
            }
            socket.close()

But that boolean terminated is set in:

public void objectTerminated(Object object, Exception e) {
        synchronized (terminatedLock) {
            if (terminated)
                return;
receiver.removeTerminationListener(this);
            try {
                receiver.waitTerminated();
            } catch (InterruptedException e1) {
                // OK, interrupted
            }

            terminated = true;
        }

and that is called before requestTermination() (at least in the situations i am in now) so socket.close() isnt called. So my debug client still thinks it is connected...


So should socket.close() be called in objectTerminated()
or should requestTermination not look at that terminated flag at all?
because they are not really really related both are from different interfaces (behaviors)

the simple fix i can think of is this:

    public void requestTermination() {
        try {
            socket.close();
        } catch (IOException e) {
            // TODO: log exception
            e.printStackTrace();
        }
    }


But that code is a bit wired in each other that dont really know what is the head or what is the tail.... :(

johan



------------------------------------------------------------------------

_______________________________________________
dltk-dev mailing list
dltk-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/dltk-dev


Back to the top