Commits

Armin Rigo committed 983af03

Move 'd->active = 0' a bit earlier. This should be enough to ensure the new comment.

  • Participants
  • Parent commits 698910c

Comments (0)

Files changed (2)

   stm_thread_local_obj = d->old_thread_local_obj;
   d->old_thread_local_obj = NULL;
 
+  // notifies the CPU that we're potentially in a spin loop
+  SpinLoop(SPLP_ABORT);
+
+  /* make the transaction no longer active */
+  d->active = 0;
+  d->atomic = 0;
+
   /* release the lock */
   spinlock_release(d->public_descriptor->collection_lock);
 
   if (num != ABRT_MANUAL && d->max_aborts >= 0 && !d->max_aborts--)
     stm_fatalerror("unexpected abort!\n");
 
-  // notifies the CPU that we're potentially in a spin loop
-  SpinLoop(SPLP_ABORT);
   // jump back to the setjmp_buf (this call does not return)
-  d->active = 0;
-  d->atomic = 0;
   stm_stop_sharedlock();
   longjmp(*d->setjmp_buf, 1);
 }
 void stm_invoke_callbacks_on_abort(struct tx_descriptor *d)
 {
     wlog_t *item;
+    assert(d->active == 0);
+
     G2L_LOOP_FORWARD(d->callbacks_on_abort, item) {
         void *key = (void *)item->addr;
         void (*callback)(void *) = (void(*)(void *))item->val;
         assert(key != NULL);
         assert(callback != NULL);
 
+        /* The callback may call stm_call_on_abort(key, NULL).
+           It is ignored, because we're no longer active. */
         callback(key);
 
     } G2L_LOOP_END;