GDB: No longer synchronize on a string.
authorMatthew Khouzam <matthew.khouzam@ericsson.com>
Wed, 16 Sep 2015 20:49:37 +0000 (16:49 -0400)
committerMatthew Khouzam <matthew.khouzam@ericsson.com>
Fri, 18 Sep 2015 00:40:37 +0000 (20:40 -0400)
This is dangerous for two reasons:
1- if the string value changes, the object changes too, so we can
corrupt data.
2- if the string is internalized, it can cause unwanted delays with
other objects synchronizing coincidentally on the same string.

Change-Id: Ibfeb3702ef82424b2fca86956f8227b52ae8b945
Signed-off-by: Matthew Khouzam <matthew.khouzam@ericsson.com>
Reviewed-on: https://git.eclipse.org/r/56133
Reviewed-by: Hudson CI
Reviewed-by: Patrick Tasse <patrick.tasse@gmail.com>
Tested-by: Patrick Tasse <patrick.tasse@gmail.com>
gdbtrace/org.eclipse.tracecompass.gdbtrace.core/src/org/eclipse/tracecompass/internal/gdbtrace/core/trace/DsfGdbAdaptor.java

index 5512b20a710ec68f48f7e6bc3223ac51a6ca0726..a29855f6f1b8ef183b15a7ac3ad3094e35bde8a8 100644 (file)
@@ -116,6 +116,8 @@ import org.eclipse.ui.ide.IDE;
 @SuppressWarnings("restriction")
 public class DsfGdbAdaptor {
 
+    private static final Object SESSION_LOCK = new Object();
+
     private GdbTrace fGdbTrace;
 
     private int fNumberOfFrames = 0;
@@ -203,13 +205,13 @@ public class DsfGdbAdaptor {
                         IDMContext context = (IDMContext) contextObject;
                         if (context != null) {
                             String sessionId;
-                            synchronized(fCurrentSessionId) {
+                            synchronized(SESSION_LOCK) {
                                 sessionId = context.getSessionId();
                                 if (sessionId.equals(fCurrentSessionId)) {
                                     return;
                                 }
+                                fCurrentSessionId = sessionId;
                             }
-                            fCurrentSessionId = sessionId;
                             // Get the current trace record
                             final DsfExecutor executor = DsfSession.getSession(sessionId).getExecutor();
                             final DsfServicesTracker tracker = new DsfServicesTracker(GdbTraceCorePlugin.getBundleContext(), sessionId);
This page took 0.027749 seconds and 5 git commands to generate.