Will the real sqUnixSocket.c step forward?

John M McIntosh johnmci at smalltalkconsulting.com
Tue Apr 30 21:43:34 UTC 2002


>So the patch isn't complete. Today we managed to "fumble" ourselves 
>around it by
>hacking waitForDataUntil: and doing a "(Delay milliSeconds: 10) 
>wait" instead of
>the wait with timeout on the readsemaphore. Yep, ugly as hell but it 
>works well
>enough for us to continue developing...
>
>regards, Göran
>
>PS. I will help in any way I can with this - Squeak needs rock solid 
>Sockets. DS
>
>Göran Hultgren, goran.hultgren at bluefish.se
>GSM: +46 70 3933950, http://www.bluefish.se
>\"Department of Redundancy department.\" -- ThinkGeek


ick!!!

Well lets see if we can fix this.

Now I wonder if there is a race condition on the flag READNOTIFy such 
that a socketReadable says no but by the time you get to aioHandle, 
then data lurks?

What if you did this instead

/* answer whether the socket has data available for reading */

int sqSocketReceiveDataAvailable(SocketPtr s)
{
   if (!socketValid(s))
     return -1;
   if (SOCKETSTATE(s) == Connected)
     {
       PSP(s)->pendingEvents|= READ_NOTIFY;
       if (socketReadable(SOCKET(s))) {
         PSP(s)->pendingEvents &= ~READ_NOTIFY;
// I'll run out on a tree branch here and assume that this &= ~ will 
reset READ_NOTIFY flag bit, but hey it might be wrong C code in fact 
let's say it is, so please check confirm etc that I'm actually kinda 
right in wanting to turn just the READ_NOTIFY bit off without 
mangling the other bits.
      	return true;
       }
       aioHandle(SOCKET(s), dataHandler, AIO_RWX);
     }
   return false;
}

Mind I'm not sure what happens between athe socketReadable and 
aioHandle logic if data arrives on the socket?
-- 
--
===========================================================================
John M. McIntosh <johnmci at smalltalkconsulting.com> 1-800-477-2659
Corporate Smalltalk Consulting Ltd.  http://www.smalltalkconsulting.com
===========================================================================



More information about the Squeak-dev mailing list