|
|
1.1 root 1: /*
2: * Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
3: *
4: * @APPLE_LICENSE_HEADER_START@
5: *
6: * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights
7: * Reserved. This file contains Original Code and/or Modifications of
8: * Original Code as defined in and that are subject to the Apple Public
9: * Source License Version 1.1 (the "License"). You may not use this file
10: * except in compliance with the License. Please obtain a copy of the
11: * License at http://www.apple.com/publicsource and read it before using
12: * this file.
13: *
14: * The Original Code and all software distributed under the License are
15: * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
16: * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
17: * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
18: * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
19: * License for the specific language governing rights and limitations
20: * under the License.
21: *
22: * @APPLE_LICENSE_HEADER_END@
23: */
24:
25: /*
26: * Copyright (c) 1990, 1996-1998 Apple Computer, Inc.
27: * All Rights Reserved.
28: *
29: * THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF APPLE COMPUTER, INC.
30: * The copyright notice above does not evidence any actual or
31: * intended publication of such source code.
32: */
33:
34:
35: #include <adsp_local.h>
36:
37: /*
38: * TrashSession
39: *
40: * Cleanly abort a session that might be open. Called if probe timer expires,
41: * or from AppleTalk event handler (close or network gone away)
42: *
43: * Only call if the session is active (I.e. not for closed or listeners)
44: *
45: * INPUTS:
46: * session pointer
47: * OUTPUTS:
48: * none
49: */
50: void TrashSession(sp) /* (CCBPtr sp) */
51: CCBPtr sp;
52: {
53: int s;
54:
55: ATDISABLE(s, sp->lock);
56: sp->userFlags |= eTearDown;
57: sp->removing = 1;
58: sp->state = sClosed;
59: ATENABLE(s, sp->lock);
60:
61: DoClose(sp, errAborted, 1);
62: }
63:
64:
65: /*
66: * DoTimerElem
67: *
68: * INPUTS:
69: *
70: * OUTPUTS:
71: *
72: */
73: void DoTimerElem(t) /* (TimerElemPtr t) */
74: TimerElemPtr t;
75: {
76: CCBPtr sp;
77: int s;
78:
79: sp = (CCBPtr)((Ptr)t - t->type); /* Recover stream pointer for this guy */
80: ATDISABLE(s, sp->lock);
81:
82: if (t->type == kFlushTimerType) { /* flush write data time just fired */
83: if (sp->sData) { /* If there's any data, flush it. */
84: sp->writeFlush = 1;
85: goto send;
86: }
87: } else if (t->type == kRetryTimerType) {
88: if (sp->waitingAck) {
89:
90: sp->waitingAck = 0;
91: sp->sendSeq = sp->firstRtmtSeq;
92: sp->pktSendCnt = 0;
93: sp->resentData = 1; /* Had to resend data */
94: sp->noXmitFlow = 1; /* Don't incr. max packets. */
95:
96: if ((sp->pktSendMax /= 2) == 0) /* Back off on max # packets
97: * sent */
98: sp->pktSendMax = 1;
99:
100: if ((sp->roundTrip *= 2) > sp->probeInterval)
101: sp->roundTrip = sp->probeInterval;
102: sp->rtmtInterval = sp->roundTrip + ((short)2 *
103: (short)sp->deviation);
104: goto send;
105: }
106: } else if (t->type == kAttnTimerType) {
107: if (sp->sapb) { /* Unacknowledged attn pkt */
108: sp->sendAttnData = 1;
109: goto send;
110: }
111: } else if (t->type == kResetTimerType) {
112: if (sp->frpb) { /* Unacknowledged forward reset */
113: sp->sendCtl |= B_CTL_FRESET;
114: goto send;
115: }
116: } else if (t->type == kProbeTimerType) {
117: if (sp->state == sOpen || sp->state == sClosing) {
118: if (--sp->probeCntr == 0) { /* Connection died */
119: ATENABLE(s, sp->lock);
120: TrashSession(sp);
121: return;
122: } else {
123: InsertTimerElem(&adspGlobal.slowTimers, &sp->ProbeTimer,
124: sp->probeInterval);
125: sp->sendCtl |= B_CTL_PROBE;
126: goto send;
127: }
128: } else if (sp->state == sOpening) {
129: if ((sp->openState == O_STATE_OPENWAIT) ||
130: (sp->openState == O_STATE_ESTABLISHED))
131: {
132: if (--sp->openRetrys == 0) { /* Oops, didn't open */
133: sp->state = sClosed;
134: ATENABLE(s, sp->lock);
135: DoClose(sp, errOpening, 1);
136: return;
137: } /* open failed */
138: else /* Send packet again */
139: {
140: sp->sendCtl |= (sp->openState == O_STATE_OPENWAIT) ?
141: B_CTL_OREQ : B_CTL_OREQACK;
142: goto send;
143: }
144: } /* we're opening */
145: }
146: }
147:
148: else {
149: dPrintf(D_M_ADSP, D_L_ERROR, ("DoTimerElem:Unknown timer type!\n"));
150: }
151:
152: ATENABLE(s, sp->lock);
153: return;
154:
155: send:
156: ATENABLE(s, sp->lock);
157: CheckSend(sp);
158: }
159:
160:
161: static void *Timer_tmo = 0;
162: static StopTimer;
163:
164: /*
165: * TimerTick
166: *
167: * Called 6 times per second
168: * INPUTS:
169: *
170: * OUTPUTS:
171: *
172: */
173: void TimerTick() /* (void) */
174: {
175: if (StopTimer)
176: return;
177: TimerQueueTick(&adspGlobal.slowTimers);
178: TimerQueueTick(&adspGlobal.fastTimers);
179: Timer_tmo = (void *)atalk_timeout(TimerTick, (caddr_t)0, HZ/6);
180: }
181:
182: void TimerStop()
183: {
184: StopTimer = 1;
185: atalk_untimeout(TimerTick, (caddr_t) 0, Timer_tmo);
186: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.