File: gtcmtr_lke_clearreq.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 (137 lines) | stat: -rw-r--r-- 3,423 bytes parent folder | download | duplicates (5)
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
/****************************************************************
 *								*
 *	Copyright 2001, 2009 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.	*
 *								*
 ****************************************************************/

/*
 * ---------------------------------------------------------------------------------------------------------
 * gtcmtr_lke_clearreq : displays the cleared lock tree received from a gtcm_server running on a remote node
 * used in	       : lke_clear.c
 * ---------------------------------------------------------------------------------------------------------
 */

#include "mdef.h"

#include "gtm_string.h"
#include "gtm_stdio.h"

#include <stddef.h>

#include "gdsroot.h"
#include "gdsblk.h"
#include "gtm_facility.h"
#include "fileinfo.h"
#include "gdsbt.h"
#include "gdsfhead.h"
#include "filestruct.h"
#include "cmidef.h"
#include "hashtab_mname.h"	/* needed for cmmdef.h */
#include "cmmdef.h"
#include "mlkdef.h"
#include "cmi.h"
#include "util.h"
#include "iosp.h"
#include "gtcmtr_protos.h"
#include "gvcmz.h"
#include "gtmmsg.h"
#include "gtcm_find_region.h"
#include "lke_cleartree.h"

#define FLUSH		1
#define LOCK_CLEAR_CONF	"Clear lock? "

GBLREF	short			crash_count;

bool gtcmtr_lke_clearreq(struct CLB *lnk, char rnum, bool all, bool interactive, int4 pid, mstr	*node)
{
	clear_confirm	conf;
	clear_reply	crep;
	clear_request	creq;
	show_reply	srep;
	bool		locks = FALSE, removed;
	uint4		status;
	char		res;
	int4		fao[2];

	error_def(ERR_LCKSGONE);

	creq.code = CMMS_U_LKEDELETE;
	creq.rnum = rnum;
	creq.all = all;
	creq.interactive = interactive;
	creq.pid = pid;
	creq.nodelength = node->len;
	memcpy(creq.node, node->addr, node->len);
	lnk->cbl = SIZEOF(creq);
	lnk->mbf = (unsigned char *)&creq;
	lnk->ast = NULL;
	status = cmi_write(lnk);
	if (CMI_ERROR(status))
	{
		((link_info *)(lnk->usr))->neterr = TRUE;
		gvcmz_error(CMMS_U_LKEDELETE, status);
		return FALSE;
	}
	if (interactive)
	{
		removed = FALSE;
		for (;;)
		{
			lnk->mbl = SIZEOF(srep);
			lnk->mbf = (unsigned char *)&srep;
			status = cmi_read(lnk);
			if (CMI_ERROR(status))
			{
				((link_info *)(lnk->usr))->neterr = TRUE;
				gvcmz_error(CMMS_V_LKESHOW, status);
				return FALSE;
			}
			if (srep.code != CMMS_V_LKESHOW)
			{
				if (removed)
					gtm_putmsg(VARLSTCNT(1) ERR_LCKSGONE);
				return locks;
			}
			util_out_print(srep.line, FLUSH);
			locks = TRUE;
			util_out_print(LOCK_CLEAR_CONF, FALSE);
			res = '\0';
			res = getchar();
			conf.clear = ('y' == res || 'Y' == res);
			removed |= conf.clear;
			lnk->cbl = SIZEOF(conf);
			lnk->mbf = (unsigned char *)&conf;
			status = cmi_write(lnk);
			if (CMI_ERROR(status))
			{
				((link_info *)(lnk->usr))->neterr = TRUE;
				gvcmz_error(CMMS_U_LKEDELETE, status);
				return FALSE;
			}
		}
	} else
	{
		lnk->mbl = SIZEOF(crep);
		lnk->mbf = (unsigned char *)&crep;
		for (;;)
		{
			status = cmi_read(lnk);
			if (CMI_ERROR(status))
			{
				((link_info *)(lnk->usr))->neterr = TRUE;
				gvcmz_error(CMMS_V_LKESHOW, status);
				return FALSE;
			}
			if (crep.code != CMMS_V_LKESHOW)
				return locks;
			gtm_putmsg(VARLSTCNT(3) crep.status, crep.locknamelength, crep.lockname);
			locks = TRUE;
		}
	}
}