[Pkg] The Trunk: Network-ul.182.mcz

commits at source.squeak.org commits at source.squeak.org
Sat Aug 13 19:28:36 UTC 2016


Levente Uzonyi uploaded a new version of Network to project The Trunk:
http://source.squeak.org/trunk/Network-ul.182.mcz

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

Name: Network-ul.182
Author: ul
Time: 13 August 2016, 9:27:46.042121 pm
UUID: 55cbd441-e7a5-4651-a45f-45e6e94e47aa
Ancestors: Network-ul.180

Socket:
- use #isConnected instead of #isThisEndConnected and #isOtherEndConnected while the VMs don't fully support half-open connections
SocketStream:
- do not recreate the buffers in #resetBuffers when nothing would change

=============== Diff against Network-ul.180 ===============

Item was changed:
  ----- Method: Socket>>closeAndDestroy: (in category 'connection open/close') -----
  closeAndDestroy: timeoutSeconds
  	"First, try to close this connection gracefully. If the close attempt fails or times out, abort the connection. In either case, destroy the socket. Do nothing if the socket has already been destroyed (i.e., if its socketHandle is nil)."
  
  	socketHandle ifNil: [ ^self ].
+ 	self isConnected ifTrue: [
- 	self isThisEndConnected ifTrue: [
  		self close.  "Close this end." ].
  	(self waitForDisconnectionFor: timeoutSeconds) ifFalse: [
  		"The other end has not closed the connect yet, so we will just abort it."
  		self primSocketAbortConnection: socketHandle ].
  	self destroy!

Item was changed:
  ----- Method: Socket>>discardReceivedData (in category 'receiving') -----
  discardReceivedData
  	"Discard any data received up until now, and return the number of bytes discarded."
  
  	| buf totalBytesDiscarded |
  	buf := String new: 10000.
  	totalBytesDiscarded := 0.
+ 	[self isConnected and: [self dataAvailable]] whileTrue: [
- 	[self isOtherEndConnected and: [self dataAvailable]] whileTrue: [
  		totalBytesDiscarded :=
  			totalBytesDiscarded + (self receiveDataInto: buf)].
  	^ totalBytesDiscarded
  !

Item was changed:
  ----- Method: Socket>>waitForDataFor:ifClosed:ifTimedOut: (in category 'waiting') -----
  waitForDataFor: timeout ifClosed: closedBlock ifTimedOut: timedOutBlock
  	"Wait for the given nr of seconds for data to arrive."
  	
  	| deadline timeLeft |
  	socketHandle ifNil: [ ^closedBlock value ].
  	deadline := Time millisecondClockValue + (timeout * 1000) truncated.
  	[
  		(self primSocketReceiveDataAvailable: socketHandle) ifTrue: [ ^self ].
+ 		self isConnected ifFalse: [ ^closedBlock value ].
- 		self isOtherEndConnected ifFalse: [ ^closedBlock value ].
  		(timeLeft := deadline - Time millisecondClockValue) <= 0 ifTrue: [ ^timedOutBlock value ].
  		"Providing a maximum for the time for waiting is a workaround for a VM bug which causes sockets waiting for data forever in some rare cases, because the semaphore doesn't get signaled. Remove the ""min: self class maximumReadSemaphoreWaitTimeout"" part when the bug is fixed."
  		readSemaphore waitTimeoutMSecs: 
  			(timeLeft min: self class maximumReadSemaphoreWaitTimeout) ] repeat!

Item was changed:
  ----- Method: Socket>>waitForDataIfClosed: (in category 'waiting') -----
  waitForDataIfClosed: closedBlock
  	"Wait indefinitely for data to arrive.  This method will block until
  	data is available or the socket is closed."
  
  	socketHandle ifNil: [ ^closedBlock value ].
  	[
  		(self primSocketReceiveDataAvailable: socketHandle) ifTrue: [ ^self ].
+ 		 self isConnected ifFalse: [ ^closedBlock value ].
- 		 self isOtherEndConnected ifFalse: [ ^closedBlock value ].
  		 "ul 8/13/2014 21:16
  		  Providing a maximum for the time for waiting is a workaround for a VM bug which
  		  causes sockets waiting for data forever in some rare cases, because the semaphore
  		  doesn't get signaled. Replace the ""waitTimeoutMSecs: self class maximumReadSemaphoreWaitTimeout""
  		  part with ""wait"" when the bug is fixed."
  		 readSemaphore waitTimeoutMSecs: self class maximumReadSemaphoreWaitTimeout ] repeat!

Item was changed:
  ----- Method: Socket>>waitForDisconnectionFor: (in category 'waiting') -----
  waitForDisconnectionFor: timeout
  	"Wait for the given nr of seconds for the connection to be broken.
  	Return true if it is broken by the deadline, false if not.
  	The client should know the connection is really going to be closed
  	(e.g., because he has called 'close' to send a close request to the other end)
  	before calling this method."
  
  	| deadline |
  	deadline := Time millisecondClockValue + (timeout * 1000) truncated.
+ 	[ self isConnected and: [ deadline - Time millisecondClockValue > 0 ] ]
- 	[ self isOtherEndConnected and: [ deadline - Time millisecondClockValue > 0 ] ]
  		whileTrue: [
  			self discardReceivedData.
  			"Providing a maximum for the time for waiting is a workaround for a VM bug which causes sockets waiting for data forever in some rare cases, because the semaphore doesn't get signaled. Remove the ""min: self class maximumReadSemaphoreWaitTimeout"" part when the bug is fixed."
  			readSemaphore waitTimeoutMSecs: 
  				(deadline - Time millisecondClockValue min: self class maximumReadSemaphoreWaitTimeout) ].
+ 	^self isConnected!
- 	^self isOtherEndConnected!

Item was changed:
  ----- Method: Socket>>waitForSendDoneFor: (in category 'waiting') -----
  waitForSendDoneFor: timeout
  	"Wait up until the given deadline for the current send operation to complete. Return true if it completes by the deadline, false if not."
  
  	| deadline timeleft |
  	deadline := Time millisecondClockValue + (timeout * 1000) truncated.
  	[ 
  		(self primSocketSendDone: socketHandle) ifTrue: [ ^true ].
+ 		self isConnected ifFalse: [ ^false ].
- 		self isThisEndConnected ifFalse: [ ^false ].
  		(timeleft := deadline - Time millisecondClockValue) <= 0 ifTrue: [ ^false ].
  		writeSemaphore waitTimeoutMSecs: timeleft ] repeat!

Item was changed:
  ----- Method: SocketStream>>resetBuffers (in category 'private') -----
  resetBuffers
  	"Recreate the buffers with default start sizes."
  
+ 	(inBuffer isNil or: [ inBuffer size ~= bufferSize ]) ifTrue: [
+ 		inBuffer := self streamBuffer: bufferSize ].
- 	inBuffer := self streamBuffer: bufferSize.
  	lastRead := 0.
  	inNextToWrite := 1.
+ 	(outBuffer isNil or: [ outBuffer size ~= bufferSize ]) ifTrue: [
+ 		outBuffer := self streamBuffer: bufferSize ].
- 	outBuffer := self streamBuffer: bufferSize.
  	outNextToWrite := 1!



More information about the Packages mailing list