[BUG] Problem with POPSocket
tim at sumeru.stanford.edu
Tue Apr 23 19:59:03 UTC 2002
Ken Causey <ken at ineffable.com> is claimed by the authorities to have written:
> Then I'm confused. My problem is that unless I do a Socket
> initializeNetwork, then POPSocket new returns a socket with an
> invalidSocketHandle, which is therefore unusable.
Ugly isn't it?
I just tried 'PopSocket example', which sends connectToPop, which in
turn carefully initialises the network. Doesn't work - the socket status
is already broken by the time it gets there. If you try it immeidately
after that, it all works since the network code it now initialised ok.
Very bad design by somebody. If I actually understood sockets I might be
able to help more...
Hmm, looking quickly through the vm code, I see a possible cause for
this. Your 'original' socket (defined as one created before the network
init prim is called) is built ok but the s->sessionId is set to 0 -
because that is the value of thisNetSession right then. Unfortunately,
that value is used as a flag that the net is not initialised, and so
when the connectToPop sends Socket initializeNetwork it does the init -
which changes the value of thisNetSession! Thus when the status of the
socket is tested via 'socketValid();' it fails because the socket's
sessionId no longer matches thisNetSession, despite it actually being
quite ok. Boom.
I think I'd suggest slightly changing the socket prim code to solve
this. 'thisNetSession' ought to be initialised by the module init code
run at module loadtime. A separate variable ought to be used as a flag
for whether the network has been initialised. In fact I think I'd
prefer if the socket plugin could share the sessionId of the main vm &
file stuff; the problem with that is that it requires changes to a
number of components and co-ordination. Actually, now I think of it I
have some old code from David Lewis that does this, waiting for an
occasion sitable for deployment.
Tim Rowledge, tim at sumeru.stanford.edu, http://sumeru.stanford.edu/tim
Strange OpCodes: HBT: Harvest Binary Tree
More information about the Squeak-dev