File: rc_gbl_ord.c

package info (click to toggle)
fis-gtm 6.3-007-1
  • links: PTS, VCS
  • area: main
  • in suites: 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 (133 lines) | stat: -rwxr-xr-x 3,837 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
/****************************************************************
 *								*
 *	Copyright 2001, 2013 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 "gtm_string.h"

#include "gdsroot.h"
#include "gdsblk.h"
#include "gtm_facility.h"
#include "fileinfo.h"
#include "gdsbt.h"
#include "gdsfhead.h"
#include "rc.h"
#include "cdb_sc.h"
#include "rc_oflow.h"
#include "copy.h"
#include "gvcst_protos.h"	/* for gvcst_order,gvcst_search prototype */
#include "t_begin.h"
#include "t_retry.h"
#include "t_end.h"
#include "hashtab_mname.h"

GBLREF int		rc_size_return;
GBLREF gd_addr		*gd_header;
GBLREF gv_key		*gv_currkey;
GBLREF gv_key		*gv_altkey;
GBLREF gv_namehead	*gv_target;
GBLREF sgmnt_data	*cs_data;
GBLREF sgmnt_addrs	*cs_addrs;
GBLDEF rc_oflow	*rc_overflow;
GBLREF gd_region	*gv_cur_region;
GBLREF trans_num	rc_read_stamp;

error_def(ERR_GVGETFAIL);

void rc_gbl_ord(rc_rsp_page *rsp)
{
	blk_hdr		*bp;
	bool		found;
	enum cdb_sc	status;
	mname_entry	gvname;
	short		bsiz, size_return;
	srch_blk_status	*bh;
	gvnh_reg_t	*gvnh_reg;

	for (;;)
	{
		gv_target = cs_addrs->dir_tree;
		found = gvcst_order();
		if (!found)
		{
			rsp->hdr.a.erc.value = RC_NETERRDBEDGE;
			rsp->size_return.value = 0;
			rsp->size_remain.value = 0;
			rsp->rstatus.value = 0;
			return;
		}
		gvname.var_name.addr = (char *)&gv_altkey->base[0];
		gvname.var_name.len = gv_altkey->end - 1;
		COMPUTE_HASH_MNAME(&gvname);
		GV_BIND_NAME_AND_ROOT_SEARCH(gd_header, &gvname, gvnh_reg);
		assert(NULL == gvnh_reg->gvspan); /* so GV_BIND_SUBSNAME_IF_GVSPAN is not needed */
		if (gv_target->root != 0)
		{
			/* Look to see if key exists */
			t_begin(ERR_GVGETFAIL, 0);
			for (;;)
			{
				rsp->hdr.a.len.value = (short)((char *)(&rsp->page[0]) - (char *)rsp);
				size_return = rc_size_return;
				if ((status = gvcst_search(gv_currkey, NULL)) != cdb_sc_normal)
				{
					t_retry(status);
					continue;
				}
				bh = gv_target->hist.h;
				if ((bsiz = ((blk_hdr *)(bh->buffaddr))->bsiz + RC_BLKHD_PAD) == SIZEOF(blk_hdr) + RC_BLKHD_PAD)
					found = FALSE;	/* Empty block, global does not exist */
				else
				{
					if (bsiz > size_return)
						rc_overflow->size = bsiz - size_return;
					else
					{
						rc_overflow->size = 0;
						size_return = bsiz;
					}
					memcpy(rsp->page, bh->buffaddr, SIZEOF(blk_hdr));
					PUT_SHORT(&((blk_hdr *)rsp->page)->bsiz, bsiz);
					memcpy(rsp->page + SIZEOF(blk_hdr) + RC_BLKHD_PAD,
					       bh->buffaddr + SIZEOF(blk_hdr),
					       size_return - (SIZEOF(blk_hdr) + RC_BLKHD_PAD));
					rsp->size_return.value = size_return;
					rsp->hdr.a.len.value += rsp->size_return.value;
					assert(rsp->hdr.a.len.value <= rc_size_return + SIZEOF(rc_rsp_page));
					rsp->zcode.value = (cs_data->blk_size / 512);	/* (2 ** zcode) == blk_size */
					if (rc_overflow->size)
					{
						memcpy(rc_overflow->buff,
						       bh->buffaddr + size_return - RC_BLKHD_PAD,
						       rc_overflow->size);
						rc_overflow->offset = size_return;
						rc_overflow->dsid = rsp->hdr.r.xdsid.dsid.value;
						rc_overflow->page = bh->blk_num;
						rc_overflow->zcode = rsp->zcode.value;
					}
					rsp->size_remain.value = rc_overflow->size;
				}
				if (0 != (rc_read_stamp = t_end(&gv_target->hist, NULL, TN_NOT_SPECIFIED)))
					break;
			}
			if (found)
				break;
		}
		GVKEY_INCREMENT_ORDER(gv_currkey);
	}
	PUT_LONG(rsp->pageaddr, bh->blk_num);
	rsp->frag_offset.value = 0;
	rsp->rstatus.value = 0;
	rsp->after.value = 0;
	rsp->xcc.value = 0;
	rsp->before.value = 0;
	return;
}