You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@netbeans.apache.org by ne...@apache.org on 2022/02/02 10:08:44 UTC

[netbeans] branch delivery updated: [NETBEANS-6177] Fix an issue the stop command is not sent

This is an automated email from the ASF dual-hosted git repository.

neilcsmith pushed a commit to branch delivery
in repository https://gitbox.apache.org/repos/asf/netbeans.git


The following commit(s) were added to refs/heads/delivery by this push:
     new 582c2c5  [NETBEANS-6177] Fix an issue the stop command is not sent
     new 3ff1e3d  Merge pull request #3549 from junichi11/netbeans-6177-xdebug
582c2c5 is described below

commit 582c2c57d1e053833e7dafc7aedf34abc3b70187
Author: Junichi Yamamoto <ju...@apache.org>
AuthorDate: Wed Feb 2 13:36:28 2022 +0900

    [NETBEANS-6177] Fix an issue the stop command is not sent
    
    - https://issues.apache.org/jira/browse/NETBEANS-6177
    - Related to NETBEANS-5080
    - Use the `canceled` field instead of `detachRequest.set(true)` because
    the stop command is not sent in `sendStopCommand()` if `detacheRequest` is `true`
---
 .../src/org/netbeans/modules/php/dbgp/DebugSession.java | 17 ++++++++++++++---
 .../org/netbeans/modules/php/dbgp/SessionManager.java   | 10 +++++-----
 2 files changed, 19 insertions(+), 8 deletions(-)

diff --git a/php/php.dbgp/src/org/netbeans/modules/php/dbgp/DebugSession.java b/php/php.dbgp/src/org/netbeans/modules/php/dbgp/DebugSession.java
index bbc3db5..f39b279 100644
--- a/php/php.dbgp/src/org/netbeans/modules/php/dbgp/DebugSession.java
+++ b/php/php.dbgp/src/org/netbeans/modules/php/dbgp/DebugSession.java
@@ -78,6 +78,7 @@ public class DebugSession extends SingleThread {
     private AtomicReference<DebuggerEngine> engine;
     private IDESessionBridge myBridge;
     private AtomicReference<String> myFileName;
+    private volatile boolean canceled;
 
     DebugSession(DebuggerOptions options, BackendLauncher backendLauncher) {
         commands = new LinkedList<>();
@@ -124,6 +125,14 @@ public class DebugSession extends SingleThread {
                 } catch (Throwable e) {
                     log(e, Level.SEVERE);
                 }
+                if (canceled) {
+                    synchronized (commands) {
+                        if (commands.isEmpty()) {
+                            detachRequest.set(true);
+                            stop();
+                        }
+                    }
+                }
             }
         } finally {
             postprocess();
@@ -133,7 +142,9 @@ public class DebugSession extends SingleThread {
     private void preprocess() {
         detachRequest.set(false);
         stopRequest.set(false);
-        commands.clear();
+        synchronized (commands) {
+            commands.clear();
+        }
         sessionId.set(null);
         myBridge = new IDESessionBridge();
         myFileName = new AtomicReference<>();
@@ -325,14 +336,14 @@ public class DebugSession extends SingleThread {
 
     @Override
     public boolean cancel() {
-        // NETBEANS-5080 detach the request
+        // NETBEANS-5080 request cancellation
         // startProcessing() may be called via other ways
         // e.g. via command line: nc -vz localhost 9003(debugger port)
         // First of all, get the socket after the above command is run
         // See: Socket sessionSocket = myServer.accept(); in ServerThread.run()
         // Then, invokeLater.get() is called in startProcessing()
         // Finally, infinite loop occurs in run() becuase do not still receive anything
-        detachRequest.set(true);
+        canceled = true;
         return true;
     }
 
diff --git a/php/php.dbgp/src/org/netbeans/modules/php/dbgp/SessionManager.java b/php/php.dbgp/src/org/netbeans/modules/php/dbgp/SessionManager.java
index 9fc0f60..d6c086b 100644
--- a/php/php.dbgp/src/org/netbeans/modules/php/dbgp/SessionManager.java
+++ b/php/php.dbgp/src/org/netbeans/modules/php/dbgp/SessionManager.java
@@ -101,11 +101,6 @@ public class SessionManager {
 
     public synchronized void stopSession(Session session) {
         SessionId id = session.lookupFirst(null, SessionId.class);
-        // NETBEANS-5080 detach the request of the debug session to finish the task
-        DebugSession debugSession = session.lookupFirst(null, DebugSession.class);
-        if (debugSession != null) {
-            debugSession.cancel();
-        }
         DebugSession debSess = getSession(id);
         if (debSess != null) {
             debSess.stopSession();
@@ -122,6 +117,11 @@ public class SessionManager {
         }
         SessionManager.closeServerThread(session);
         resetBreakpoints();
+        // NETBEANS-5080 request cancellation to finish the task
+        DebugSession debugSession = session.lookupFirst(null, DebugSession.class);
+        if (debugSession != null) {
+            debugSession.cancel();
+        }
     }
 
     public static SessionId getSessionId(Project project) {

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@netbeans.apache.org
For additional commands, e-mail: commits-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists