File: gvcmz_neterr.c

package info (click to toggle)
fis-gtm 6.2-000-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 30,784 kB
  • ctags: 42,554
  • sloc: ansic: 358,483; asm: 4,847; csh: 4,574; sh: 2,261; awk: 200; makefile: 86; sed: 13
file content (123 lines) | stat: -rw-r--r-- 3,388 bytes parent folder | download | duplicates (2)
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
/****************************************************************
 *								*
 *	Copyright 2001, 2011 Fidelity Information Services, 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 "gdsroot.h"
#include "gtm_facility.h"
#include "fileinfo.h"
#include "gdsbt.h"
#include "gdsfhead.h"
#include "cmidef.h"
#include "hashtab_mname.h"	/* needed for cmmdef.h */
#include "cmmdef.h"
#include "locklits.h"
#include "iotimer.h"
#include "gtm_string.h"
#include "gvcmy_close.h"
#include "gvcmz.h"
#include "op.h"
#include "dpgbldir.h"
#include "lv_val.h"		/* needed for "callg.h" */
#include "callg.h"

GBLREF	struct NTD	*ntd_root;
GBLDEF	bool		neterr_pending;

error_def(ERR_LCKSCANCELLED);

void	gvcmz_neterr(INTPTR_T *err)
{
	struct CLB	*p, *pn, *p1;
	unsigned char	*temp, buff[512];
	gd_addr		*gdptr;
	gd_region	*region, *r_top;
	uint4		count, lck_info;
	INTPTR_T	err_buff[10];
	boolean_t	locks = FALSE;

	neterr_pending = FALSE;
	if (NULL == ntd_root)
		GTMASSERT;
	for (p = (struct CLB *)RELQUE2PTR(ntd_root->cqh.fl);  p != (struct CLB *)ntd_root;  p = pn)
	{
		/* Get the forward link, in case a close removes the current entry */
		pn = (struct CLB *)RELQUE2PTR(p->cqe.fl);
		if (0 != ((link_info *)p->usr)->neterr)
		{
			p->ast = NULL;
			if (locks)
				gvcmy_close(p);
			else
			{
				locks = ((link_info *)p->usr)->lck_info & REMOTE_CLR_MASK;
				gvcmy_close(p);
				if (locks)
				{
					buff[0] = CMMS_L_LKCANALL;
					for (p1 = (struct CLB *)RELQUE2PTR(ntd_root->cqh.fl);
					     p1 != (struct CLB *)ntd_root;
					     p1 = (struct CLB *)RELQUE2PTR(p1->cqe.fl))
					{
						p1->ast = NULL;
						/* The following line effectively clears REQUEST_PENDING */
						lck_info = ((link_info *)p1->usr)->lck_info &= REMOTE_CLR_MASK;
						if (lck_info)
						{
							temp = p1->mbf;
							p1->mbf = buff;
							p1->cbl = S_HDRSIZE + S_LAFLAGSIZE;
							if (lck_info & (REMOTE_LOCKS | LREQUEST_SENT))
							{
								buff[1] = CM_LOCKS;
								cmi_write(p1);
							}
							if (lck_info & (REMOTE_ZALLOCATES | ZAREQUEST_SENT))
							{
								buff[1] = CM_ZALLOCATES;
								cmi_write(p1);
							}
							p1->mbf = temp;
						}
					}
					op_lkinit();
					op_unlock();
					op_zdeallocate(NO_M_TIMEOUT);
				}
			}
			/* Cycle through all active global directories */
			for (gdptr = get_next_gdr(NULL);  NULL != gdptr;  gdptr = get_next_gdr(gdptr))
				for (region = gdptr->regions, r_top = region + gdptr->n_regions;  region < r_top;  ++region)
					if ((dba_cm == region->dyn.addr->acc_meth) && (p == region->dyn.addr->cm_blk))
					{
						/* If it's a CM-accessed region via the current (error-generating) link: */
						region->open = FALSE;
						region->dyn.addr->acc_meth = dba_bg;
					}
		}
	}
	if (locks)
	{
		if (NULL != err)
		{
			count = (uint4)(*err + 1);
			memcpy(err_buff, err, count * SIZEOF(INTPTR_T));
			err_buff[count] = 0;
			err_buff[count + 1] = ERR_LCKSCANCELLED;
			err_buff[count + 2] = 0;
			err_buff[0] += 3;
			callg_signal(err_buff);
		} else
			rts_error(VARLSTCNT(1) ERR_LCKSCANCELLED);
	} else  if (NULL != err)
		callg_signal(err);

}