[squeak-dev] The Trunk: Network-eem.170.mcz

commits at source.squeak.org commits at source.squeak.org
Tue Jan 5 21:16:04 UTC 2016


Eliot Miranda uploaded a new version of Network to project The Trunk:
http://source.squeak.org/trunk/Network-eem.170.mcz

==================== Summary ====================

Name: Network-eem.170
Author: eem
Time: 5 January 2016, 1:15:51.565662 pm
UUID: 4fa7ff7a-74dd-4721-b7c7-04775d2afa03
Ancestors: Network-cmm.169

Move NetNameResolver from the old primUTCMicrosecondClock to the new utcMicrosecondClock.

=============== Diff against Network-cmm.169 ===============

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 |
  	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 utcMicrosecondClock + (secs * 1000000).
- 	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 ]		!

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 utcMicrosecondClock + (secs * 1000000).
- 	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 primStartLookupOfAddress: hostAddress.
  			(self waitForCompletionUntil: deadline) ifTrue: [
  				self primAddressLookupResult ] ] ]!

Item was changed:
  ----- Method: NetNameResolver class>>waitForCompletionUntil: (in category 'private') -----
  waitForCompletionUntil: deadline
+ 	"Wait until deadline for the resolver to be ready to accept a new request.
+ 	 Return true if the resolver is ready, false if the network is not initialized or
+ 	 the resolver has not become free within the given time period."
- 	"Wait until deadlien for the resolver to be ready to accept a new request. Return true if the resolver is ready, false if the network is not initialized or the resolver has not become free within the given time period."
  
  	| status millisecondsLeft |
  	status := self resolverStatus.
+ 	[ status = ResolverBusy
+ 	  and: [millisecondsLeft := (deadline - Time utcMicrosecondClock) // 1000.
+ 		   millisecondsLeft > 0 ] ]
+ 		whileTrue: "wait for resolver to be available"
+ 			[ ResolverSemaphore waitTimeoutMSecs: millisecondsLeft.
- 	[ status = ResolverBusy and: [
- 		millisecondsLeft := deadline isLarge
- 			ifTrue: [ (deadline - Time primUTCMicrosecondClock) // 1000 ]
- 			ifFalse: [ deadline - Time millisecondClockValue ].
- 		millisecondsLeft > 0  ] ]
- 		whileTrue: [
- 			"wait for resolver to be available"
- 			ResolverSemaphore waitTimeoutMSecs: millisecondsLeft.
  			status := self resolverStatus ].
  	status = ResolverReady ifTrue: [ ^true ].
  	status = ResolverBusy ifTrue: [ self primAbortLookup ].
+ 	^false!
- 	^false
- !

Item was changed:
  ----- Method: NetNameResolver class>>waitForResolverReadyUntil: (in category 'private') -----
  waitForResolverReadyUntil: deadline
  	"Wait until deadline for the resolver to be ready to accept a new request. Return true if the resolver is not busy, false if the network is not initialized or the resolver has not become free within the given time period."
  
  	| status millisecondsLeft |
  	(status := self resolverStatus) = ResolverUninitialized ifTrue: [ ^false ].
+ 	[ status = ResolverBusy
+ 	  and: [millisecondsLeft := (deadline - Time utcMicrosecondClock) // 1000.
+ 		   millisecondsLeft > 0 ] ]
+ 		whileTrue: "wait for resolver to be available"
+ 			[ ResolverSemaphore waitTimeoutMSecs: millisecondsLeft.
+ 			  status := self resolverStatus ].
- 	[ status = ResolverBusy and: [
- 		millisecondsLeft := deadline isLarge
- 			ifTrue: [ (deadline - Time primUTCMicrosecondClock) // 1000 ]
- 			ifFalse: [ deadline - Time millisecondClockValue ].
- 		millisecondsLeft > 0 ] ]
- 		whileTrue: [
- 			"wait for resolver to be available"
- 			ResolverSemaphore waitTimeoutMSecs: millisecondsLeft.
- 			status := self resolverStatus ].
  	^status ~= ResolverBusy!



More information about the Squeak-dev mailing list