oops - Win32OS does not yet support new select interface
authorClaus Gittinger <cg@exept.de>
Fri, 25 Jul 2003 22:00:45 +0200
changeset 7532 7612ff7ef377
parent 7531 4682ca752d27
child 7533 3d6e54708528
oops - Win32OS does not yet support new select interface
ProcessorScheduler.st
--- a/ProcessorScheduler.st	Fri Jul 25 21:29:13 2003 +0200
+++ b/ProcessorScheduler.st	Fri Jul 25 22:00:45 2003 +0200
@@ -2924,6 +2924,72 @@
         OperatingSystem unblockInterrupts.
     ].
 
+    OperatingSystem isMSWINDOWSlike ifTrue:[
+        "/ temporary kludge - until interface below is implemented in Win32OS
+        fd := OperatingSystem 
+                  selectOnAnyReadable:readFdArray 
+                  writable:writeFdArray
+                  exception:nil 
+                  withTimeOut:millis.
+        wasBlocked ifTrue:[
+            OperatingSystem blockInterrupts.
+        ].
+
+        fd isNil ifTrue:[
+            "/ either still nothing to do,
+            "/ or error (which should not happen)
+
+            (err := OperatingSystem lastErrorSymbol) notNil ifTrue:[
+                err == #EBADF ifTrue:[
+
+                    "/ mhmh - one of the fd's given to me is corrupt.
+                    "/ find out which one .... and remove it
+
+                    'Processor [info]: obsolete FD in select - clearing' infoPrintCR.
+                    OperatingSystem clearLastErrorNumber.
+                    self removeCorruptedFds
+                ] ifFalse:[
+                    err == #ENOENT ifTrue:[
+                        'Processor [warning]: ENOENT in select; rd=' infoPrint.
+                        readFdArray infoPrint.
+                        ' wr=' infoPrint.
+                        writeFdArray infoPrintCR.
+                    ] ifFalse:[
+                        'Processor [warning]: error in select: ' infoPrint. err infoPrintCR.
+                    ]
+                ].
+            ]
+        ] ifFalse:[
+            index := readFdArray identityIndexOf:fd.
+            index ~~ 0 ifTrue:[
+                sema := readSemaphoreArray at:index.
+                sema notNil ifTrue:[
+                    sema signalOnce.
+                    ^ true
+                ].
+                action := readCheckArray at:index.
+                action notNil ifTrue:[
+                    action value.
+                     ^ true
+                ]
+            ].
+            index := writeFdArray identityIndexOf:fd.
+            index ~~ 0 ifTrue:[
+                sema := writeSemaphoreArray at:index.
+                sema notNil ifTrue:[
+                    sema signalOnce.
+                     ^ true
+                ].
+                action := writeCheckArray at:index.
+                action notNil ifTrue:[
+                    action value.
+                     ^ true
+                ]
+            ]
+        ].
+        ^ false
+    ].
+
     newProcessMaybeReady := false.
     readableResultFdArray := Array new:40.
     writableResultFdArray := Array new:40.
@@ -3255,7 +3321,7 @@
 !ProcessorScheduler class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic/ProcessorScheduler.st,v 1.212 2003-07-15 14:03:17 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/ProcessorScheduler.st,v 1.213 2003-07-25 20:00:45 cg Exp $'
 ! !
 
 ProcessorScheduler initialize!