#REFACTORING by cg
class: Socket
changed: #waitForNewConnectionOrDataOnAny:timeout:
--- a/Socket.st Mon Aug 07 10:48:11 2017 +0200
+++ b/Socket.st Wed Aug 09 14:12:34 2017 +0200
@@ -4057,45 +4057,47 @@
"first, a quick check if data is already available"
self canReadWithoutBlocking ifTrue:[
- ^ self accept.
+ ^ self accept.
].
otherConnections do:[:aConnection |
- aConnection canReadWithoutBlocking ifTrue:[
- ^ aConnection
- ]
+ aConnection canReadWithoutBlocking ifTrue:[
+ ^ aConnection
+ ]
].
"check again - prevent incoming interrupts from disturbing our setup"
wasBlocked := OperatingSystem blockInterrupts.
[
- sema := Semaphore new name:'multiReadWait'.
- otherConnections do:[:aConnection |
- Processor signal:sema onInput:(aConnection fileDescriptor).
- ].
- Processor signal:sema onInput:(self fileDescriptor).
- timeoutSeconds notNil ifTrue:[
- Processor signal:sema afterSeconds:timeoutSeconds
- ].
- Processor activeProcess state:#ioWait.
- sema wait.
+ sema := Semaphore name:'multiReadWait'.
+ otherConnections do:[:aConnection |
+ Processor signal:sema onInput:(aConnection fileDescriptor).
+ ].
+ Processor signal:sema onInput:(self fileDescriptor).
+ timeoutSeconds notNil ifTrue:[
+ Processor signal:sema afterSeconds:timeoutSeconds
+ ].
+ Processor activeProcess state:#ioWait.
+ sema wait.
] ifCurtailed:[
- sema notNil ifTrue:[Processor disableSemaphore:sema].
- wasBlocked ifFalse:[OperatingSystem unblockInterrupts].
+ sema notNil ifTrue:[Processor disableSemaphore:sema].
+ wasBlocked ifFalse:[OperatingSystem unblockInterrupts].
].
wasBlocked ifFalse:[OperatingSystem unblockInterrupts].
"see who it was ..."
self canReadWithoutBlocking ifTrue:[
- ^ self accept.
+ ^ self accept.
].
otherConnections do:[:aConnection |
- aConnection canReadWithoutBlocking ifTrue:[
- ^ aConnection
- ]
+ aConnection canReadWithoutBlocking ifTrue:[
+ ^ aConnection
+ ]
].
"none - a timeout"
^ nil
+
+ "Modified: / 09-08-2017 / 11:59:50 / cg"
!
waitForNewConnectionWithTimeout:timeoutSecondsOrNil
@@ -4133,3 +4135,4 @@
version_CVS
^ '$Header$'
! !
+