NonPositionableExternalStream.st
changeset 25137 34bca3daadac
parent 24720 1f02c362969c
child 25143 d9dc4a133499
--- a/NonPositionableExternalStream.st	Mon Dec 16 16:23:24 2019 +0100
+++ b/NonPositionableExternalStream.st	Mon Dec 16 16:24:25 2019 +0100
@@ -961,7 +961,14 @@
     "nextPutBytes handles non-blocking io in receiver.
      Answer the receiver"
 
-    self nextPutBytes:aCollection size from:aCollection startingAt:1.
+    |count nWritten|
+
+    count := aCollection size.
+    nWritten := self nextPutBytes:count from:aCollection startingAt:1.
+    count ~= nWritten ifTrue:[
+        "incomplete write"
+        self writeError.
+    ].
 
     "Modified: / 09-02-2018 / 19:59:15 / stefan"
 !
@@ -969,12 +976,13 @@
 nextPutAll:aCollection startingAt:start to:stop
     "redefined, to wait until stream is writable, to avoid blocking in a write"
 
-    |count|
+    |count nWritten|
 
     count := stop-start+1.
-    count ~= (self nextPutBytes:count from:aCollection startingAt:start) ifTrue:[
-	"incomplete write"
-	self writeError.
+    nWritten := self nextPutBytes:count from:aCollection startingAt:start.
+    count ~= nWritten ifTrue:[
+        "incomplete write"
+        self writeError.
     ].
 !
 
@@ -983,7 +991,6 @@
 
     |offset remaining wasBlocking|
 
-    wasBlocking := self blocking:false.
     handle isNil ifTrue:[
         "self blocking: above may set handle to nil!!"
         self errorNotOpen.
@@ -996,6 +1003,8 @@
         ^ 0.
     ].
 
+    wasBlocking := self blocking:false.
+
     offset := initialOffset.
     remaining := initialWriteCount.