Windows build fixes
[ghc-hetmet.git] / rts / win32 / AsyncIO.c
index 6fb9a2b..8662e2a 100644 (file)
@@ -12,7 +12,6 @@
 #include <windows.h>
 #include <stdio.h>
 #include "Schedule.h"
-#include "RtsFlags.h"
 #include "Capability.h"
 #include "win32/AsyncIO.h"
 #include "win32/IOManager.h"
@@ -275,8 +274,21 @@ start:
            unsigned int rID = completedTable[i].reqID;
            
            prev = NULL;
-           for(tso = blocked_queue_hd ; tso != END_TSO_QUEUE; prev = tso, tso = tso->_link) {
+           for(tso = blocked_queue_hd ; tso != END_TSO_QUEUE; tso = tso->_link) {
        
+                if (tso->what_next == ThreadRelocated) {
+                    /* Drop the TSO from blocked_queue */
+                    if (prev) {
+                        setTSOLink(&MainCapability, prev, tso->_link);
+                    } else {
+                        blocked_queue_hd = tso->_link;
+                    }
+                    if (blocked_queue_tl == tso) {
+                        blocked_queue_tl = prev ? prev : END_TSO_QUEUE;
+                    }
+                    continue;
+                }
+
                switch(tso->why_blocked) {
                case BlockedOnRead:
                case BlockedOnWrite:
@@ -311,6 +323,8 @@ start:
                    }
                    break;
                }
+
+                prev = tso;
            }
            /* Signal that there's completed table slots available */
            if ( !ReleaseSemaphore(completed_table_sema, 1, NULL) ) {