Lines Matching refs:sp
79 int CheckOkToClose(sp) /* (CCBPtr sp) */
80 CCBPtr sp;
83 if (sp->sData) /* Outstanding data ? */
86 if (sp->sapb) /* Outstanding send attention ? */
89 if (sp->frpb) /* Outstanding forward reset ? */
92 if (sp->sendAttnAck)
95 if (sp->sendDataAck)
101 sp->sendCtl |= B_CTL_CLOSE; /* So, need to send close advice */
102 sp->callSend = 1;
129 CCBPtr sp = 0;
136 sp = (CCBPtr)gbuf_rptr(((gbuf_t *)gref->info));
137 atalk_flush(sp->gref);
144 if (sp) {
145 completepb(sp, p); /* complete the copy of the request */
160 * sp pointer to ccb
167 void RemoveCCB(sp, pb) /* (CCBPtr sp, DSPPBPtr pb) */
168 CCBPtr sp;
173 if (sp->gref == 0)
178 qRemove((CCB *)AT_ADSP_STREAMS, sp); /* remove sp from active streams queue */
185 completepb(sp, pb); /* queued */
188 if (sp->opb && (pb != sp->opb)) { /* if the pb requested is not the */
189 pb = sp->opb; /* waiting open pb, complete it too */
190 sp->opb = 0;
192 completepb(sp, pb);
194 sp->opb = 0;
197 gref = sp->gref;
198 sp->gref = 0;
199 if (gref->info == (char *)sp->sp_mp) { /* queue head is still valid */
202 if ((skt = sp->localSocket) != 0) {
203 if (adspDeassignSocket(sp) == 0)
204 ddp_notify_nbp(skt, sp->pid, DDP_ADSP);
212 gbuf_freem(sp->sp_mp); /* our head is already gone, be sure
218 int AbortIO(sp, err)
219 CCBPtr sp;
224 if (sp->gref == 0)
229 _total = CompleteQueue(&sp->sapb, err); /* Abort outstanding send attentions */
230 CompleteQueue(&sp->frpb, err); /* Abort outstanding forward resets */
232 if (sp->sbuf_mb) { /* clear the send queue */
233 gbuf_freel(sp->sbuf_mb);
234 sp->sbuf_mb = 0;
237 if (sp->csbuf_mb) {
238 gbuf_freem(sp->csbuf_mb);
239 sp->csbuf_mb = 0;
241 sp->sData = 0;
256 * sp An ADSP stream
260 void DoClose(sp, err, force_abort) /* (CCBPtr sp, OSErr err) */
261 register CCBPtr sp;
270 sp->pid, err, force_abort, sp->localSocket, sp->removing));
271 sp->userFlags |= eClosed; /* Set flag */
272 sp->state = sClosed;
273 sp->openState = O_STATE_NOTHING;
278 RemoveTimerElem(&adspGlobal.slowTimers, &sp->ProbeTimer);
279 RemoveTimerElem(&adspGlobal.fastTimers, &sp->FlushTimer);
280 RemoveTimerElem(&adspGlobal.fastTimers, &sp->RetryTimer);
281 RemoveTimerElem(&adspGlobal.fastTimers, &sp->AttnTimer);
282 RemoveTimerElem(&adspGlobal.fastTimers, &sp->ResetTimer);
284 aborted_count = AbortIO(sp, err);
285 np = sp->opb; /* Get list of close/removes to complete */
286 sp->opb = 0; /* set this list null */
292 completepb(sp, pb);
294 if (sp->removing && (force_abort >= 0)) { /* Abort outstanding receives */
295 aborted_count += CompleteQueue(&sp->rpb, err);
297 if (sp->deferred_mb) {
298 gbuf_freel(sp->deferred_mb);
299 sp->deferred_mb = 0;
301 if (sp->attn_mb) {
302 gbuf_freem(sp->attn_mb);
303 sp->attn_mb = 0;
305 if (sp->rbuf_mb) { /* clear the rcv queue */
306 gbuf_freem(sp->rbuf_mb);
307 sp->rbuf_mb = 0;
309 if (sp->crbuf_mb) {
310 gbuf_freem(sp->crbuf_mb);
311 sp->crbuf_mb = 0;
313 sp->rData = 0;
329 completepb(sp, pb); /* send fake read completion */
332 sp->removing = 0;
333 RemoveCCB(sp, 0); /* Will call completion routine */
335 sp->userFlags &= ~eClosed;
356 int adspClose(sp, pb) /* (DSPPBPtr pb) */
357 register CCBPtr sp;
371 if (sp == 0) {
380 if (sp->state != (short)sListening) { /* But it's not a listener! */
384 CompleteQueue(&sp->opb, errAborted); /* Complete all dspListens */
385 RemoveCCB(sp, pb); /* Will call completion routine */
394 if (sp->removing) { /* Don't allow dspRemove or dspClose */
411 if ((sp->state == (short)sPassive) || (sp->state == (short)sOpening)) {
412 sp->state = sClosed;
413 DoClose(sp, errAborted, 0);
419 if (sp->state == (word)sClosed) { /* Ok to close a closed connection */
424 if ((sp->state != (word)sOpen) && (sp->state != (word)sClosing)) {
429 sp->state = sClosing; /* No matter what, we're closing */
433 sp->removing = 1; /* Prevent allowing another dspClose. */
437 if (sp->state == sPassive || sp->state == sClosed ||
438 sp->state == sOpening) {
439 sp->state = sClosed;
440 DoClose(sp, errAborted, 0); /* Will remove CCB! */
443 sp->state = sClosing;
447 if (pb->u.closeParams.abort || CheckOkToClose(sp)) /* going to close */
449 AbortIO(sp, errAborted);
450 sp->sendCtl = B_CTL_CLOSE; /* Send close advice */
459 qAddToEnd((struct qlink **)&sp->opb, (struct qlink *)pb); /* and save it */
466 CheckSend(sp);
486 int RxClose(sp)
487 register CCBPtr sp;
492 if ((sp->state == sClosing) || (sp->state == sClosed))
495 sp->state = sClosed;
496 CheckReadQueue(sp); /* try to deliver all remaining data */
506 completepb(sp, pb); /* send close completion */
509 if ((sp->userFlags & eClosed) == 0)
510 DoClose(sp, errAborted, -1); /* abort send requests and timers */