X-Git-Url: https://git.saurik.com/apple/xnu.git/blobdiff_plain/21362eb3e66fd2c787aee132bce100a44d71a99c..4452a7af2eac33dbad800bcc91f2399d62c18f53:/bsd/netat/adsp_stream.c diff --git a/bsd/netat/adsp_stream.c b/bsd/netat/adsp_stream.c index cd23ec2ac..c749294bd 100644 --- a/bsd/netat/adsp_stream.c +++ b/bsd/netat/adsp_stream.c @@ -72,8 +72,6 @@ unsigned char adspAssignSocket(); int adspallocate(), adsprelease(); int adspInited = 0; -atlock_t adspall_lock; -atlock_t adspgen_lock; GLOBAL adspGlobal; /**********/ @@ -92,17 +90,14 @@ void adsp_input(mp) gref_t *gref; CCBPtr sp; at_ddp_t *p; - int s, l; gbuf_t *mb; switch (gbuf_type(mp)) { case MSG_DATA: p = (at_ddp_t *)gbuf_rptr(mp); - ATDISABLE(s, adspall_lock); sp = adsp_inputQ[p->dst_socket]; if ((sp == 0) || (sp->gref==0) || (sp->state==sClosed)) { - ATENABLE(s, adspall_lock); gbuf_freem(mp); return; } @@ -115,7 +110,6 @@ void adsp_input(mp) } while ((sp = sp->otccbLink) != 0); if (sp == 0) { - ATENABLE(s, adspall_lock); gbuf_freem(mp); return; } @@ -127,12 +121,9 @@ void adsp_input(mp) gbuf_next(mb) = mp; } else sp->deferred_mb = mp; - ATENABLE(s, adspall_lock); return; } - ATDISABLE(l, sp->lockRemove); sp->lockFlag = 1; - ATENABLE(l, adspall_lock); while (mp) { adsp_rput(sp->gref, mp); if ((mp = sp->deferred_mb) != 0) { @@ -141,7 +132,6 @@ void adsp_input(mp) } } sp->lockFlag = 0; - ATENABLE(s, sp->lockRemove); return; case MSG_IOCACK: @@ -191,7 +181,7 @@ int adsp_readable(gref) int adsp_writeable(gref) gref_t *gref; { - int s, rc; + int rc; CCBPtr sp; if (gref->info == 0) @@ -207,9 +197,7 @@ int adsp_writeable(gref) return(1); sp = (CCBPtr)gbuf_rptr(((gbuf_t *)gref->info)); - ATDISABLE(s, sp->lock); rc = CalcSendQFree(sp); - ATENABLE(s, sp->lock); return rc; } @@ -235,7 +223,6 @@ int adsp_open(gref) gref_t *gref; { register CCBPtr sp; - int s; if (!adspInited) adsp_init(); @@ -246,28 +233,21 @@ int adsp_open(gref) sp = (CCBPtr)gbuf_rptr(((gbuf_t *)gref->info)); gref->readable = adsp_readable; gref->writeable = adsp_writeable; - ATDISABLE(s, adspall_lock); if ((sp->otccbLink = ccb_used_list) != 0) sp->otccbLink->ccbLink = sp; ccb_used_list = sp; - ATENABLE(s, adspall_lock); return 0; } int adsp_close(gref) gref_t *gref; { - int s, l; unsigned char localSocket; /* make sure we've not yet removed the CCB (e.g., due to TrashSession) */ - ATDISABLE(l, adspgen_lock); if (gref->info) { CCBPtr sp = (CCBPtr)gbuf_rptr(((gbuf_t *)gref->info)); - ATDISABLE(s, sp->lock); - ATENABLE(s, adspgen_lock); localSocket = sp->localSocket; - ATENABLE(l, sp->lock); if (localSocket) adspRelease(gref); else @@ -276,7 +256,6 @@ int adsp_close(gref) gbuf_freeb((gbuf_t *)gref->info); } } else - ATENABLE(l, adspgen_lock); return 0; } @@ -342,7 +321,6 @@ int adsp_wput(gref, mp) gbuf_t *mp; { int rc; - int s; gbuf_t *xm; ioc_t *iocbp; CCBPtr sp; @@ -364,17 +342,14 @@ int adsp_wput(gref, mp) adsp_iocnak(gref, mp, EINVAL); } v = *(unsigned char *)gbuf_rptr(gbuf_cont(mp)); - ATDISABLE(s, adspall_lock); if ( (v != 0) && ((v > DDP_SOCKET_LAST) || (v < 2) || ddp_socket_inuse(v, DDP_ADSP))) { - ATENABLE(s, adspall_lock); iocbp->ioc_rval = -1; adsp_iocnak(gref, mp, EINVAL); } else { if (v == 0) { - ATENABLE(s, adspall_lock); if ((v = adspAssignSocket(gref, 0)) == 0) { iocbp->ioc_rval = -1; adsp_iocnak(gref, mp, EINVAL); @@ -384,7 +359,6 @@ int adsp_wput(gref, mp) adsp_inputC[v] = 1; adsp_inputQ[v] = sp; adsp_pidM[v] = sp->pid; - ATENABLE(s, adspall_lock); adsp_dequeue_ccb(sp); } *(unsigned char *)gbuf_rptr(gbuf_cont(mp)) = v; @@ -456,9 +430,7 @@ int adsp_wput(gref, mp) if (!gref->info) gbuf_freem(mp); else { - ATDISABLE(s, sp->lockClose); rc = adspWriteHandler(gref, mp); - ATENABLE(s, sp->lockClose); switch (rc) { case STR_PUTNEXT: @@ -543,12 +515,10 @@ adspAssignSocket(gref, flag) { unsigned char sVal, sMax, sMin, sSav, inputC; CCBPtr sp; - int s; sMax = flag ? DDP_SOCKET_LAST-46 : DDP_SOCKET_LAST-6; sMin = DDP_SOCKET_1st_DYNAMIC; - ATDISABLE(s, adspall_lock); for (inputC=255, sVal=sMax; sVal >= sMin; sVal--) { if (!ddp_socket_inuse(sVal, DDP_ADSP)) break; @@ -563,22 +533,17 @@ adspAssignSocket(gref, flag) } } if (sVal < sMin) { - if (!flag || (inputC == 255)) { - ATENABLE(s, adspall_lock); + if (!flag || (inputC == 255)) return 0; - } sVal = sSav; } sp = (CCBPtr)gbuf_rptr(((gbuf_t *)gref->info)); - ATENABLE(s, adspall_lock); adsp_dequeue_ccb(sp); - ATDISABLE(s, adspall_lock); adsp_inputC[sVal]++; sp->otccbLink = adsp_inputQ[sVal]; adsp_inputQ[sVal] = sp; if (!flag) adsp_pidM[sVal] = sp->pid; - ATENABLE(s, adspall_lock); return sVal; } @@ -590,11 +555,9 @@ adspDeassignSocket(sp) CCBPtr curr_sp; CCBPtr prev_sp; int pid = 0; - int s, l; dPrintf(D_M_ADSP, D_L_TRACE, ("adspDeassignSocket: pid=%d,s=%d\n", sp->pid, sp->localSocket)); - ATDISABLE(s, adspall_lock); sVal = sp->localSocket; if ((curr_sp = adsp_inputQ[sVal]) != 0) { prev_sp = 0; @@ -603,12 +566,10 @@ adspDeassignSocket(sp) curr_sp = curr_sp->otccbLink; } if (curr_sp) { - ATDISABLE(l, sp->lockRemove); if (prev_sp) prev_sp->otccbLink = sp->otccbLink; else adsp_inputQ[sVal] = sp->otccbLink; - ATENABLE(l, sp->lockRemove); if (adsp_inputQ[sVal]) adsp_inputC[sVal]--; else { @@ -619,11 +580,9 @@ adspDeassignSocket(sp) sp->ccbLink = 0; sp->otccbLink = 0; sp->localSocket = 0; - ATENABLE(s, adspall_lock); return pid ? 0 : 1; } } - ATENABLE(s, adspall_lock); dPrintf(D_M_ADSP, D_L_ERROR, ("adspDeassignSocket: closing, no CCB block, trouble ahead\n")); @@ -637,9 +596,7 @@ void adsp_dequeue_ccb(sp) CCB *sp; { - int s; - ATDISABLE(s, adspall_lock); if (sp == ccb_used_list) { if ((ccb_used_list = sp->otccbLink) != 0) sp->otccbLink->ccbLink = 0; @@ -650,7 +607,6 @@ adsp_dequeue_ccb(sp) sp->otccbLink = 0; sp->ccbLink = 0; - ATENABLE(s, adspall_lock); } void SndMsgUp(gref, mp)