Levente Uzonyi uploaded a new version of Network to project The Trunk:
http://source.squeak.org/trunk/Network-ul.164.mcz ==================== Summary ==================== Name: Network-ul.164 Author: ul Time: 10 October 2015, 5:11:50.792 pm UUID: fd3fe5d1-838c-4dfe-869f-c780662b45b8 Ancestors: Network-ul.163 - fixed NetNameResolver class >> #nameForAddress:timeout: - simplified NetNameResolver class >> #addressForName:timeout: =============== Diff against Network-ul.163 =============== Item was changed: ----- Method: NetNameResolver class>>addressForName:timeout: (in category 'lookups') ----- addressForName: hostName timeout: secs "Look up the given host name and return its address. Return nil if the address is not found in the given number of seconds." "NetNameResolver addressForName: 'create.ucsb.edu' timeout: 30" "NetNameResolver addressForName: '100000jobs.de' timeout: 30" "NetNameResolver addressForName: '1.7.6.4' timeout: 30" "NetNameResolver addressForName: '' timeout: 30 (This seems to return nil?)" + | deadline | - | deadline result | self initializeNetwork. self useOldNetwork ifFalse: [^self addressForName: hostName]. "check if this is a valid numeric host address (e.g. 1.2.3.4)" (self addressFromString: hostName) ifNotNil: [ :numericHostAddress | ^numericHostAddress ]. "Look up a host name, including ones that start with a digit (e.g. 100000jobs.de or squeak.org)" deadline := Time primUTCMicrosecondClock + (secs * 1000000). "Protect the execution of this block, as the ResolverSemaphore is used for both parts of the transaction." + ^(self resolverMutex critical: [ + (self waitForResolverReadyUntil: deadline) ifTrue: [ + self primStartLookupOfName: hostName. + (self waitForCompletionUntil: deadline) ifTrue: [ + self primNameLookupResult. ] ] ]) + ifNil: [ (NameLookupFailure hostName: hostName) signal: 'Could not resolve the server named: ', hostName ] ! - (self resolverMutex critical: [ - (self waitForResolverReadyUntil: deadline) - ifFalse: [ 'Could not resolve the server named: ', hostName ] - ifTrue: [ - self primStartLookupOfName: hostName. - (self waitForCompletionUntil: deadline) - ifFalse: [ 'Could not resolve the server named: ', hostName ] - ifTrue: [ - result := self primNameLookupResult. - nil "No error" ] ] ]) - ifNotNil: [ :message | (NameLookupFailure hostName: hostName) signal: message ]. - ^result! Item was changed: ----- Method: NetNameResolver class>>nameForAddress:timeout: (in category 'lookups') ----- nameForAddress: hostAddress timeout: secs "Look up the given host address and return its name. Return nil if the lookup fails or is not completed in the given number of seconds. Depends on the given host address being known to the gateway, which may not be the case for dynamically allocated addresses." "NetNameResolver nameForAddress: (NetNameResolver addressFromString: '128.111.92.2') timeout: 30" | deadline | self initializeNetwork. + deadline := Time primUTCMicrosecondClock + (secs * 1000000). - deadline := DateAndTime now + secs seconds. "Protect the execution of this block, as the ResolverSemaphore is used for both parts of the transaction." + ^self resolverMutex critical: [ + (self waitForResolverReadyUntil: deadline) ifTrue: [ + self primStartLookupOfAddress: hostAddress. + (self waitForCompletionUntil: deadline) ifTrue: [ + self primAddressLookupResult ] ] ]! - ^self resolverMutex - critical: [ - (self waitForResolverReadyUntil: deadline) - ifTrue: [ - self primStartLookupOfAddress: hostAddress. - (self waitForCompletionUntil: deadline) - ifTrue: [self primAddressLookupResult] - ifFalse: [nil]] - ifFalse: [nil]].! |
Free forum by Nabble | Edit this page |