#BUGFIX by stefan
class: NonPositionableExternalStream
comment/format in: #nextPutBytes:from:startingAt:
changed:
#canReadWithoutBlocking
#canWriteWithoutBlocking
#closeFile
check for nil fd
--- a/NonPositionableExternalStream.st Wed Mar 04 17:01:08 2020 +0100
+++ b/NonPositionableExternalStream.st Wed Mar 04 17:02:50 2020 +0100
@@ -552,11 +552,12 @@
closeFile
<resource: #PRIVATE>
- |semasToSignal|
+ |semasToSignal fd|
- handle notNil ifTrue:[
+ fd := self fileHandle.
+ fd notNil ifTrue:[
"make sure, that no select is performed on closed file descriptors"
- semasToSignal := Processor disableFd:self fileHandle doSignal:false.
+ semasToSignal := Processor disableFd:fd doSignal:false.
super closeFile.
"tell the waiters that they must not wait any longer"
@@ -566,6 +567,7 @@
].
"Modified: / 07-04-2017 / 14:32:00 / cg"
+ "Modified: / 04-03-2020 / 14:52:38 / Stefan Vogel"
! !
!NonPositionableExternalStream methodsFor:'private'!
@@ -925,10 +927,12 @@
a read operation will not block the smalltalk process), false otherwise.
We know, that error conditions do not block, so return true for errors."
+ |fd|
+
^ readAhead notNil
- or:[handle isNil
+ or:[(fd := self fileHandle) isNil
or:[mode == #writeonly
- or:[OperatingSystem readCheck:self fileHandle]]]
+ or:[OperatingSystem readCheck:fd]]]
"
|pipe|
@@ -942,7 +946,8 @@
pipe close
"
- "Modified: 25.9.1997 / 13:08:45 / stefan"
+ "Modified: / 25-09-1997 / 13:08:45 / stefan"
+ "Modified: / 04-03-2020 / 14:51:53 / Stefan Vogel"
!
canWriteWithoutBlocking
@@ -950,9 +955,13 @@
(i.e. a write operation will not block the smalltalk process).
We know, that error conditions do not block, so return true for errors."
- ^ handle isNil
+ |fd|
+
+ ^ (fd := self fileHandle) isNil
or:[mode == #readonly
- or:[OperatingSystem writeCheck:self fileHandle]]
+ or:[OperatingSystem writeCheck:fd]]
+
+ "Modified: / 04-03-2020 / 14:51:42 / Stefan Vogel"
! !
!NonPositionableExternalStream methodsFor:'writing'!
@@ -999,6 +1008,10 @@
Lange Rede kurzer Sinn: 'self blocking:' sends 'self fileDescriptor'
which may set handle to nil!!"
+ "for linux we set non-blocking mode, so that the whole ST with all
+ other processes does not block, when a socket or pipe is full.
+ For windows, writes are done in an own thread, so only the
+ active process will block. For windows, #blocking: is a non-op."
wasBlocking := self blocking:false.
handle isNil ifTrue:[
@@ -1046,6 +1059,7 @@
"Modified (format): / 13-02-2020 / 14:23:44 / Stefan Reise"
"Modified: / 03-03-2020 / 16:14:41 / Stefan Vogel"
+ "Modified (format): / 04-03-2020 / 12:41:18 / Stefan Vogel"
!
nextPutLine:aString