Problem with Socket under Linux...
goran.hultgren at bluefish.se
goran.hultgren at bluefish.se
Mon Apr 22 14:34:52 UTC 2002
Ian Piumarta <ian.piumarta at inria.fr> wrote:
> Hi Goran,
>
> > int sqSocketReceiveDataAvailable(SocketPtr s)
> > {
> > if (!socketValid(s))
> > return -1;
> > if (SOCKETSTATE(s) == Connected)
> > {
> > if (socketReadable(SOCKET(s)))
> > return true;
> > PSP(s)->pendingEvents|= READ_NOTIFY;
> > aioHandle(SOCKET(s), dataHandler, PSP(s), AIO_RW);
> > }
> > return false;
> > }
> >
> > I don't really know why this code looks like it does but I do wonder why
> > the unix version notifies the readSemaphore even if the socket is not
> > "socketReadable".
>
> It probably comes from my misunderstanding of exactly the conditions
> under which the semaphore should be signalled. (As far as I know,
> nobody ever specified the behaviour of the socket semaphore stuff in
> any kind of rigorous manner -- so I'm basically guessing where to
> signal them.) If the Unix and win behaviours differ then I happily
> concede that the win version is probably right.
>
> > I don't really know what aioHandle is/does
>
> It ensures that the socket is select()ed for i/o, which might not be the
> case if it has just been connected and no reads were performed before
> asking if data is available, or if a read of all available data has just
> completed.
Ok.
> > but I
> > assume it will result in that "notify()" is called which in turn signals
> > the readSema.
>
> Correct. The notify() is done in the function dataHandler().
>
> > Obviously I am missing something fundamental here -
> > shouldn't the readSemaphore only be signalled if there is something to
> > read?
>
> This should be the case, since the signal happens in the dataHandler which
> is only called when select() determines that data is available on the
> socket.
Ok, but wait. If notify() is called for some other reason... No. Can't
see where that would happen.
Hmmm.
> > On Win32 it seems to never signal the semaphore which also
> > seems.... funny. :-)
>
> It depends on the assumptions. Does polling a socket for data enable
> the signaling of its semaphore, or must you actually try to read data
> from it first?
Well, since I am in over my head I shouldn't draw any conclusions. It
just "looked" as if the Win32 version of this function didn't signal
anything. But perhaps I missed something.
> I suggest you try commenting out the line
>
> PSP(s)->pendingEvents|= READ_NOTIFY;
>
> and then run every socket test in your possession to see what works/breaks.
Ok, I will try this. Now I just have to figure out how to build my VM.
:-
(I am trying VMMaker but I stumbled right before "configure" - can't
really understand where it should be... It sure isn't in my VMMaker
generated "src" directory anyway. Whatever.)
> > We have just semi-verified it's a Linux - thing, Jonas here running
> > on Win2k does not have it - at least not when doing some simple
> > tests.
>
> If you send me your test suite then I'll hack on this at my end. (I
> need to fix a problem with mouse wheels anyway, so this is the perfect
> opportunity to look at the socket stuff.)
Ok, I will see if I can whip up some simple testcode that shows the
problem. I will get back to you.
> Thanks!
>
> Ian
Hey, thank YOU.
regards, Göran
More information about the Squeak-dev
mailing list
|