BSD 4_3_Net_2 release
[unix-history] / usr / src / contrib / isode / quipu / task_invoke.c
CommitLineData
9e8e5516
C
1/* task_invoke.c - deal with invocation of an operation over a connection */
2
3#ifndef lint
4static char *rcsid = "$Header: /f/osi/quipu/RCS/task_invoke.c,v 7.2 91/02/22 09:39:59 mrose Interim $";
5#endif
6
7/*
8 * $Header: /f/osi/quipu/RCS/task_invoke.c,v 7.2 91/02/22 09:39:59 mrose Interim $
9 *
10 *
11 * $Log: task_invoke.c,v $
12 * Revision 7.2 91/02/22 09:39:59 mrose
13 * Interim 6.8
14 *
15 * Revision 7.1 90/10/17 11:54:53 mrose
16 * sync
17 *
18 * Revision 7.0 89/11/23 22:18:13 mrose
19 * Release 6.0
20 *
21 */
22
23/*
24 * NOTICE
25 *
26 * Acquisition, use, and distribution of this module and related
27 * materials are subject to the restrictions of a license agreement.
28 * Consult the Preface in the User's Manual for the full terms of
29 * this agreement.
30 *
31 */
32
33
34/* LINTLIBRARY */
35
36#include "rosap.h"
37#include "quipu/util.h"
38#include "quipu/connection.h"
39
40extern LLog * log_dsap;
41extern time_t timenow;
42extern time_t admin_time;
43extern UTC str2utct();
44struct task_act * task_alloc();
45struct common_args * get_ca_ref();
46
47int task_invoke(conn, dx)
48register struct connection * conn;
49register struct DSAPinvoke * dx;
50{
51 time_t timer;
52 struct task_act * task;
53 struct extension * ext;
54 struct common_args * ca;
55
56 DLOG(log_dsap, LLOG_TRACE, ("task_invoke()"));
57
58 for(task=conn->cn_tasklist; task!=NULLTASK; task=task->tk_next)
59 if(task->tk_dx.dx_id == dx->dx_id)
60 break;
61
62 if(task != NULLTASK)
63 {
64 DLOG(log_dsap, LLOG_TRACE, ("Duplicate invocation identifier %d", dx->dx_id));
65 send_ro_ureject(conn->cn_ad, &(dx->dx_id), ROS_IP_DUP);
66 return(NOTOK);
67 }
68
69 task = task_alloc();
70
71 DLOG(log_dsap, LLOG_TRACE, ("Operation Invoked"));
72
73 task->tk_conn = conn;
74 task->tk_state = TK_ACTIVE;
75 task->tk_dx = (*dx); /* struct copy */
76
77 if(task->tk_dx.dx_arg.dca_dsarg.arg_type == OP_ABANDON)
78 {
79 DLOG(log_dsap, LLOG_NOTICE, ("Abandon received"));
80#ifndef NO_STATS
81 log_x500_event (&(task->tk_dx.dx_arg.dca_dsarg),task->tk_conn->cn_ctx,NULLDN,NULLDN,task->tk_conn->cn_ad);
82#endif
83 if(perform_abandon(task) == OK)
84 {
85 task_result(task);
86 }
87 else
88 {
89 task_error(task);
90 }
91 task_free(task);
92 return(OK);
93 }
94
95 if(task->tk_dx.dx_arg.dca_dsarg.arg_type == OP_GETEDB)
96 {
97 DLOG(log_dsap, LLOG_TRACE, ("GetEDB received"));
98 task->tk_dx.dx_arg.dca_charg.cha_originator = dn_cpy(task->tk_conn->cn_dn);
99 }
100
101 if((ca = get_ca_ref(&task->tk_dx.dx_arg)) != NULL_COMMONARG)
102 {
103 switch(ca->ca_servicecontrol.svc_prio)
104 {
105 case SVC_PRIO_LOW:
106 task->tk_prio = DSA_PRIO_LOW;
107 break;
108 case SVC_PRIO_MED:
109 task->tk_prio = DSA_PRIO_MED;
110 break;
111 case SVC_PRIO_HIGH:
112 task->tk_prio = DSA_PRIO_HIGH;
113 break;
114 default:
115 DLOG(log_dsap, LLOG_EXCEPTIONS, ("Impossibly svc_prio = %d",
116 ca->ca_servicecontrol.svc_prio));
117 task->tk_prio = DSA_PRIO_LOW;
118 break;
119 }
120
121 for(ext = ca->ca_extensions; ext!=NULLEXT; ext=ext->ext_next)
122 {
123 /* Check for unavailable critical extension */
124 if(ext->ext_critical)
125 break;
126 }
127
128 if(ext != NULLEXT)
129 {
130 task->tk_resp.di_type = DI_ERROR;
131 task->tk_resp.di_error.de_err.dse_type = DSE_SERVICEERROR;
132 task->tk_resp.di_error.de_err.dse_un.dse_un_service.DSE_sv_problem = DSE_SV_UNAVAILABLECRITICALEXTENSION;
133 task_error(task);
134 task_free(task);
135 return(NOTOK);
136 }
137 }
138 else
139 {
140 /* Logic warning: No common args => low prio */
141 task->tk_prio = DSA_PRIO_LOW;
142 }
143
144 /* Check for loop */
145 if(conn->cn_ctx == DS_CTX_X500_DAP)
146 {
147 if(ca != NULL_COMMONARG)
148 {
149 if(ca->ca_servicecontrol.svc_timelimit == SVC_NOTIMELIMIT)
150 {
151 task->tk_timed = FALSE;
152 if ((conn->cn_authen == DBA_AUTH_NONE)
153 || (! manager (task->tk_conn->cn_dn)))
154 {
155 task->tk_timed = 2;
156 task->tk_timeout = timenow + admin_time;
157 }
158 }
159 else
160 {
161 task->tk_timed = TRUE;
162 if ((timer = ca->ca_servicecontrol.svc_timelimit) > admin_time)
163 {
164 if ((conn->cn_authen == DBA_AUTH_NONE)
165 || (! manager (task->tk_conn->cn_dn)))
166 {
167 task->tk_timed = 2;
168 timer = admin_time;
169 }
170 }
171 task->tk_timeout = timenow + timer;
172 }
173#ifdef DEBUG
174 if (task->tk_timed)
175 DLOG(log_dsap, LLOG_DEBUG, ("CommonArgs timelimit is %d secs", task->tk_timeout - timenow));
176#endif
177 }
178 else
179 {
180 task->tk_timed = FALSE;
181 }
182 }
183 else
184 {
185 struct chain_arg * cha = &(task->tk_dx.dx_arg.dca_charg);
186
187 if(cha_loopdetected(cha))
188 {
189 task->tk_resp.di_type = DI_ERROR;
190 task->tk_resp.di_error.de_err.dse_type = DSE_SERVICEERROR;
191 task->tk_resp.di_error.de_err.dse_un.dse_un_service.DSE_sv_problem = DSE_SV_LOOPDETECT;
192 task_error(task);
193 task_free(task);
194 return(NOTOK);
195 }
196
197 if(cha->cha_timelimit == NULLCP)
198 {
199 task->tk_timed = 2;
200 task->tk_timeout = timenow + admin_time;
201
202 if(ca != NULL_COMMONARG)
203 {
204 if(ca->ca_servicecontrol.svc_timelimit != SVC_NOTIMELIMIT)
205 {
206 task->tk_timed = TRUE;
207 if (ca->ca_servicecontrol.svc_timelimit < admin_time)
208 {
209 task->tk_timeout = timenow + ca->ca_servicecontrol.svc_timelimit;
210 }
211 }
212 }
213#ifdef DEBUG
214 if (task->tk_timed)
215 DLOG(log_dsap, LLOG_DEBUG, ("DSP CommonArgs timelimit is %d secs", task->tk_timeout - timenow));
216#endif
217 }
218 else
219 {
220 UTC ut;
221
222 task->tk_timed = TRUE;
223 ut = str2utct(cha->cha_timelimit, strlen(cha->cha_timelimit));
224 task->tk_timeout = gtime(ut2tm(ut));
225 timer = timenow;
226 if (task->tk_timeout - timer > admin_time)
227 {
228 /* DSP -> can't rely on manager() !!! */
229 task->tk_timed = 2;
230 task->tk_timeout = timer + admin_time;
231 DLOG(log_dsap, LLOG_DEBUG, ("Chained timeout (limited) is %s", cha->cha_timelimit));
232 }
233 else
234 {
235 DLOG(log_dsap, LLOG_DEBUG, ("Chained timeout is %s", cha->cha_timelimit));
236 }
237 }
238 }
239
240 if(task->tk_timed == FALSE)
241 {
242 DLOG(log_dsap, LLOG_TRACE, ("task has NO timelimit"));
243 }
244#ifdef DEBUG
245 else
246 {
247 struct UTCtime ut;
248 struct UTCtime ut2;
249
250 DLOG(log_dsap, LLOG_TRACE, ("inv task has timelimit of %ld", task->tk_timeout));
251 tm2ut(gmtime(&(task->tk_timeout)), &ut);
252 DLOG(log_dsap, LLOG_DEBUG, ("converted timelimit = %s", utct2str(&(ut))));
253 tm2ut(gmtime(&(timenow)), &ut2);
254 DLOG(log_dsap, LLOG_DEBUG, ("time now = %s", utct2str(&(ut2))));
255 }
256#endif
257
258 task->tk_next = conn->cn_tasklist;
259 conn->cn_tasklist = task;
260 task->tk_state = TK_ACTIVE;
261 return(OK);
262}
263