Problem with Socket under Linux...

Ian Piumarta ian.piumarta at inria.fr
Wed Apr 24 13:50:03 UTC 2002


Goran,

I ran your test program and saw precisely what you described.

If you managed to build from source then could you apply the following
patch, recompile and try to reproduce your original problem with Comanche?

(Running your test program with these changes, my VM sits at 0% CPU [plus
or minus a few percentage points when opening notifiers ;-] throughout.  
I've run several other tests and the changes seem fine, but I've not run
anything nearly as "heavy" as Comanche -- so the very first question might
even be "does it work at all?" ;-)

The patch is against the 3.1beta-4478 sources, posted about a month ago on
my Squeak page.  (If you're using VMMaker then you'll have to figure out
for yourself how to persuade patch to work right, or simply apply the
patches by hand -- they're minimal.)  If it works for you and seems
stable (i.e., Comanche functions properly for a few days) then I'll roll
it into a 3.1 final release along with various other stuff and build a
bunch of new VMs.

Regards,

Ian

--- Squeak-3.1beta-4478/src/unix/sqUnixSocket.c	Tue Feb  5 20:33:44 2002
+++ 3.1/src/unix/sqUnixSocket.c	Wed Apr 24 15:15:58 2002
@@ -1,39 +1,11 @@
 /* sqUnixSocket.c -- Unix socket support
  * 
- *   Copyright (C) 1996 1997 1998 1999 2000 2001 Ian Piumarta and individual
- *      authors/contributors listed elsewhere in this file.
- *   All rights reserved.
- *   
- *   This file is part of Unix Squeak.
- * 
- *   This file is distributed in the hope that it will be useful, but WITHOUT
- *   ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- *   FITNESS FOR A PARTICULAR PURPOSE.
- *   
- *   You may use and/or distribute this file ONLY as part of Squeak, under
- *   the terms of the Squeak License as described in `LICENSE' in the base of
- *   this distribution, subject to the following restrictions:
- * 
- *   1. The origin of this software must not be misrepresented; you must not
- *      claim that you wrote the original software.  If you use this software
- *      in a product, an acknowledgment to the original author(s) (and any
- *      other contributors mentioned herein) in the product documentation
- *      would be appreciated but is not required.
- * 
- *   2. This notice may not be removed or altered in any source distribution.
- * 
- *   Using or modifying this file for use in any context other than Squeak
- *   changes these copyright conditions.  Read the file `COPYING' in the base
- *   of the distribution before proceeding with any such use.
- * 
- *   You are STRONGLY DISCOURAGED from distributing a modified version of
- *   this file under its original name without permission.  If you must
- *   change it, rename it first.
+ * @copyright@
  */
 
 /* Author: Ian.Piumarta at inria.fr
  * 
- * Last edited: 2002-02-05 20:33:44 CET by piumarta on emilia.inria.fr
+ * Last edited: 2002-04-24 15:15:58 CEST by piumarta on emilia.inria.fr
  * 
  * Support for "accept" primitives contributed by:
  *	Lex Spoon <lex at cc.gatech.edu>
@@ -207,7 +179,7 @@
 static void closeHandler(int, void *, int);
 
 #ifdef DEBUG
-static char *handlerName(aioHandler h)
+char *handlerName(aioHandler h)
 {
   /*  if (h == nullHandler)    return "nullHandler";*/
   if (h == acceptHandler)  return "acceptHandler";
@@ -316,11 +288,11 @@
 
 void notify(privateSocketStruct *pss, int eventMask)
 {
-  int mask= pss->pendingEvents | eventMask;
+  int mask= pss->pendingEvents & eventMask;
   if (mask & CONN_NOTIFY)  interpreterProxy->signalSemaphoreWithIndex((pss)->connSema);
   if (mask & READ_NOTIFY)  interpreterProxy->signalSemaphoreWithIndex((pss)->readSema);
   if (mask & WRITE_NOTIFY) interpreterProxy->signalSemaphoreWithIndex((pss)->writeSema);
-  pss->pendingEvents= 0;
+  pss->pendingEvents&= ~mask;
 }
 
 /* this handler should never normally be invoked */
@@ -603,6 +575,7 @@
       SOCKETSTATE(s)= WaitingForConnection;
       aioEnable(SOCKET(s), PSP(s), 0);
       aioHandle(SOCKET(s), acceptHandler, AIO_RX); /* => accept() possible */
+      PSP(s)->pendingEvents= CONN_NOTIFY;
     }
   else
     {
@@ -651,6 +624,7 @@
 	      /* asynchronous connection in progress */
 	      SOCKETSTATE(s)= WaitingForConnection;
 	      aioHandle(SOCKET(s), connectHandler, AIO_WX);  /* => connect() done */
+	      PSP(s)->pendingEvents= CONN_NOTIFY;
 	    }
 	  else
 	    {
@@ -683,7 +657,7 @@
 {
   struct privateSocketStruct *pss;
 
-  FPRINTF((stderr, "acceptFrom(%d, %d)\n", SOCKET(s), SOCKET(serverSocket)));
+  FPRINTF((stderr, "acceptFrom(%d, %d)\n", SOCKET(s), 0/*SOCKET(serverSocket)*/));
 
   /* sanity checks */
   if(!socketValid(serverSocket) || !PSP(serverSocket)->multiListen)
@@ -883,7 +857,7 @@
 int sqSocketReceiveDataAvailable(SocketPtr s)
 {
   if (!socketValid(s))
-    return -1;
+    return false;
   if (SOCKETSTATE(s) == Connected)
     {
       if (socketReadable(SOCKET(s)))
@@ -900,7 +874,7 @@
 int sqSocketSendDone(SocketPtr s)
 {
   if (!socketValid(s))
-    return -1;
+    return true;	/* subsequent sendData() signals the error */
   if (SOCKETSTATE(s) == Connected)
     {
       if (socketWritable(SOCKET(s))) return true;




More information about the Squeak-dev mailing list