[squeak-dev] Shutting down ALServers properly

Frank Shearar frank.shearar at gmail.com
Mon Dec 17 22:40:20 UTC 2012


I thought I'd be clever and start up my server in a #setUp and close
it in a #tearDown.

So I have something like this:

RemoteOrganizerTest >> setUp
	port := 9090.
	host := '127.0.0.1'. "Everything supports IPv4."
	serv := self assertLocalServerOnPort: port.
	local := self setUpLocal.
	remote := self setUpRemote.

RemoteOrganizerTest >> assertLocalServerOnPort: anInteger
	| serv |
	ALServer allInstances do: #stop. "This is excessive!" self flag: #todo.
	serv := ALServer on: anInteger application: (ImageReflector new).
	"Must fork so that we can read from the socket. Otherwise we're
trying to read and write on the same Process, which doesn't work."
	serv start.
	^ serv.

RemoteOrganizerTest >> tearDown
	serv stop.

local contains a SystemOrganizer while remote contains a
WebClient-using thing. It all kind've works, except that in the
#tearDown the sockets are very unhappy with the way they're being torn
down: SocketPrimitiveFailed: primSocketReceiveDataAvailable: failed.
The stack looks like this:

Socket>>primitiveFailed:
Socket(Object)>>primitiveFailed
Socket>>primSocketReceiveDataAvailable:
Socket>>waitForDataIfClosed:
ALConnection>>wait
ALConnection>>loop
[] in [] in ALConnection>>run
BlockClosure>>on:do:
[] in ALConnection>>run
BlockClosure>>ifCurtailed:
ALConnection>>run
[] in ALConnection>>start
[] in BlockClosure>>newProcess

so I'm reasonably sure that I'm terminating the ALServers with too
extreme a prejudice.

How should I tear down the server?

(I could pull the server creation into a TestFixture, but I'm hesitant
to do that without understanding the error above.)

frank


More information about the Squeak-dev mailing list