[pypy-commit] stmgc default: stm_wait_for_current_inevitable_transaction is actually used from outside

Raemi noreply at buildbot.pypy.org
Wed Apr 1 15:57:43 CEST 2015


Author: Remi Meier <remi.meier at inf.ethz.ch>
Branch: 
Changeset: r1745:1062987da64f
Date: 2015-04-01 15:58 +0200
http://bitbucket.org/pypy/stmgc/changeset/1062987da64f/

Log:	stm_wait_for_current_inevitable_transaction is actually used from
	outside transactions, make sure nobody messes with the commit log
	during that time.

diff --git a/c8/stm/sync.c b/c8/stm/sync.c
--- a/c8/stm/sync.c
+++ b/c8/stm/sync.c
@@ -105,18 +105,25 @@
 
 void stm_wait_for_current_inevitable_transaction(void)
 {
+ restart:
+    /* make sure there is no major collection happening, which
+       could free some commit log entries */
+    s_mutex_lock();
+
     struct stm_commit_log_entry_s *current = STM_PSEGMENT->last_commit_log_entry;
 
     /* XXX: don't do busy-waiting */
-    while (1) {
-        if (current->next == NULL) {
-            break;
-        } else if (current->next == INEV_RUNNING) {
+    while (current->next != NULL) {
+        if (current->next == INEV_RUNNING) {
+            s_mutex_unlock();
             usleep(10);
-            continue;
+            /* some major collection could have freed "current", so
+               restart from the beginning */
+            goto restart;
         }
         current = current->next;
     }
+    s_mutex_unlock();
 }
 
 


More information about the pypy-commit mailing list