|
|
1.1 root 1: /* conn_retry.c - deal with asynchronous A-Associate events */
2:
3: #ifndef lint
4: static char *rcsid = "$Header: /f/osi/quipu/RCS/conn_retry.c,v 7.0 89/11/23 22:16:56 mrose Rel $";
5: #endif
6:
7: /*
8: * $Header: /f/osi/quipu/RCS/conn_retry.c,v 7.0 89/11/23 22:16:56 mrose Rel $
9: *
10: *
11: * $Log: conn_retry.c,v $
12: * Revision 7.0 89/11/23 22:16:56 mrose
13: * Release 6.0
14: *
15: */
16:
17: /*
18: * NOTICE
19: *
20: * Acquisition, use, and distribution of this module and related
21: * materials are subject to the restrictions of a license agreement.
22: * Consult the Preface in the User's Manual for the full terms of
23: * this agreement.
24: *
25: */
26:
27:
28: #include "quipu/dsap.h"
29: #include "quipu/util.h"
30: #include "quipu/connection.h"
31:
32: extern LLog * log_dsap;
33: extern time_t timenow;
34: extern time_t nsap_timeout;
35:
36: #ifndef NO_STATS
37: extern LLog * log_stat;
38: extern int dn_print();
39: #endif
40:
41: struct connection * conn_alloc();
42:
43: /*
44: * Deal with an incoming acceptance of association establishment.
45: * Return value says whether anything has happened or not.
46: */
47: conn_retry(conn)
48: struct connection * conn;
49: {
50: struct DSAPconnect dc_s;
51: struct DSAPconnect *dc = &dc_s;
52: struct DSAPindication di_s;
53: struct DSAPindication *di = &di_s;
54: struct oper_act * on;
55: struct oper_act * onext;
56: struct oper_act * ont = NULLOPER;
57: int result;
58: int pstate;
59: int do_next_nsap;
60:
61: DLOG (log_dsap,LLOG_TRACE,( "conn_retry()"));
62:
63: pstate = conn->cn_state;
64:
65: if (timenow - conn->cn_last_used >= nsap_timeout) {
66: /* this NSAP has had long enough - try the next one... */
67: LLOG (log_dsap,LLOG_NOTICE,("NSAP hanging (%d)...",conn->cn_ad));
68: do_next_nsap = 1;
69: conn->cn_last_used = timenow; /* restart timer */
70: } else {
71: do_next_nsap = 0;
72: }
73:
74: switch (conn->cn_ctx)
75: {
76: case DS_CTX_X500_DAP:
77: LLOG(log_dsap, LLOG_EXCEPTIONS, ("DAP context type in conn_retry()"));
78: conn_extract(conn);
79: return;
80:
81: case DS_CTX_X500_DSP:
82: watch_dog ("DspAsynBindRetry");
83: result = DspAsynBindRetry (conn->cn_ad, do_next_nsap, dc, di);
84: watch_dog_reset ();
85: break;
86:
87: case DS_CTX_QUIPU_DSP:
88: watch_dog ("QspAsynBindRetry");
89: result = QspAsynBindRetry (conn->cn_ad, do_next_nsap, dc, di);
90: watch_dog_reset ();
91: break;
92:
93: default:
94: LLOG(log_dsap, LLOG_EXCEPTIONS, ("Unknown context type in conn_retry()"));
95: conn_extract(conn);
96: return;
97: }
98:
99: switch(result)
100: {
101: case CONNECTING_1:
102: DLOG (log_dsap,LLOG_NOTICE,("D-BIND.RETRY CONNECTING_1 (%d)",conn->cn_ad));
103: conn->cn_state = CN_CONNECTING1;
104: DCFREE(dc);
105: break;
106:
107: case CONNECTING_2:
108: DLOG (log_dsap,LLOG_NOTICE,("D-BIND.RETRY CONNECTING_2 (%d)",conn->cn_ad));
109: conn->cn_state = CN_CONNECTING2;
110: DCFREE(dc);
111: break;
112:
113: case NOTOK :
114: DLOG (log_dsap,LLOG_NOTICE,( "D-BIND.RETRY NOTOK"));
115: conn->cn_state = CN_FAILED;
116:
117: #ifndef NO_STATS
118: pslog(log_stat, LLOG_NOTICE, "Failed (RETRY NOTOK)", dn_print, (caddr_t) conn->cn_dn);
119: #endif
120: dsa_reliable (conn,FALSE,timenow);
121:
122: for(on=conn->cn_operlist; on!=NULLOPER; on=onext)
123: {
124: onext = on->on_next_conn;
125: /* See if there is another DSA to try... */
126: if ((on->on_state != ON_ABANDONED) && (on->on_dsas != NULL_DI_BLOCK)) {
127: LLOG (log_dsap,LLOG_NOTICE,("Trying a different DSA (NOTOK)..."));
128: if (oper_chain (on) == OK) {
129: if (ont == NULLOPER)
130: conn->cn_operlist = onext;
131: else
132: ont->on_next_conn = onext;
133: continue;
134: }
135: }
136: /* No - we can't do it !!! */
137: oper_fail_wakeup(on);
138: ont = on;
139: }
140: conn_extract(conn);
141: break;
142:
143: case DONE :
144: DLOG (log_dsap,LLOG_NOTICE,( "D-BIND.RETRY DONE (%d)",conn->cn_ad));
145: if( (conn->cn_ad == NOTOK) || (conn_req_aux(conn, dc) != OK))
146: {
147: #ifndef NO_STATS
148: pslog(log_stat, LLOG_NOTICE, "Failed (RETRY DONE)", dn_print, (caddr_t) conn->cn_dn);
149: #endif
150: dsa_reliable (conn,FALSE,timenow);
151: conn->cn_state = CN_FAILED;
152: for(on=conn->cn_operlist; on!=NULLOPER; on=onext)
153: {
154: onext = on->on_next_conn;
155: /* See if there is another DSA to try... */
156: if ((on->on_state != ON_ABANDONED) && (on->on_dsas != NULL_DI_BLOCK)) {
157: LLOG (log_dsap,LLOG_NOTICE,("Trying a different DSA (DONE)..."));
158: if (oper_chain (on) == OK) {
159: if (ont == NULLOPER)
160: conn->cn_operlist = onext;
161: else
162: ont->on_next_conn = onext;
163: continue;
164: }
165: }
166: oper_fail_wakeup(on);
167: ont = on;
168: }
169: DLOG(log_dsap, LLOG_DEBUG, ("conn_retry calling conn_extract 1"));
170: conn_extract(conn);
171: DCFREE(dc);
172: return;
173: }
174: DCFREE(dc);
175:
176: for(on=conn->cn_operlist; on!=NULLOPER; on=on->on_next_conn)
177: {
178: if (on->on_state == ON_ABANDONED)
179: oper_fail_wakeup(on);
180:
181: else if (oper_send_invoke(on) != OK) {
182: LLOG (log_dsap,LLOG_EXCEPTIONS,("oper_send_invoke failed in conn_retry"));
183: oper_log(on);
184: oper_fail_wakeup(on);
185: }
186: }
187: break;
188:
189: default :
190: DLOG(log_dsap, LLOG_DEBUG, ("conn_retry calling conn_extract 2"));
191: for(on=conn->cn_operlist; on!=NULLOPER; on=on->on_next_conn)
192: {
193: oper_fail_wakeup(on);
194: }
195: conn_extract(conn);
196: DCFREE(dc);
197: break;
198:
199: } /* switch retry */
200:
201: if (pstate != conn->cn_state)
202: conn->cn_last_used = timenow;
203: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.