Bug 622691 followup: invert statement order in AutoUnlockDefaultCompartment to get update inside lock, r=gal, a=blocking
authorDavid Mandelin <dmandelin@mozilla.com>
Thu, 06 Jan 2011 11:30:15 -0800
changeset 60226 aa2cb417ef96503b312652e7e8d262ebe8219c39
parent 60225 7558dc118df513a41cbed1da33027eea0d09a87f
child 60227 11362bbb1bfa028bf3a83db7b9555fb949163183
push idunknown
push userunknown
push dateunknown
reviewersgal, blocking
bugs622691
milestone2.0b9pre
Bug 622691 followup: invert statement order in AutoUnlockDefaultCompartment to get update inside lock, r=gal, a=blocking
js/src/jscntxt.h
--- a/js/src/jscntxt.h
+++ b/js/src/jscntxt.h
@@ -2672,26 +2672,26 @@ class AutoLockDefaultCompartment {
     }
 };
 
 class AutoUnlockDefaultCompartment {
   private:
       JSContext *cx;
   public:
     AutoUnlockDefaultCompartment(JSContext *cx) : cx(cx) {
-        JS_UNLOCK(cx, &cx->runtime->atomState.lock);
 #ifdef JS_THREADSAFE
         cx->runtime->defaultCompartmentIsLocked = false;
 #endif
+        JS_UNLOCK(cx, &cx->runtime->atomState.lock);
     }
     ~AutoUnlockDefaultCompartment() {
+        JS_LOCK(cx, &cx->runtime->atomState.lock);
 #ifdef JS_THREADSAFE
         cx->runtime->defaultCompartmentIsLocked = true;
 #endif
-        JS_LOCK(cx, &cx->runtime->atomState.lock);
     }
 };
 
 class AutoKeepAtoms {
     JSRuntime *rt;
   public:
     explicit AutoKeepAtoms(JSRuntime *rt) : rt(rt) { JS_KEEP_ATOMS(rt); }
     ~AutoKeepAtoms() { JS_UNKEEP_ATOMS(rt); }