#BUGFIX by stefan
authorStefan Vogel <sv@exept.de>
Tue, 03 Mar 2020 16:20:40 +0100
changeset 25313 a91253d9c944
parent 25312 b8687d94e230
child 25314 a91d744724d0
#BUGFIX by stefan class: NonPositionableExternalStream changed: #nextPutBytes:from:startingAt: reset non-blocking state in #ensure: block
NonPositionableExternalStream.st
--- a/NonPositionableExternalStream.st	Mon Mar 02 14:50:33 2020 +0100
+++ b/NonPositionableExternalStream.st	Tue Mar 03 16:20:40 2020 +0100
@@ -995,7 +995,10 @@
      dont move it under the #handle is nil check,
      if you move it, expecco ALM will freeze with 100% cpu usage during startup...
      and see the comment inside the #handle is nil check,
-     which seems to assume this #blocking: call before"
+     which seems to assume this #blocking: call before.
+
+     Lange Rede kurzer Sinn: 'self blocking:' sends 'self fileDescriptor'
+                              which may set handle to nil!!"
     wasBlocking := self blocking:false.
 
     handle isNil ifTrue:[
@@ -1010,36 +1013,39 @@
         ^ 0.
     ].
 
-
     offset := initialOffset.
     remaining := initialWriteCount.
 
-    [remaining ~~ 0] whileTrue:[
-        |count|
+    [
+        [remaining ~~ 0] whileTrue:[
+            |count|
 
-        count := super nextPutBytes:remaining from:buffer startingAt:offset.
-        self assert:(count >= 0).
-        count == 0 ifTrue:[
-            self writeWait.
             count := super nextPutBytes:remaining from:buffer startingAt:offset.
             self assert:(count >= 0).
             count == 0 ifTrue:[
-                Transcript showCR:'zero write'.
-                self error
+                self writeWait.
+                count := super nextPutBytes:remaining from:buffer startingAt:offset.
+                self assert:(count >= 0).
+                count == 0 ifTrue:[
+                    Transcript showCR:'zero write'.
+                    self error:'zero write'
+                ].
+            ].
+            remaining := remaining - count.
+            offset := offset + count.
+            remaining ~~ 0 ifTrue:[
+                "Transcript showCR:'writeWait'."
+                self writeWait.
             ].
         ].
-        remaining := remaining - count.
-        offset := offset + count.
-        remaining ~~ 0 ifTrue:[
-            "Transcript showCR:'writeWait'."
-            self writeWait.
-        ].
-    ].
-    wasBlocking ifTrue:[self blocking:true].
+    ] ensure:[    
+        wasBlocking ifTrue:[self blocking:true].
+    ].    
 
     ^ offset - initialOffset.
 
     "Modified (format): / 13-02-2020 / 14:23:44 / Stefan Reise"
+    "Modified: / 03-03-2020 / 16:14:41 / Stefan Vogel"
 !
 
 nextPutLine:aString