Problem with Socket under Linux...

goran.hultgren at bluefish.se goran.hultgren at bluefish.se
Mon Apr 22 15:20:18 UTC 2002


Ok, now I have some sample code to show you: Fire up a virgin
3.2gamma-4827, kill the logo, open a Process browser from the tools flap
(turn on CPU watch since this shows % active), open the transcript, open
a workspace, paste this into it:

| socket |
[Transcript show: 'initializing network ... '.
Socket initializeNetworkIfFail: [^Transcript show:'failed'].
Transcript show:'ok';cr.
socket _ Socket newTCP.
socket listenOn: 54321.
Transcript show: 'server endpoint created'; cr.
socket waitForConnectionUntil: Socket standardDeadline.
(Delay forSeconds: 60) wait.
socket closeAndDestroy.
Transcript cr; show: 'server endpoint destroyed'; cr.]
	forkAt: Processor userBackgroundPriority.

[client _ Socket newTCP.
client connectTo: (NetNameResolver addressFromString: '127.0.0.1') port:
54321.
(client waitForConnectionUntil: Socket standardDeadline)
	ifTrue:[Transcript show: 'Client connected, waiting 60 secs'; cr.
			client getData. "this one will timeout"]
	ifFalse:[Transcript show: 'Client not connected!'; cr.]
] forkAt: Processor userBackgroundPriority.


...then do a "do it" on the first fork to start a dumb server that
doesn't answer but just sits there for one minute. Thendo a "do-it" on
the second part which connects and then does a #getData which will
timeout in 45 seconds.

When this is done, click on Process browser and press Alt-u repeatedly.
Note the last do-it that eats CPU, at least 33% on my box. Do a debug on
it, step around in #waitForDataUntil: while inspecting the readSema and
you will see how the primitive raises excess signals to 1 and thus the
wait flies through and sets it back to 0.

Ok, what should be fixed? :-)

regards, Göran

PS. Using .deb-packages of Squeak:
gohu at marvin2:~/squeak/3.2gamma$ squeak -version
 3.2a-4653 #1 [nas audio, xshm] Sat Feb  2 12:36:23 EST 2002 gcc 2.95.4
Linux logrus.dnsalias.net 2.4.17 #3 Sun Jan 6 17:39:22 EST 2002 i686
unknown
default plugin location: /usr/lib/squeak/3.2a-4653/*.so
gohu at marvin2:~/squeak/3.2gamma$ uname -a
Linux marvin2 2.4.17 #2 Tue Feb 19 15:51:50 CET 2002 i686 unknown
DS



More information about the Squeak-dev mailing list