summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKenneth Russel <[email protected]>2006-05-11 02:39:05 +0000
committerKenneth Russel <[email protected]>2006-05-11 02:39:05 +0000
commit909a78b2d82052bd5cc5f39a9be665e6dc184982 (patch)
tree4aecd5fadbd6b7d4dacfc9df43bf40dfafc4ef3c /src
parentcc1afd96c4d1eea321489d160e2fd0f7a58f458e (diff)
Fixed apparent deadlock in object tracking code provoked by GE Medical
Systems' demo by removing synchronization around one part of the code git-svn-id: file:///usr/local/projects/SUN/JOGL/git-svn/svn-server-sync/jogl/trunk@761 232f8b59-042b-4e1e-8c03-345bb8c30851
Diffstat (limited to 'src')
-rw-r--r--src/classes/com/sun/opengl/impl/GLContextShareSet.java98
1 files changed, 53 insertions, 45 deletions
diff --git a/src/classes/com/sun/opengl/impl/GLContextShareSet.java b/src/classes/com/sun/opengl/impl/GLContextShareSet.java
index 293402899..f2c015762 100644
--- a/src/classes/com/sun/opengl/impl/GLContextShareSet.java
+++ b/src/classes/com/sun/opengl/impl/GLContextShareSet.java
@@ -157,51 +157,57 @@ public class GLContextShareSet {
creation of the new context (which is the second argument)
before any server-side OpenGL objects have been created in that
context. */
- public static synchronized void registerForObjectTracking(GLContext olderContextOrNull,
- GLContext newContext,
- GLContext realShareContext) {
+ public static void registerForObjectTracking(GLContext olderContextOrNull,
+ GLContext newContext,
+ GLContext realShareContext) {
if (isObjectTrackingEnabled() || isObjectTrackingDebuggingEnabled()) {
- if (olderContextOrNull != null &&
- newContext != null) {
- if (entryFor(olderContextOrNull) != entryFor(newContext)) {
- throw new IllegalArgumentException("old and new contexts must be able to share textures and display lists");
- }
- }
-
- // FIXME: downcast to GLContextImpl undesirable
- GLContextImpl impl1 = (GLContextImpl) olderContextOrNull;
- GLContextImpl impl2 = (GLContextImpl) newContext;
+ GLContextImpl impl1 = null;
+ GLContextImpl impl2 = null;
GLObjectTracker tracker = null;
- GLObjectTracker deletedObjectTracker = null;
- GLContextImpl shareImpl = (GLContextImpl) realShareContext;
- // Before we zap the "user-level" object trackers, make sure
- // that all contexts in the share set share the destroyed object
- // tracker
- if (shareImpl != null) {
- deletedObjectTracker = shareImpl.getDeletedObjectTracker();
- }
- if (deletedObjectTracker == null) {
- // Must create one and possibly set it up in the older context
- deletedObjectTracker = new GLObjectTracker();
- if (DEBUG) {
- System.err.println("Created deletedObjectTracker " + deletedObjectTracker + " because " +
- ((shareImpl == null) ? "shareImpl was null" : "shareImpl's (" + shareImpl + ") deletedObjectTracker was null"));
+ synchronized (GLContextShareSet.class) {
+ if (olderContextOrNull != null &&
+ newContext != null) {
+ if (entryFor(olderContextOrNull) != entryFor(newContext)) {
+ throw new IllegalArgumentException("old and new contexts must be able to share textures and display lists");
+ }
}
+ // FIXME: downcast to GLContextImpl undesirable
+ impl1 = (GLContextImpl) olderContextOrNull;
+ impl2 = (GLContextImpl) newContext;
+
+ GLObjectTracker deletedObjectTracker = null;
+ GLContextImpl shareImpl = (GLContextImpl) realShareContext;
+ // Before we zap the "user-level" object trackers, make sure
+ // that all contexts in the share set share the destroyed object
+ // tracker
if (shareImpl != null) {
- // FIXME: think should really assert in this case
- shareImpl.setDeletedObjectTracker(deletedObjectTracker);
+ deletedObjectTracker = shareImpl.getDeletedObjectTracker();
+ }
+ if (deletedObjectTracker == null) {
+ // Must create one and possibly set it up in the older context
+ deletedObjectTracker = new GLObjectTracker();
if (DEBUG) {
- System.err.println("Set deletedObjectTracker " + deletedObjectTracker + " in shareImpl context " + shareImpl);
+ System.err.println("Created deletedObjectTracker " + deletedObjectTracker + " because " +
+ ((shareImpl == null) ? "shareImpl was null" : "shareImpl's (" + shareImpl + ") deletedObjectTracker was null"));
+ }
+
+ if (shareImpl != null) {
+ // FIXME: think should really assert in this case
+ shareImpl.setDeletedObjectTracker(deletedObjectTracker);
+ if (DEBUG) {
+ System.err.println("Set deletedObjectTracker " + deletedObjectTracker + " in shareImpl context " + shareImpl);
+ }
}
}
- }
- impl2.setDeletedObjectTracker(deletedObjectTracker);
- if (DEBUG) {
- System.err.println("Set deletedObjectTracker " + deletedObjectTracker + " in impl2 context " + impl2);
+ impl2.setDeletedObjectTracker(deletedObjectTracker);
+ if (DEBUG) {
+ System.err.println("Set deletedObjectTracker " + deletedObjectTracker + " in impl2 context " + impl2);
+ }
}
+ // Must not hold lock around this operation
// Don't share object trackers with the primordial share context from Java2D
if (Java2D.isOGLPipelineActive()) {
// FIXME: probably need to do something different here
@@ -217,18 +223,20 @@ public class GLContextShareSet {
}
}
- if (impl1 != null) {
- tracker = impl1.getObjectTracker();
- assert (tracker != null)
- : "registerForObjectTracking was not called properly for the older context";
- }
- if (tracker == null) {
- tracker = new GLObjectTracker();
+ synchronized (GLContextShareSet.class) {
+ if (impl1 != null) {
+ tracker = impl1.getObjectTracker();
+ assert (tracker != null)
+ : "registerForObjectTracking was not called properly for the older context";
+ }
+ if (tracker == null) {
+ tracker = new GLObjectTracker();
+ }
+ // Note that we don't assert that the tracker is non-null for
+ // impl2 because the way we use this functionality we actually
+ // overwrite the initially-set object tracker in the new context
+ impl2.setObjectTracker(tracker);
}
- // Note that we don't assert that the tracker is non-null for
- // impl2 because the way we use this functionality we actually
- // overwrite the initially-set object tracker in the new context
- impl2.setObjectTracker(tracker);
}
}