File: gvcmz_int_lkcancel.c

package info (click to toggle)
fis-gtm 6.3-007-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, sid
  • size: 36,284 kB
  • sloc: ansic: 328,861; asm: 5,182; csh: 5,102; sh: 1,918; awk: 291; makefile: 69; sed: 13
file content (148 lines) | stat: -rwxr-xr-x 4,034 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
/****************************************************************
 *								*
 * Copyright (c) 2001-2018 Fidelity National Information	*
 * Services, Inc. and/or its subsidiaries. All rights reserved.	*
 *								*
 *	This source code contains the intellectual property	*
 *	of its copyright holder(s), and is made available	*
 *	under a license.  If you do not know the terms of	*
 *	the license, please stop and do not read further.	*
 *								*
 ****************************************************************/

#include "mdef.h"

#include "gtm_signal.h"

#include "gtm_stdio.h"
#include "gtm_string.h"
#include "gdsroot.h"
#include "gdsbt.h"
#include "gtm_facility.h"
#include "fileinfo.h"
#include "gdsfhead.h"
#include "ast.h"
#include "cmidef.h"
#include "hashtab_mname.h"	/* needed for cmmdef.h */
#include "cmmdef.h"
#include "gvcmz.h"
#include "cmi.h"
#include "iosp.h"
#include "gt_timer.h"
#include "copy.h"

GBLDEF int		lkcancel_count;

GBLREF struct NTD	*ntd_root;
GBLREF unsigned char	cm_action;
GBLREF unsigned char	lkerror;
GBLREF struct CLB	*lkerrlnk;
GBLREF unsigned char	cmlk_num;

error_def(ERR_BADSRVRNETMSG);
error_def(ERR_TEXT);

#define CM_LKCANCEL_WAIT_TIME	100 /* ms */

void gvcmz_int_lkcancel(void)
{
	static unsigned char	temp[16];
	bool			read_inprog;
	char			errbuf[CM_ERRBUFF_SIZE];
	unsigned char		*ptr, action, sent;
	unsigned short		count, cbl;
	uint4			status, norm_stat;
	int			loopcounter = 0;
	struct CLB		*p;
	CMI_MUTEX_DECL(cmi_mutex_rc);
	DEBUG_ONLY(void		(*oldast)();)

	assertpro(ntd_root);
	CMI_MUTEX_BLOCK(cmi_mutex_rc);
	action = CMMS_L_LKCANCEL;
	temp[0] = CMMS_S_INTERRUPT;
	temp[3] = action;
	temp[4] = cm_action;
	temp[5] = cmlk_num;
	lkcancel_count = count = 0;
	sent = (CM_ZALLOCATES == cm_action ? ZAREQUEST_SENT : LREQUEST_SENT);
	for (p = (struct CLB *)RELQUE2PTR(ntd_root->cqh.fl);  p != (struct CLB *)ntd_root;  p = (struct CLB *)RELQUE2PTR(p->cqe.fl))
	{
		if (((link_info*)(p->usr))->lck_info & (REQUEST_PENDING | sent))
		{
			ptr = p->mbf;
			cbl = p->cbl;
			CM_PUT_USHORT(&temp[1], ((link_info*)(p->usr))->procnum, ((link_info*)(p->usr))->convert_byteorder);
			DEBUG_ONLY(oldast = p->ast;)
			if (CM_CLB_READ == p->sta)
				read_inprog = TRUE;
			else
				read_inprog = FALSE;
			if (read_inprog)
			{
				p->mbf = &temp[CM_URGDATA_OFFSET];
				p->cbl = CM_URGDATA_LEN;
				status = cmi_write_int(p);
			} else
			{
				assert(0 == p->ast); /* below cmi_write has to be synchronous. vinu 06/18/2001 */
				p->mbf = &temp[3];
				p->cbl = 3;
				status = cmi_write(p);
			}
			p->mbf = ptr;
			p->cbl = cbl;
			if (CMI_ERROR(status))
			{
				((link_info *)(p->usr))->neterr = TRUE;
			/* safe to always enable since error ??? smw 96/11 */
				VMS_ONLY(was_setast = SS$_WASSET;) /* to force ENABLE_AST in CMI_MUTEX_RESTORE */
				CMI_MUTEX_RESTORE(cmi_mutex_rc);
				gvcmz_error(action, status);
				return;
			}
			if (!read_inprog)
			{
				p->ast = gvcmz_lkcancel_ast;
				status = cmi_read(p);
				if (CMI_ERROR(status))
				{
					((link_info *)(p->usr))->neterr = TRUE;
				/* safe to always enable since error ??? smw 96/11 */
					VMS_ONLY(was_setast = SS$_WASSET;) /* to force ENABLE_AST in CMI_MUTEX_RESTORE */
					CMI_MUTEX_RESTORE(cmi_mutex_rc);
					gvcmz_error(action, status);
					return;
				}
			} else
			{
				assert(CM_CLB_READ == p->sta);
				p->ast = gvcmz_lkcancel_ast;
			}
			count++;
		}
	}
	CMI_MUTEX_RESTORE(cmi_mutex_rc);
/* 97/6/23 smw need to rethink break condition here */
	while (lkcancel_count < count && !lkerror)
	{
		CMI_IDLE(CM_LKCANCEL_WAIT_TIME);
		DEBUG_ONLY(loopcounter++;)
	}
	if (lkerror)
	{
		if (CMI_CLB_ERROR(lkerrlnk))
			gvcmz_error(lkerror, CMI_CLB_IOSTATUS(lkerrlnk));
		else
		{
			if (CMMS_E_ERROR != *(lkerrlnk->mbf))
			{
				SNPRINTF(errbuf, CM_ERRBUFF_SIZE, "gvcmz_int_lkcancel: expected CMMS_E_ERROR, got %d",
					(int)(*(lkerrlnk->mbf)));
				rts_error_csa(CSA_ARG(NULL) VARLSTCNT(6) ERR_BADSRVRNETMSG, 0, ERR_TEXT, 2, LEN_AND_STR(errbuf));
			} else
				gvcmz_errmsg(lkerrlnk, FALSE);
		}
	}
	return;
}