semaphores do not access like volatile
Niko Schwarz
niko.schwarz at gmx.net
Mon Feb 10 11:49:02 UTC 2003
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Am Montag, 10. Februar 2003 12:06 schrieb diegogomezdeck at consultar.com:
> Are you signaling the semaphore before changing the "results" variable?
Yeis.
> Can you atach a piece of code with the problem?
I'll try.
first, this method creates the reading thread:
initializeThreading
| ws |
readProc _ [[(Delay forMilliseconds: 100) wait.
ws _ WriteStream
on: (String new: 4000).
[socket dataAvailable]
whileTrue: [ws nextPutAll: socket getData asString].
ws size > 0
ifTrue: [self processIncoming: ws contents.
semaphore signal]] repeat]
forkAt: Processor userInterruptPriority - 10
important here is processIncoming. it does this:
processIncoming: aString
"Check if the stream is closing (see checkIfClosingAndRepair), and then
put the data into its channels.
If it is closing, disconnect after processing."
[snip]
doc _ XMLDOMParser parseDocumentFrom: xmlString readStream.
self assert: doc elements size = 1.
el _ doc elements anyOne.
el name caseOf: {
[#stream:stream] -> [self verifyProtocol: el attributes].
[#iq] -> [self channel: #iq add: el].
[#stream:error] -> [self channel: #stream:error add: el]}
otherwise: [self error: el name asString , ' is unknown!'].
closing
ifTrue: [self disconnect]
disconnect btw calls terminate on its own process.
so, obviously, in every every case, the channels variable was modified before
calling signal.
I read it like this:
authenticateName: name password: pwd resource: rsc
| el |
self send: [snip authenticate me].
semaphore wait.
"(Delay forMilliseconds: 1000) wait." <-- uncommenting this brings it to work
el _ (channels at: #iq) last.
(el attributes at: #type)
= #error
ifTrue: [AuthenticationException
signalWithQuery: (el firstTagNamed: #query)]
But even with incorrect password, the error doesnt arrive in channels fast
enough to give an authentication exception.
hope i cleared it. i tried to make a shorter snippet to let it fail, but it
worked fine there.
regards,
nick
- --
"Rembrandt's first name was Beauregard, which is why he never used
it."
-- Dave Barry
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.1 (GNU/Linux)
iD8DBQE+R5Gu3P3nmXTVnC8RAo5PAJkBXrKvB8XBT+oQn1YUy+t1ZBmYfgCgq0yK
uq148mHm31VcJvIICBUoQw0=
=Kl2v
-----END PGP SIGNATURE-----
More information about the Squeak-dev
mailing list
|