]> git.saurik.com Git - apple/xnu.git/blobdiff - bsd/netat/adsp_Close.c
xnu-792.22.5.tar.gz
[apple/xnu.git] / bsd / netat / adsp_Close.c
index d7e276e7017d9b3102fda240941211b738be6f98..67541a4307da5be70578500a005701b18bace14c 100644 (file)
@@ -1,23 +1,29 @@
 /*
  * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
  *
- * @APPLE_LICENSE_HEADER_START@
+ * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. The rights granted to you under the License
+ * may not be used to create, or enable the creation or redistribution of,
+ * unlawful or unlicensed copies of an Apple operating system, or to
+ * circumvent, violate, or enable the circumvention or violation of, any
+ * terms of an Apple operating system software license agreement.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
- * @APPLE_LICENSE_HEADER_END@
+ * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
  */
 /*
  *     Copyright (c) 1990, 1995-1998 Apple Computer, Inc.
@@ -56,7 +62,6 @@
 #include <netat/adsp.h>
 #include <netat/adsp_internal.h>
 
-extern atlock_t adspall_lock;
 
 static void qRemove(CCBPtr, CCBPtr);
 
@@ -122,7 +127,6 @@ int  CompleteQueue(qhead, code)     /* (DSPPBPtr FPTR qhead, OSErr code) */
     register gref_t *gref;
     register int    total = 0;
     CCBPtr sp = 0;
-    int s;
 
     n = *qhead;                        /* Get first item */
     *qhead = 0;                        /* Zero out the queue */
@@ -131,7 +135,6 @@ int  CompleteQueue(qhead, code)     /* (DSPPBPtr FPTR qhead, OSErr code) */
        if (gref->info) {
            sp = (CCBPtr)gbuf_rptr(((gbuf_t *)gref->info));
            atalk_flush(sp->gref);
-           ATDISABLE(s, sp->lock);
            }
     }
 
@@ -144,8 +147,6 @@ int  CompleteQueue(qhead, code)     /* (DSPPBPtr FPTR qhead, OSErr code) */
        } else
            gbuf_freem(p->mp);
     }                          /* while */
-    if (sp)
-       ATENABLE(s, sp->lock);
     return(total);
 }
 
@@ -173,7 +174,7 @@ void RemoveCCB(sp, pb)              /* (CCBPtr sp, DSPPBPtr pb) */
     /*
      * Unlink CCB from list
      */
