File: gvcmz_lkread_ast.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 (146 lines) | stat: -rwxr-xr-x 3,905 bytes parent folder | download | duplicates (3)
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
/****************************************************************
 *								*
 *	Copyright 2001, 2004 Sanchez Computer Associates, Inc.	*
 *								*
 *	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 "cmidef.h"
#include "hashtab_mname.h"	/* needed for cmmdef.h */
#include "cmmdef.h"
#include "gvcmz.h"
#include "cmi.h"
#include "iosp.h"

GBLREF unsigned short	lkresponse_count;
GBLREF struct CLB	*lktask_x;
GBLREF uint4		lkstatus;
GBLREF unsigned char	cm_action;
GBLREF unsigned char	lkerror;
GBLREF struct CLB	*lkerrlnk;
GBLREF cm_lk_response	*lk_granted, *lk_suspended;
GBLREF unsigned short	lksusp_sent,lksusp_rec;

void gvcmz_lkread_ast(struct CLB *lnk)
{
	unsigned char	*ptr;
	uint4 		status;
	cm_lk_response	*lk_suspend, *lk_grant,*p;

	if (CMI_CLB_ERROR(lnk))
	{
		((link_info *)(lnk->usr))->neterr = TRUE;
		lkerror = CMMS_L_LKREQUEST;
		lkerrlnk = lnk;
		return;
	}
	if (lkstatus == CMMS_M_LKBLOCKED)
	{
		lnk->ast = 0;
		ptr = lnk->mbf;
		*ptr++ = CMMS_L_LKSUSPEND;
		*ptr++ = cm_action;
		lnk->cbl = S_HDRSIZE + S_LAFLAGSIZE;
		status = cmi_write(lnk);
		if (CMI_ERROR(status))
		{
			((link_info *)(lnk->usr))->neterr = TRUE;
			lkerror = CMMS_L_LKREQUEST;
			lkerrlnk = lnk;
			return;
		}
		assert(0 == lksusp_sent && NULL == lk_suspended || 0 < lksusp_sent && NULL != lk_suspended);
		lksusp_sent++;
		lk_suspend = &((link_info *)(lnk->usr))->lk_response;
		lk_suspend->next = lk_suspended;
		lk_suspend->response = lnk;
		lk_suspended = lk_suspend;
		lk_suspend->response->ast = gvcmz_lksuspend_ast;
		status = cmi_read(lnk);
		if (CMI_ERROR(status))
		{
			((link_info *)(lnk->usr))->neterr = TRUE;
			lkerror = CMMS_L_LKREQUEST;
			lkerrlnk = lnk;
			return;
		}
	} else if (lkstatus != CMMS_L_LKCANCEL)
	{
		assert(lkstatus == SS_NORMAL);
		if (*lnk->mbf == CMMS_M_LKBLOCKED)
		{
			lktask_x = lnk;
			lnk->ast = 0;
			ptr = lnk->mbf;
			*ptr++ = CMMS_L_LKACQUIRE;
			*ptr++ = cm_action;
			lnk->cbl = S_HDRSIZE + S_LAFLAGSIZE;
			status = cmi_write(lnk);
			if (CMI_ERROR(status))
			{
				((link_info *)(lnk->usr))->neterr = TRUE;
				lkerror = CMMS_L_LKREQUEST;
				lkerrlnk = lnk;
				return;
			}
			lksusp_sent = 0;
			lksusp_rec = 0;
			lk_suspend = lk_granted;
			while (lk_suspend)
			{
				lk_granted = lk_granted->next;
				lk_suspend->response->ast = 0;
				ptr = lk_suspend->response->mbf;
				*ptr++ = CMMS_L_LKSUSPEND;
				*ptr++ = cm_action;
				lk_suspend->response->cbl = S_HDRSIZE + S_LAFLAGSIZE;
				status = cmi_write(lk_suspend->response);
				if (CMI_ERROR(status))
				{
					((link_info *)(lk_suspend->response->usr))->neterr = TRUE;
					lkerror = CMMS_L_LKREQUEST;
					lkerrlnk = lk_suspend->response;
					return;
				}
				lksusp_sent++;
				lk_suspend->next = lk_suspended;
				lk_suspended = lk_suspend;
				lk_suspend->response->ast = gvcmz_lksuspend_ast;
				status = cmi_read(lk_suspend->response);
				if (CMI_ERROR(status))
				{
					((link_info *)(lk_suspend->response->usr))->neterr = TRUE;
					lkerror = CMMS_L_LKREQUEST;
					lkerrlnk = lk_suspend->response;
					return;
				}
				lk_suspend = lk_granted;
			}
			lkstatus = CMMS_M_LKBLOCKED;
		} else if (*(lnk->mbf) == CMMS_M_LKABORT)
		{
			lkstatus = CMMS_L_LKCANCEL;
			lnk->ast = 0;
		} else
		{
			if (*(lnk->mbf) != CMMS_M_LKGRANTED)
			{
				lkerror = CMMS_L_LKREQUEST;
				lkerrlnk = lnk;
				return;
			}
			((link_info *)(lnk->usr))->lck_info |= (cm_action == CM_ZALLOCATES ? REMOTE_ZALLOCATES : REMOTE_LOCKS);
			lnk->ast = 0;
			lk_grant = &((link_info *)(lnk->usr))->lk_response;
			lk_grant->next = lk_granted;
			lk_grant->response = lnk;
			lk_granted = lk_grant;
		}
	}
	lkresponse_count++;
}