# HG changeset patch # User Claus Gittinger # Date 1502280754 -7200 # Node ID bf5e9d5ec5324939f7602843ce565b7fc2a31b23 # Parent 7ba22942a7288259df2bbd9b308dd52d2f0b7ed2 #REFACTORING by cg class: Socket changed: #waitForNewConnectionOrDataOnAny:timeout: diff -r 7ba22942a728 -r bf5e9d5ec532 Socket.st --- 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$' ! ! +