-    qRemove(AT_ADSP_STREAMS, sp); /* remove sp from active streams queue */
+    qRemove((CCB *)AT_ADSP_STREAMS, sp); /* remove sp from active streams queue */
 
     if (pb) {
        pb->ioResult = 0;
@@ -222,7 +223,7 @@ int  AbortIO(sp, err)
     /*
      * Complete all outstanding transactions.  
      */
-    total += CompleteQueue(&sp->sapb, err); /* Abort outstanding send attentions */
+    total = CompleteQueue(&sp->sapb, err); /* Abort outstanding send attentions */
     CompleteQueue(&sp->frpb, err); /* Abort outstanding forward resets */
 
     if (sp->sbuf_mb) { /* clear the send queue */
@@ -352,7 +353,6 @@ int adspClose(sp, pb)               /* (DSPPBPtr pb) */
     register CCBPtr sp;
     register struct adspcmd *pb;
 {
-    int        s;
     register gbuf_t *mp;
        
     /* Must execute nearly all of this with ints off because user could 
@@ -404,10 +404,8 @@ int adspClose(sp, pb)              /* (DSPPBPtr pb) */
      * is still pending.
      */
     if (pb->csCode == (short)dspClose) {
-       ATDISABLE(s, sp->lock);
        if ((sp->state == (short)sPassive) || (sp->state == (short)sOpening)) {
            sp->state = sClosed;
-           ATENABLE(s, sp->lock);
            DoClose(sp, errAborted, 0);
            pb->ioResult = 0;
            adspioc_ack(0, pb->ioc, pb->gref);
@@ -415,23 +413,19 @@ int adspClose(sp, pb)             /* (DSPPBPtr pb) */
        }
                
        if (sp->state == (word)sClosed) { /* Ok to close a closed connection */
-           ATENABLE(s, sp->lock);
            pb->ioResult = 0;
            adspioc_ack(0, pb->ioc, pb->gref);
            return 0;
        }
        if ((sp->state != (word)sOpen) && (sp->state != (word)sClosing)) {
-           ATENABLE(s, sp->lock);
            pb->ioResult = errState;
            return EINVAL;
        }
                
        sp->state = sClosing;   /* No matter what, we're closing */
-       ATENABLE(s, sp->lock);
     }                          /* dspClose */
     
     else {                     /* dspRemove */
-       ATDISABLE(s, sp->lock);
        sp->removing = 1;       /* Prevent allowing another dspClose. */
                                /* Tells completion routine of close */
                                /* packet to remove us. */
@@ -439,13 +433,10 @@ int adspClose(sp, pb)             /* (DSPPBPtr pb) */
        if (sp->state == sPassive || sp->state == sClosed || 
            sp->state == sOpening) {
            sp->state = sClosed;
-           ATENABLE(s, sp->lock);
            DoClose(sp, errAborted, 0); /* Will remove CCB! */
            return 0;
-       } else {                        /* sClosing & sOpen */
+       } else                  /* sClosing & sOpen */
            sp->state = sClosing;
-           ATENABLE(s, sp->lock);
-       }
        
     }                          /* dspRemove */
 
@@ -461,9 +452,7 @@ int adspClose(sp, pb)               /* (DSPPBPtr pb) */
            pb = (struct adspcmd *)gbuf_rptr(mp); /* get new parameter block */
            pb->ioc = 0;
            pb->mp = mp;
-           ATDISABLE(s, sp->lock);
            qAddToEnd(&sp->opb, pb);    /* and save it */
-           ATENABLE(s, sp->lock);
     } else {
            pb->ioResult = 0;
            adspioc_ack(0, pb->ioc, pb->gref); /* release user, and keep no copy
@@ -479,19 +468,15 @@ static void qRemove(qptr, elem)
     register CCBPtr qptr;
     register CCBPtr elem;
 {
-       int s;
 
-       ATDISABLE(s, adspall_lock);
     while(qptr->ccbLink) {
        if ((DSPPBPtr)(qptr->ccbLink) == (DSPPBPtr)elem) {
            qptr->ccbLink = elem->ccbLink;
            elem->ccbLink = 0;
-           ATENABLE(s, adspall_lock);
            return;
        }
        qptr = qptr->ccbLink;
     }
-       ATENABLE(s, adspall_lock);
 }
 
 int RxClose(sp)
@@ -499,17 +484,11 @@ int RxClose(sp)
 {
     register gbuf_t *mp;
     register struct adspcmd *pb;
-       int s, l;
 
-       ATDISABLE(l, sp->lockClose);
-       ATDISABLE(s, sp->lock);
-       if ((sp->state == sClosing) || (sp->state == sClosed)) {
-               ATENABLE(s, sp->lock);
-               ATENABLE(l, sp->lockClose);
+       if ((sp->state == sClosing) || (sp->state == sClosed))
                return 0;
-       }
+       
     sp->state = sClosed;
-       ATENABLE(s, sp->lock);
     CheckReadQueue(sp);                /* try to deliver all remaining data */
 
     if ( (mp = gbuf_alloc(sizeof(struct adspcmd), PRI_HI)) ) {
@@ -526,6 +505,5 @@ int RxClose(sp)
 if ((sp->userFlags & eClosed) == 0)
     DoClose(sp, errAborted, -1);       /* abort send requests and timers */
 
-       ATENABLE(l, sp->lockClose);
     return 0;
 }