[nas] More bugs

Peter Berg Larsen pebl at math.ku.dk
Fri Sep 28 03:40:14 MDT 2001



Hi,

For at least solaris the minibufSamples is never initialized which is bad
because in ausuni.c the number of written bytes in writeAlloutputs are
calculated by 

n = aumax(aumax(*monoSamples, *stereoSamples),
	  aumax(*leftSamples, *rightSamples));

which sometimes gives seq-fault. These variables does not seems to be set
unless they are used, (on any machine). The first diff is to initialize
that when allocated. 

In CloseDownClient an if sentence is written as 

    if (!client->clientGone)
        if (client->closeDownMode == AuCloseDownDestroy)
        {
            [...]

*            if ((client->requestVector != InitialVector) &&
*                (--nClients == 0))
            {
                if (terminateAtReset)
                    dispatchException |= DE_TERMINATE;
         } [..]
     }

I have taken this as a fault as nClients always should be decreased, which
could be optimized out as is. Secondly there is some peculiarities with
persistent clients (client has set closedownmode to
AuCloseDownRetainPermanent). If a persistent client starts a flow and is
the _only_ client, the flow continues, but as soon as a non-persitence
client enters and stops, the flow stops. Is this intended? It seems that
either the flows should stop (server reset/terminate) when last client is
down, or flows started by persistent client should be accounted for, and
only when they also have stop/gone, should the server reset/terminat.


The patch should take care of the different bugs plus some more
initializing of data. It also contains a patch to check for clientGone.

 
Peter
--
E-Mail:       pebl at math.ku.dk 
Real name:    Peter Berg Larsen 
Where:        Department of Computer Science, Copenhagen Uni., Denmark
-------------- next part --------------
diff -w -u /usr/local/dikunix/work/nas/src//nas-1.4.2a/server/dia/au.h ./au.h
--- /usr/local/dikunix/work/nas/src//nas-1.4.2a/server/dia/au.h	Sat Jan  1 10:28:24 2000
+++ ./au.h	Thu Sep 27 02:19:49 2001
@@ -355,6 +355,9 @@
 									      \
     if (!((d) = (ComponentPtr) aualloc(PAD4(sizeof(ComponentRec)) + (extra))))\
 	return AuBadAlloc;						      \
+                                                                              \
+    /* pebl: specific initalize minibufSamples to zero (needed!) */           \
+    bzero((d),PAD4(sizeof(ComponentRec)) + (extra));                          \
 }
 
 #define AU_ADD_DEVICE(d)						      \
diff -w -u /usr/local/dikunix/work/nas/src//nas-1.4.2a/server/dia/auevents.c ./auevents.c
--- /usr/local/dikunix/work/nas/src//nas-1.4.2a/server/dia/auevents.c	Sun Oct 24 19:16:52 1999
+++ ./auevents.c	Wed Sep 26 23:47:32 2001
@@ -76,6 +76,8 @@
 int             count;
 auEvent        *events;
 {
+    /* pebl: check whether client is still there */
+    if (pClient->clientGone == FALSE)
     WriteEventsToClient(pClient, count, events);
 }
 
diff -w -u /usr/local/dikunix/work/nas/src//nas-1.4.2a/server/dia/dispatch.c ./dispatch.c
--- /usr/local/dikunix/work/nas/src//nas-1.4.2a/server/dia/dispatch.c	Sat May  8 20:47:38 1999
+++ ./dispatch.c	Fri Sep 28 07:12:22 2001
@@ -259,18 +259,24 @@
 {
     if (!client->clientGone)
     {
-	if (client->closeDownMode == AuCloseDownDestroy)
-	{
 	    client->clientGone = TRUE;  /* so events aren't sent to client */
 	    CloseDownConnection(client);
+
+	if (client->closeDownMode == AuCloseDownDestroy)
+	{
 	    FreeClientResources(client);
 	    if (ClientIsAsleep (client))
 		ClientSignal (client);
 	    if (client->index < nextFreeClientID)
 		nextFreeClientID = client->index;
 	    clients[client->index] = NullClient;
-	    if ((client->requestVector != InitialVector) &&
-		(--nClients == 0))
+
+	    /* Pebl: decrease first as the compiler might skip the second test
+	     * if first fails, then check if client was idle.  BUG: if a
+	     * persistent client is running flows all flows are killed if
+	     * there is no more clients, except if it was the only client.  */
+	    if ((--nClients == 0) &&
+		(client->requestVector != InitialVector))
 	    {
 		if (terminateAtReset)
 		    dispatchException |= DE_TERMINATE;
@@ -281,8 +287,6 @@
 	}
 	else
 	{
-	    client->clientGone = TRUE;
-	    CloseDownConnection(client);
 	    --nClients;
 	}
     }
@@ -350,6 +354,8 @@
     client->swapped = FALSE;
     client->big_requests = FALSE;
     client->closeDownMode = AuCloseDownDestroy;
+    /* pebl: init unused field? */
+    bzero(client->screenPrivate,MAXSCREENS * sizeof(pointer));
 }
 
 /************************


More information about the Nas mailing list